01-28-2013 04:24 PM
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.
Solved! Go to Solution.
01-28-2013 04:29 PM
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.
01-28-2013 05:08 PM
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).
01-28-2013 05:24 PM
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.
01-28-2013 05:53 PM
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.
01-28-2013 09:26 PM
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