LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

RS232 - Error Handling

Solved!
Go to solution

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

0 Kudos
Message 1 of 9
(5,456 Views)
U just send some querie, and wait for reply (VISA VXI Cmd or Query). If u got reply then ur connection was not lost.
Message Edited by Baji on 04-28-2009 11:17 AM
Balaji PK (CLA)
Ever tried. Ever failed. No matter. Try again. Fail again. Fail better

Don't forget Kudos for Good Answers, and Mark a solution if your problem is solved.
0 Kudos
Message 2 of 9
(5,451 Views)

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

0 Kudos
Message 3 of 9
(5,445 Views)
Where u r getting the error.
Balaji PK (CLA)
Ever tried. Ever failed. No matter. Try again. Fail again. Fail better

Don't forget Kudos for Good Answers, and Mark a solution if your problem is solved.
0 Kudos
Message 4 of 9
(5,444 Views)

error out indicator of the VI 'VISA VXI Cmd or Query'.

 

--
Joachim

0 Kudos
Message 5 of 9
(5,442 Views)

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

 

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 6 of 9
(5,422 Views)
Solution
Accepted by topic author Joachim082

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

0 Kudos
Message 7 of 9
(5,416 Views)

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.

0 Kudos
Message 8 of 9
(5,394 Views)

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

0 Kudos
Message 9 of 9
(5,374 Views)