It just prints "None" twice a second, LOL. Still no data printed when sending from phone. I know the data is going from the phone to the RPi though - loading one of my other previous scripts does print the data on the screen (the one with all the open/close ropey code in it that would eventually hang up somewhere).
How is the while 1 loop getting the "msg" data from within the comm_mon thread? If I were to guess, the data for "print msg" is coming from the first line of code rather than from within the comm_mon thread function.
Code: Select all
msg = None def openConn(): global conn while True: try: conn = serial.Serial("/dev/rfcomm0", baudrate=9600) return except serial.SerialException: pass def comm_mon(): global conn, msg while True: try: msg = conn.readline().strip("\n") except serial.SerialException: conn.close() time.sleep(0.2) openConn() openConn() t = threading.Thread(target=comm_mon) t.start() while 1: time.sleep(0.5) print msg