ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

取消
显示结果 
搜索替代 
您的意思是: 

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 项奖励
1 条消息(共 10 条)
9,216 次查看

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
2 条消息(共 10 条)
9,213 次查看

Hi, GerdW

 

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

 

Sort

 

0 项奖励
3 条消息(共 10 条)
9,205 次查看

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.



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
4 条消息(共 10 条)
9,175 次查看

Hi, crossrulz

 

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

 

Sort

0 项奖励
5 条消息(共 10 条)
9,152 次查看

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 项奖励
6 条消息(共 10 条)
9,123 次查看

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 项奖励
7 条消息(共 10 条)
9,113 次查看

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



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 项奖励
8 条消息(共 10 条)
9,107 次查看

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 项奖励
9 条消息(共 10 条)
8,622 次查看

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 项奖励
10 条消息(共 10 条)
8,602 次查看