XMail Filters And Utilities
Home Gschänk-Atelier Kunst Bilder Software über uns Suche Sitemap Links
Software > Development > PHP stuff >
PHP stuff page   

PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML. And much more ...

On this page you will find a some scripts or tools I have written quick'n'dirty for use with PHP. They are used in real-world environment and are considered very useful for a long period. This may not necessarily be the case for everyone else than me, but they may at least be a starting point for you and leave room for your own modifications.


A replacements for the Windows 'mode' command.

The main problem using PHP for serial communication on a Windows PC is the fact that there's no way to set up the port timeouts correctly. A PHP script that opens a COM port for communication with a serial device such as a modem will always wait for a timeout that is set to 60000ms by 'mode' when expecting data coming in. Setting the stream to non-blocking doesn't help.

SerConf has the ability to set up the port timeouts. It's in fact a setup tool for the SetCommState and SetCommTimeouts Windows functions. It does no console setup and offers no lpt redirection as 'mode' does.

  • does not fully support all features of 'mode'
  • but supports port timeouts, for read and write separately
  • if timeouts are specified it makes use of the WriteTotalTimeoutMultiplier but never of the ReadIntervalTimeout
  • simpler handshake setup

usage example:

serconf com3 baud=38400 stop=1 parity=none handshake=both rtimeout=10 wtimeout=10

help (called without parameter):

SERCONF version 0.3
Usage: serconf  [opts/commands]

Where opts/commands are:
  Baud=<value>          baud rate (110 to 256000, default=keep current)
  Parity=<type>         'none' (default), 'even', 'odd', 'mark' or 'space'
  Data=<value>          7 or 8 (default) bits
  Stop=<value>          1 (default) or 2 stop bits
  Handshake=<type>      'none' (default), 'dtr', 'rtc' or 'cts', 'both'
  WTimeout=<value>      milliseconds (default=1000, 0=no timeout)
  RTimeout=<value>      milliseconds (default=1000, 0=don't wait at all)
Download the SerConf tool