1

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!

userX
  • 305
  • 2
  • 15
  • I just checked it by putting in some print statements. It hangs on the read(), after completing tens of successful reads (a hundred? I have not counted them). Advice appreciated. – userX Jun 04 '13 at 22:59
  • are ou sure that there is more data to read? – User Jun 05 '13 at 20:13
  • yes -- I have connected the serial port to a pc -- and I am typing into a terminal session. – userX Jun 13 '13 at 05:55
  • Have you tried to use minterm or similar, to just ensure your device it's OK? – Tolo Palmer Feb 06 '14 at 12:21

0 Answers0