Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- import serial
- ser = serial.Serial(
- port='/dev/ttyO4',
- baudrate=9600,
- parity=serial.PARITY_ODD,
- stopbits=serial.STOPBITS_TWO,
- bytesize=serial.SEVENBITS
- )
- ser.open()
- ser.isOpen()
- print 'Enter your commands below.\r\nEnter "exit" to leave the application.'
- input=1
- while 1 :
- # get keyboard input
- input = raw_input(">> ")
- if input == 'exit':
- ser.close()
- exit()
- else:
- # send the character to the device
- ser.write(input + '\r\n')
- out = ''
- # wait 1 second before reading output
- time.sleep(1)
- while ser.inWaiting() > 0:
- out += ser.read(1)
- if out != '':
- print ">>" + out
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement