10-20-2022 06:31 AM - edited 10-20-2022 07:11 AM
--Hello everyone,
I have been working on a device which outputs binary data of 9-14 bytes for a single command I write each time using VISA Write(depending on the data size). As the communication protocol is in binary format, I disabled termination character at 'VISA Serial Config' function. Can anyone tell how to input binary count to VISA Read function when the output varies in byte count.
From the beginning, I avoided using 'Bytes at Port' property node to feed 'Byte count' input, but as I received Timeout error everytime, I tried using it with a wait of 10mS after VISA Write. Although it worked out fine except with a warning (Hex 0x3FFF0006), I am looking forward to know any better method to get variable sized binary output data without changing byte count value everytime. Thank you. 🙂
Solved! Go to Solution.
10-21-2022 08:28 AM
Is this a SCPI device? If so then the binary data conforms to a format (forget name).
First char is '#"
Second char is either 0 or some number between 1 and 9. This refers to the next block of characters. eg if 3 then the next 3 chars are how much data will follow this. If 0 then it is a indefinite length block.
so in this example the 3rd, 4th and 5th chars are the length of the data to follow.
data....
linefeed
10-21-2022 09:00 AM
Well, you are halfway there.
In general terms, you read the message based on the protocol. Can you define the message protocol? We can give better advice with that information.
10-24-2022 03:47 AM
Thank you for the response.
I send the following instruction to the device.
And I receive the following message from the device.
Based on the size, the register data 'XXX' can be in between 2-9 bytes. Block check character is the sum of XOR of bytes from C1 to ETX.
For example, I send the instruction "\0411:7\05", I may receive "\02:7+8905\03!" which is of 11 bytes.
Here, EOT = Hex 04, ENQ = Hex 05, AD1=ASCII 1, AD2=ASCII 1, C1=ASCII :, C2=ASCII 7, STX=Hex 02, ETX=Hex 03, XXX=ASCII +8905, BCC=ASCII !
10-24-2022 06:49 AM
This is an interesting protocol since it mixes binary and ASCII. I think I would set the Termination Character to ETX (0x03), try to read more than 13 bytes (I would probably use 50 out of habit) to read the STX and the message, and then read an additional character to BCC.
10-24-2022 08:06 AM
Great, Thank you so much. That worked out well without the use of any wait function b/w VISA Read & Write.