Recent

Author Topic: serial port, paired device...  (Read 8955 times)

mmikac

  • New Member
  • *
  • Posts: 26
serial port, paired device...
« 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() ...)

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: serial port, paired device...
« Reply #1 on: May 20, 2010, 05:55:38 pm »
Maybe you could show some code to make more clear what you are doing.

Lazlover

  • Newbie
  • Posts: 2
Re: serial port, paired device...
« Reply #2 on: May 20, 2010, 06:26:29 pm »
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..


« Last Edit: May 20, 2010, 08:29:33 pm by Lazlover »

mas steindorff

  • Hero Member
  • *****
  • Posts: 532
Re: serial port, paired device...
« Reply #3 on: May 20, 2010, 09:50:05 pm »
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
windows 10 &11, Ubuntu 21+ - fpc 3.0.4, IDE 2.0 general releases

 

TinyPortal © 2005-2018