From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA Read Return Count does not match Byte Count

Hello, all,

 

I'm encountering an error with a VISA Read.  The output value(bytes read) of VI(Bytes at Port) is 32 bytes, but I  only get 8 back (Return Count)? Anyone know what's happening?read.png VISA Read block oddly enough does not return an error.  Any ideas on how to debug this?

0 Kudos
Message 1 of 10
(7,104 Views)

Hi sort,

 

it would help to know the whole picture including the initialization of the serial port!

 

My glass ball says: You have configured a TermChar and VISARead stops to read when receiving this TermChar!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 10
(7,101 Views)

Hi, GerdW

 

You got it, After disabled  enable terminate character (VISA configure serial port ), everything is working fine. Thank you.

 

Sort

 

0 Kudos
Message 3 of 10
(7,093 Views)

So you understand what your current issue is, but I have to state that using the Bytes At Port to determine how many bytes to read is generally a bad practice when the instrument sends out ASCII data.  Most instruments use that termination character to state when a message is complete.  So you tell the VISA Read to read more bytes than a message will be and it will just return the message.  You can then process that message, loop around and read the next message.  With the Bytes At Port, you can get multiple messages, partial messages, and who knows what other message synchronizing issues.


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
Message 4 of 10
(7,063 Views)

Hi, crossrulz

 

Thanks for your comments. It's very useful information.

 

Sort

0 Kudos
Message 5 of 10
(7,040 Views)

Preventing LabVIEW from Continuously Polling the Serial Port,I used an event handling to improve program efficiency. It's looking work well. Share it with everyone. FYI.

 

rs232 reader.png

0 Kudos
Message 6 of 10
(7,011 Views)

While that might work this is the generally accepted way of handling serial communications.

 

SerialCapture.PNG

VISA Read will read the serial port until it receives a termination character or times out

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 7 of 10
(7,001 Views)

@sort897 wrote:

Preventing LabVIEW from Continuously Polling the Serial Port,I used an event handling to improve program efficiency. It's looking work well. Share it with everyone. FYI.

 


I do not like to use the events for VISA.  Depending on how the instrument works, I will either use Bytes At Port to see if any data has come in and then use a Wait or something if there is no data or I will just use the Read and let the timeout tell me that the instrument is not sending anything.

 

I really need to get those nuggets done...


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 8 of 10
(6,995 Views)

hello,sort897

   I use the bled112 

   It is occuring a error Service: 1800 and Characteristic 2A00 were not found when connection the device

 

your help would be very nice.

thank you

0 Kudos
Message 9 of 10
(6,510 Views)

I'm sorry, but your message is not very clear.  What are "Service:1800" and "Characteristic 2A00"?  And "bled112"?

 

So far, nothing you've posted sounds related to what this thread was originally about.

 

You should post a new message thread that includes details, and perhaps your VI.

0 Kudos
Message 10 of 10
(6,490 Views)