Module comscan
[show private | hide private]
[frames | no frames]

Module comscan

Detect and enumerate com(serial) ports

You should close all com ports you have open before calling any
functions in this module.  If you don't they will be detected as in
use.

Call the comscan() function It returns a list with each entry being a
dictionary of useful information.  See the platform notes for what is
in each one.

For your convenience the entries in the list are also sorted into
an order that would make sense to the user.

Platform Notes:
===============

w  Windows9x
W  WindowsNT/2K/XP
L  Linux
M  Mac

wWLM name               string   Serial device name
wWLM available          Bool     True if it is possible to open this device
wW   active             Bool     Is the driver actually running?  An example of when this is False
                                 is USB devices or Bluetooth etc that aren't currently plugged in.
                                 If you are presenting stuff for users, do not show entries where
                                 this is false
w    driverstatus       dict     status is some random number, problem is non-zero if there is some
                                 issue (eg device disabled)
wW   hardwareinstance   string   instance of the device in the registry as named by Windows
wWLM description        string   a friendly name to show users
wW   driverdate         tuple    (year, month, day)
 W   driverversion      string   version string
wW   driverprovider     string   the manufacturer of the device driver
wW   driverdescription  string   some generic description of the driver
  L  device             tuple    (major, minor) device specification
  L  driver             string   the driver name from /proc/devices (eg ttyS or ttyUSB)

Classes
RegistryAccess A class that is significantly easier to use to access the Registry

Function Summary
  comscan(*args, **kwargs)
Call platform specific version of comscan function
  _cmpfunc(a, b)
Comparison function for two port names
  _comscanlinux(maxnum)
Get all the ports on Linux
  _comscanmac()
Get all the ports on Mac
  _comscanwindows()
Get detail about all com ports on Windows
  _IsLinux()
  _IsMac()
  _IsWindows()
  _stringint(str)
Seperate a string and trailing number into a tuple

Function Details

comscan(*args, **kwargs)

Call platform specific version of comscan function

_cmpfunc(a, b)

Comparison function for two port names

In particular it looks for a number on the end, and sorts by the prefix (as a string operation) and then by the number. This function is needed because "com9" needs to come before "com10"

_comscanlinux(maxnum=9)

Get all the ports on Linux

Note that Linux doesn't actually provide any way to enumerate actual ports. Consequently we just look for device nodes. It still isn't possible to establish if there are actual device drivers behind them. The availability testing is done however.
Parameters:
maxnum - The highest numbered device to look for (eg maxnum of 17 will look for ttyS0 ... ttys17)

_comscanmac()

Get all the ports on Mac

Just look for /dev/cu.* entries, they all seem to populate here whether USB->Serial, builtin, bluetooth, etc...

_comscanwindows()

Get detail about all com ports on Windows

This code functions on both win9x and nt/2k/xp

_stringint(str)

Seperate a string and trailing number into a tuple

For example "com10" returns ("com", 10)

Generated by Epydoc 2.1 on Fri Aug 15 18:58:25 2008 http://epydoc.sf.net