Showing results for 
Search instead for 
Did you mean: 

VISA read where the number of bytes is unknown?

Go to solution

I'm working with a VISA resource over USB that reads in the results of printf(%lu %hhu %d) from a microcontroller. As these results are numbers in ASCII, their length in bytes is unkown. The numbers *should* be no more than 3 digits, but I can't know that for sure. VISA Read won't let me leave the number of bytes unwired, so should I just attach a high constant to it? Or is there a better way?

0 Kudos
Message 1 of 4
Accepted by topic author ijustlovemath

1.  Have the microcontroller send an End Of Line character (0xA on the ASCII table) at the end of the printf.

2. Enable the Termination Character of the VISA session and set it to be 0xA.  You may have to do that through the VISA property node.

3. Tell the VISA Read to read more bytes than you would ever expect to get.  The VISA Read will stop reading when it finds the termination character (the End Of Line).

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
Message 2 of 4
If the micro is appending a termination character such as a carriage return or a line feed, you enable that with VISA Configure Serial Port and just specify some arbitrary high number of bytes to read.
0 Kudos
Message 3 of 4

Thanks guys! I've noted this as solved.

0 Kudos
Message 4 of 4