Lazarus
Programming => Operating Systems => Windows CE => Topic started by: mmikac on May 14, 2010, 08:39:07 pm
-
I have to manage detection when serial (print) device is off (automtic power down for example).
However, when I define permanent paired connection between IPAQ and this device, neither I get any exception when trying to write to temporaray unavailable device, neither anything else..
(I tried to use 1. try..except on assignfile to com port and rewrite/writeln, 2. ioresult with $i-/$i+ directives, 3. fileexists() ...)
-
Maybe you could show some code to make more clear what you are doing.
-
RTS/CTS is the "standard way" to detect if device is ready to accept input.
If you use only tx & rx-lines without any HW-handshake there is "no way" to detect before you send anything..
Then the "only" option is ask the device if it's alive..
eg. like sending command AT to a modem, you get back OK.. Then you know.
Edit: Ahh.. I see now, you want to detect if the local device is still there, not if the extrernal device is alive.. Sorry..
-
I found a (good) unit already writen for the serial port called Synapse writen by Lukas Gebauer Found at URL: http://www.ararat.cz/synapse
It uses the Windows registry to determine which ports are active in Windows under the /HARDWARE\DEVICEMAP\SERIALCOMM' key in the "HKEY_LOCAL_MACHINE" root.
For Linux the funtion just returns the result of '/dev/ttyS0,/dev/ttyS1,/dev/ttyS2,/dev/ttyS3'
The Windows device drivers will update the registry anytime they detect new hardware like a USB serial device. There is another key somewhere in the registry that list all of the ports that have ever been connected not that it's not what you're looking for