05-01-2013 09:31 AM
I'm trying to learn labview. I have been able to do serial communication based on basic read write example. I can send single byte. Actually I'm only reading from serial port within labview. What I need to do is receiving 4 bytes and combine them as a single 32 bit integer. I'm setting read buffer as 4. I have basically 2 problems:
1- Since the sender and the receiver(labview) does not begin communication at the same time there is a sync problem. The incoming bytes are not in order (LSB and MSBs may not be in the right place)
2- I should interpret the coming characters as numbers and combine 4 of them into a single number and do it in the right order, and then do it continuously and then store them in an array.
Can you give me some tips. Is there an easy way to do this?
Note:I'll also send the same integer back in the future. Sending a 32 bit number to the port idea is also appreciated.
Thanks.
Solved! Go to Solution.
05-01-2013 11:07 AM - edited 05-01-2013 11:07 AM
What device are you communicating with? Can you be a bit more specific with the your hardware?
05-01-2013 03:28 PM
Hi, I'm using an mcu to send the data to the pc(labview). I can modify the sent data if required.
05-01-2013 03:52 PM
Since you have control of the protocol, you can handle this however you want. I would recommend using a command/response type of communication. You send a command to the microcontroller and the microcontroller sends the data back. If you need to stream data, then have a Start Stream command and a Stop Stream command. This way you can make sure the serial buffers are clear and you can read the data properly.
Now the serial drivers (I assume you are using VISA) send strings. So what you will want to do is use the Flatten To String and Unflatten From String to convert the data type back an forth.