04-28-2009 12:32 AM
Hi,
I am reading continuous data from a RS232 interface. During the communication it might can be that the remote station is powered off due to maintenance work. How can I determine the connection lost? The error out of the function 'Number of Bytes at Port' and 'Read Serial' is empty. Do I have to set a property to enable error handling? What I'm doing wrong? I've attached a screenshot of a test vi where independent of connecting the RS232 cable no error code is displayed.
Kind Regards,
--
Joachim
Solved! Go to Solution.
04-28-2009 12:47 AM - edited 04-28-2009 12:47 AM
04-28-2009 01:00 AM
Hi Baji,
Thanks for the response. Unfortunately I receive the error code -1073807257 (not supported) independent if the device is connected or not.
Kind Regards,
--
Joachim
04-28-2009 01:03 AM
04-28-2009 01:04 AM
error out indicator of the VI 'VISA VXI Cmd or Query'.
--
Joachim
04-28-2009 01:48 AM
That's what the timeout is good for.
You didn't specify if you poll the data (send a query command to the device and read the answer) or if the device is pushing the data (sending each ?? second(s) some byte) .
However, whenever the connection is down, you woun't get any bytes back .
You can use the build in timeout and try to read 1 or more byte or build your own timeout in the polling loop with 'Number of Bytes at Port' ...
04-28-2009 02:19 AM
I send a start aquisition command to the device and I read the data continuously. Because I am aquiring the data of two devices simultanously with different sample rates I have to store the last data package on a shift
register to have a "simulated" synchronuous aquisition of both devices. That means that the property of Bytes at Port has to be 15 to read the data with VISA Read. If not I use the last 'good' package with 15 bytes from
the shift register. Thus I can only use the Number of Bytes property to determine if I don't get data for a longer period of time using the Tick count information for the VISA Read compared with the current Tick count.
--
Joachim
04-28-2009 09:07 AM
Does this mean you have a solution?
In the VI you posted, you are not doing continuous reads. Your error handling is correct and you should not expect an error if the instrument is not there. There will obviously not be any bytes to be read and the VISA Read will not return an error when it's told to read 0 bytes.
If you actually do have a VISA Bytes at Serial Port and a VISA Read in a loop, then the only way to determine if the instrument is offline is to count how many consecutive times the function returns 0.
p.s. the idea of using VXI functions for serial communications is incorrect.
04-28-2009 11:20 PM
Yes I've solved the problem with calculating my own timeout. In the example VI this was of course no continuous reading - it should only point out that there is no error independent of connecting the remote station or not.
I've attached my solution.
--
Joachim