Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA Read Byte count - binary data format input

Solved!
Go to solution

--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. 🙂

0 Kudos
Message 1 of 6
(1,265 Views)

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

 

 

0 Kudos
Message 2 of 6
(1,196 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 6
(1,191 Views)

Thank you for the response.

I send the following instruction to the device.

MachinePossible_0-1666599562842.png

And I receive the following message from the device.

MachinePossible_1-1666599770838.pngMachinePossible_2-1666599798700.png

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 !

0 Kudos
Message 4 of 6
(1,150 Views)
Solution
Accepted by topic author MachinePossible

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 6
(1,132 Views)

Great, Thank you so much. That worked out well without the use of any wait function b/w VISA Read & Write.

0 Kudos
Message 6 of 6
(1,121 Views)