LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP( EXAM QUESTION ANYONE PLEASE CHECK IT ).

Solved!
Go to solution

Design a TCP server to provide the service exam service on the port 50601 .The server expect to read a message made of N bytes with the following structure:

Byte 0: length(u8)

Byte 1:command(u8)

Byte 2...Byte(N-1): Data Bytes (u8)

The first byte represent the message length(N).

The second byte is the command byte.

The remaining bytes are the data bytes.i.e a sequence of u8 representing codes collected from an 8bits analog to digital converter.

 

The server acts as in the following

1. If the command byte is equal to the hexadecimal code 0xAA the server builds a waveform converting the array of U8 samples (Data byes)to doubles(dbl)and scaling them to represent the voltage levels between 0v and 1 v.Assume for the waveform t0 the current time and dt=1ms .the server plots the samples and save the wavform to the file samples.txt.and  send to the client response DATA SAVED

2. If the 1st byte is equal to the hexadecimal code 0xBB the server builds a waveform converting the array of u8 samples(DATA BYTES) TO doubles(dbl)and sacling them to represent the voltage level between 0v and 1v.THE SERVER Calculates the maximum and minimm and avarage of teh recieved samples,show the result to the user in the fromt panel.

3. Every time a successful connection is closed ,the server saves the date,the time,the ip address of the remote client and the recieved byte(on a file entitled server log text)

4.any error ,the server jst replies the message ERROR OR MALFORMED REQUEST  and drops the connection.

0 Kudos
Message 1 of 15
(3,862 Views)

help

0 Kudos
Message 2 of 15
(3,832 Views)

Balbal207,

 

If you are going to post homework/take home tests please ask specific questions that we can help you with.  I see you attached what you have tried, which is great, now what is not happening as you expect it to?

Matt J | National Instruments | CLA
0 Kudos
Message 3 of 15
(3,814 Views)

i want to know the first part of the program before case structure is correct or not.

0 Kudos
Message 4 of 15
(3,799 Views)

first byte,data byte and command byte

0 Kudos
Message 5 of 15
(3,797 Views)

@balbal207 wrote:

Design a TCP server to provide the service exam service on the port 50601 .The server expect to read a message made of N bytes with the following structure:

Byte 0: length(u8)

Byte 1:command(u8)

Byte 2...Byte(N-1): Data Bytes (u8)

The first byte represent the message length(N).

The second byte is the command byte.

The remaining bytes are the data bytes.i.e a sequence of u8 representing codes collected from an 8bits analog to digital converter.


Your code has very little resemblance to the stated requirements:

 

You are only reading one set of data, then spin the loop forever doing the same thing over and over until stop is pressed. almost everything belongs inside the while loop!

You are not even looking at the first receive byte (the lenght!). You need that to decide how much more to read. You need to look at what the read returns, not the size (1) you wire into the read! That's just silly!

How many times do you need to calculate 1/255? Are you expecting different results every time?

What's up with all the coercions and type mismatches?

Why do you wire the net address? What IP is 193.205.4.11?

 

Do some LabVIEW tutorials. Learn about dataflow and programming basics. Look at the TCP examples that ship with LabVIEW!

0 Kudos
Message 6 of 15
(3,770 Views)

yes ,but is it correct  the command byte and remaining bytes(N-2).so i want to keep only this first  one outside and then i have to put command byte and remaining bytes inside the loop

0 Kudos
Message 7 of 15
(3,757 Views)

@balbal207 wrote:

yes ,but is it correct  the command byte and remaining bytes(N-2).so i want to keep only this first  one outside and then i have to put command byte and remaining bytes inside the loop


Not is is not correct. In your code N is always 1 and N-2 is thus always -1. You need to process the output of the first read to get N.

 

No, you need to wait for a connection inside the loop and once a connection is made process the data once (not inside another loop repeating the same operation over and over), then send the response back and close the connection. Then you go back at listening for the next conenction, all inside one loop.

0 Kudos
Message 8 of 15
(3,749 Views)

can u please check this

0 Kudos
Message 9 of 15
(3,744 Views)

can u please check it..now i added timeout for other two.

0 Kudos
Message 10 of 15
(3,713 Views)