Seems to be a system issue causing
[cc lang=”python”]
for i in range(256):
try:
self.ser = serial.Serial(i, 9600)
print “serial initialized: “, self.ser
break
except:
self.ser = None
[/cc]
to think there is a serial device on COM 1 (i = 1). The serial monitor in arduino indeed does see COM 1 and COM 4 but only messages are arrive from COM 4. I guess COM 1 is just an active serial port which may or may not have messages arriving on it and the system could care less about this fact.
In any case, this is not an issue on the tablet itself, and for testing purposes, the above issue is easily resolved by skipping COM 1 i.e. range(2,256)
Also, 9600 BAUD is pretty slow. The serial portion of the code as it is does not run on a thread and calls readline() twice to read a message. The first readline ensures that the last time flushinput was called, it was not cut off in the middle of some message. As it is, the code reads readline() x2 followed by flushinput(). On Eddo’s BEAST, this is is never an issue as the program runs fast enough that the readlines are always waiting on new messages as opposed to reading messages already in the buffer. One can simply use a single readline and no flushinput. On the tablet, this can be an issue as the program runs slower and often there is a lot queued in the buffer. There is still an issues of the program hanging on readline if the program is running a little faster but I don’t think this will happen often, i.e. it’s something I can ignore.