+++ /dev/null
-import os, termios
-from time import sleep
-import logging
-from serial import *
-
-class SerialClientException(Exception): pass
-
-class SerialClient:
- def __init__(self, port = '/dev/ttyS1', baud = 9600):
- self.ser = Serial(
- port = port,
- baudrate = baud,
- bytesize=EIGHTBITS, #number of databits
- parity=PARITY_NONE, #enable parity checking
- stopbits=STOPBITS_ONE, #number of stopbits
- timeout=10, #set a timeout value, None for waiting forever, return on read
- xonxoff=0, #enable software flow control
- rtscts=0, #enable RTS/CTS flow control
- )
-
-
- self.rfh = self.ser
- self.wfh = self.ser
- self.wfh.write('B\n')
-
- def get_fh(self):
- return (self.rfh, self.wfh)
-
- def __del__(self):
- pass
-
-
-if __name__ == '__main__':
- s = SerialClient("/dev/ttyS1", 9600)
-
- (rfh, wfh) = s.get_fh()
-
- wfh.write('B\n')
- print rfh.read()
-
-