Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Visa Read does not read all bytes at port

Solved!
Go to solution

I have a device I am communicating with via Serial Port. I have a standard communication protocol. For a particular command, I know the exact number of bytes expected in return. I send my command. I see the correct and exepcted number of bytes at the port. I then read the number of bytes at the port. However, the VISA read only returns the first two bytes.

 

I have successfully communicated with this device and this protocol for over 130 unique and different commands. There are only about 6 commands in which the visa read fails to read all the bytes at the port. Does anyone know why this would happen?  I expect to see 6 bytes. I see 6 bytes. I issue the visa read command with 6 bytes. The visa read returns only the first 2 bytes. It is very very frustrating. I can do this exact same process with a different command. I expect 45 bytes from that command. I see 45 bytes with that command and I read 45 bytes with that command.

 

I do not believe this is device related as I can successfully converse with the same device on the same computer with the same connector cable utilizing not-LabView. It appears to be an issue strictly related to labview and the VISA read command. If anyone could help that would be greatly apprecicated.

 

Thank you.

0 Kudos
Message 1 of 6
(8,823 Views)

It sounds like your program may not be written correctly but you have not posted it or details on the instrument and command. You should be aware that the default setting for the configure serial port is to enable the termination character and with this set, the VISA Read will terminate as soon as the character is detected. In this case, it does not matter how many bytes you request.

Message 2 of 6
(8,817 Views)

My very first thought was that you have the termination character set to TRUE.  The third byte of the returned message is likely what VISA thinks the termination character is (0x0A by default).


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 3 of 6
(8,809 Views)

The details of this application are as follows:

 

Open a VISA Serial Port, 9600 baud rate, odd parity, 1 start bit, 8 data bits, 1 stop bit.

 

Send a command byte value between 0 - 255.

Receive response in bytes.

It is the exact same for all commands 0-255.

The VI is ridiculously simple. Wire a VISA Open to a VISA Write to a VISA Property Node to a VISA Read to a VISA Close.

 

I issue the Cmd byte via the VISA Write command. I expect X bytes at the port. I utilize the VISA Property Node >> Bytes At Port. It sees X bytes at the port.At this point it is flawless. Every single command works perfectly. They all transmit the appropriate number of bytes in return from the device.

 

I utilize the VISA Read and wire the bytes at port to the byte count.

 

For commands exepcting 6 bytes, the VISA Property node sees six bytes at the port, the VISA Read only Reads the first two.

0 Kudos
Message 4 of 6
(8,805 Views)
Solution
Accepted by topic author TennesseePaul

What is the exact byte stream you are expecting back with this command?

 

Instead of the VISA Open, use the Configure Serial Port VI.  That way you can override the defaults.  It sounds like your instrument uses all of the VISA defaults for baud rate, start and stop bits, etc.  However, in the VISA software, there is a default to use a termination character and this character is 10 (0x0A).  If you use the Configure Serial Port, you can tell the VISA driver to not use the termination character.


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 5 of 6
(8,801 Views)

Dude, I think you nailed it! I need to verify tomorrow, but that may very well be the case.

 

And, I mis-spoke, I am using the Serial Configure VI, not the Open Serial. However, I think you nailed it because while I sit here at home scratching my head bald trying to re-work this in my mind, I cannot recall if I set the Termination Character or not. So that is the most logical response yet.

 

I will certainly check this tomorrow morning and if correct, dish out props and kudos.

 

Thanks,

 

Tennessee

Message 6 of 6
(8,786 Views)