07-03-2015 10:36 AM
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.
Solved! Go to Solution.
07-03-2015 11:53 AM
help
07-03-2015 12:02 PM
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?
07-03-2015 12:26 PM
i want to know the first part of the program before case structure is correct or not.
07-03-2015 12:27 PM
first byte,data byte and command byte
07-03-2015 12:37 PM - edited 07-03-2015 12:41 PM
@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!
07-03-2015 12:47 PM
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
07-03-2015 12:56 PM - edited 07-03-2015 12:57 PM
@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.
07-03-2015 12:59 PM
can u please check this
07-03-2015 01:03 PM
can u please check it..now i added timeout for other two.