07-01-2019 10:46 AM
I have a development board that communicates over serial port. The following shows the basic properties of the serial port.
The board uses binary message format (35 bytes of ASCII encoded data is converted into binary) to communicate with a Bluetooth device which is always ON and broadcasting. In return for a successful connect , it sends back a handshake message exactly as the sent message but with a different identifier (however the total number of bytes remains the same).
For instance:
Byte array for Connect: 33, 10, 0, 0, 0, 53, 50, 82, 68, 88, 70, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 165, 1
The first byte is the ASCII exclamation mark (red)
The last 2 bytes is the sum of the middle 32 bytes (green)
Example expected result: 33, 10, 0, 0, 0, 0, 0, 0, 0, 0, 70, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 1
As you can see below, I am converting the array of 35 bytes to binary for VISA Write and I expect 35 bytes to be read back as well. Alas, I am not sure why I am not able to read anything back, and Bytes at Port always shows 0. The port settings are as per the properties figure shown above (the figure below doesn't show VISA open/close, but the attached VI should serve as a MWE).
Any advise is appreciated. Thanks.
Solved! Go to Solution.
07-01-2019 11:57 AM - edited 07-01-2019 11:58 AM
Of course it is 0, you didn't provide anywhere near enough time between the VISA Write and the Bytes at Port to give the device time to respond!
This is yet another example of where "Bytes at Port" is the wrong thing to use. Get rid of it.
Since you know the response string is the same length as the Write string, just get the length of the string you wrote then wire that into the VISA Read.
Also, the VISA configure should be before the loop, not inside.
07-01-2019 12:18 PM
07-01-2019 12:23 PM
It says Byte Count. Not Bit Count. Why would you think you'd wire 280?
07-01-2019 12:44 PM
Did all three changes as per your advice. Played around with time factor ranging from 10s to 60s. Didn't make a difference yet.
advanced properties of the serial port board.
07-01-2019 12:57 PM
I'm confused. And I guess I missed that part the first time you posted the VI image. Why are you converting your 35 byte string into a string of 0's and 1's?
You had said you were sending 35 bytes and gave examples of that. I didn't see your For Loop where you converted each byte into an 8 character string of 0's and 1's. Does your device really want that?
07-01-2019 01:20 PM
07-01-2019 01:26 PM
07-01-2019 01:38 PM
NO NO NO.
Your string manipulation turned 35 bytes into 280 bytes when you converted each byte of data into 8 bytes such as "01010101" with that inner For Loop. When you sent a "0", you sent a byte of value 48 decimal. And when you sent a "1", you sent a byte of value 49 decimal.
I really doubt your device wants 8 characters of "1" and "0". I suggest you reread the manual for your device.
07-01-2019 01:46 PM