Note that the comments tell you how to change certain features of the program. When running, the script will ‘echo’ any characters coming from the serial port to the console and ‘echo’ any characters typed in from the console to the serial port. If you give it both parameters, they can be in any order as the script can tell what is a port versus what is the rate.
If you want to override or specify either the serial port or BAUD rate just give it either or both parameters. Given no parameters, it defaults to 115200 BAUD and will search for ‘active’ serial ports with the name /dev/ttyUSB* or /dev/ttyACM* and use the first one it finds. # Uncomment the next two lines to display the typed in characters in hex format # for x in line: print ('%s') % (x.encode('hex')), # Uncomment the next line to display the input from the serial port in hex format Ser = serial.Serial(port=serport,baudrate=rate,parity=serial.PARITY_NONE,stopbits=serial.STOPBITS_ONE,bytesize=serial.EIGHTBITS,timeout=1) Print 'Unable to find any ports scanning for /dev/' + dev