[NCLUG] programming language

Sean Reifschneider jafo at tummy.com
Mon Jun 18 19:48:58 MDT 2012


On 06/07/2012 05:46 PM, Ben West wrote:
> I think, given your reply, I'm going to echo Bob here, and suggest you use
> something high-level, like python, using some c libs for serial interfacing.

No additional C libraries are required for serial access.  You can do
C-like serial access in Python via things like:

   import termios
   import TERMIOS
   import os

   modem = open(modemLine, 'w+')
   modemfd = modem.fileno()

   new = termios.tcgetattr(modemfd)
   new[0] = TERMIOS.IGNBRK | TERMIOS.IGNPAR
   new[1] = 0
   new[2] = TERMIOS.CRTSCTS | TERMIOS.HUPCL | TERMIOS.CLOCAL | TERMIOS.CREAD
   new[2] = new[2] | TERMIOS.CS8 | TERMIOS.B300 | TERMIOS.CSTOPB
   new[3] = 0
   new[4] = TERMIOS.B300
   new[5] = TERMIOS.B300
   termios.tcsetattr(modemfd, TERMIOS.TCSANOW, new)

   (rfdl, wfdl, efdl) = select.select([modemfd], [], [], 1)

   os.write(modemfd, 'ATDT\r')

Sean



More information about the NCLUG mailing list