Correction -- I'm using the first tty -- not 5 as the old version stated.
I'm in the process of writing a program to allow a TS-4200-8160 embedded arm computer to respond to serial data. My first step is to log some serial data. So I have been testing a serial logging script for the TS-4200-8160. The script starts well, collecting individual characters, then hangs on the read after collecting tens of characters (so it does work for a while):
import serial
from datetime import datetime
import time, struct
import sys
def fileout(mesg):
with open('/root/python/rs485cap.out', 'a') as f:
f.write(mesg)
def main():
ser = serial.Serial(
port=0,
baudrate=115200,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
timeout=None
)
try:
while 1:
print ser.portstr
stuff=ser.read()
fileout(stuff + ", "+str(datetime.now()) + '\n')
print stuff
except KeyboardInterrupt:
print "Bye"
ser.close()
sys.exit()
ser.close()
ser.close()
if __name__ == '__main__':
main()
What is missing? Thanks for your help!