03-15-2011 06:04 PM - edited 03-15-2011 06:08 PM
Hello everyone
I´m sending 6 different bytes through an FPGA to a computer but only need the second byte. I´m using the serial port of the computer and get the data expected but in a wrong way. The buffer is acquiring these bytes crazily. For example, I send this (I changed the binary system to decimal):
255 - 70- 64 - 30- 0 - 55,
but I get either different position of them or two copies of different bytes, and they are also in a different position. For example
70 - 0 - 64 - 255- 55 - 30 or
255 - 30 - 30- 64 - 64 - 0
I attached the code.
Does anybody know what the problem is?
Thank you in advance
03-15-2011 10:41 PM
For one thing, if you want the 2nd byte, your index value on Index Array should be 1. Array element indices are zero based.
There is no logical reason by your bytes would be reordered in the way you show them. And your one example string shows repeated values. Nothing about LabVIEW would do that. Certainly nothing in the VI you posted. What does your FPGA code look like?
There are two things that could affect byte order.
1. You start reading from the serial port in midstream of a packed of bytes. The device sends 1 2 3 4 5 6, but your reading VI opens the serial port part way through, so you start reading 6 bytes that are 3 4 5 6 1 2 where 1 and 2 are the two bytes from the next packet.
2. You are sending 16 bit or 32 bit numbers, and when you convert from 16 bit or 32 bit to individual bytes, endianism is catching up to you. So you write 16 bit value as MSB LSB (big endian) but you really wanted to send it LSB MSB (little endian).
03-16-2011 02:43 AM
First of all check whether you are getting the data correctly on the hyperterminal
Second add a serial buffer before the loop start
Third change the read value from 6 to 1.
Then check it and send the results