import os import termios import serial import time import sys # Description -------------------------------------------------------------------------------------------------------------- # Classes for serial, usb, tcp/ip communications. # # Name: channels.py # Author: W. Hetherington # Created: 2009/03/18 # Modified: 2009/03/18 # Copyright: (c)2009 # License: No restrictions #--------------------------------------------------------------------------------------------------------------------------- class SerialUSB : def __init__(self) : try: connect = serial.Serial('/dev/ttyUSB0',115200,rtscts=0,timeout=1) except: print('USB error: Perhaps the controller or operator is unplugged.') sys.exit(2) self.raw = connect # To access the serial attributes and methods directly def Write(self, s) : self.raw.write(s) def ReadLines(self) : return self.raw.readlines() def ReadLine(self) : return self.raw.readline() #--------------------------------------------------------------------------------------------------------------------------- # Execute #if __name__ == '__main__': #Test()