From: Maxious Date: Sat, 29 Sep 2012 14:02:54 +0000 Subject: add serial port reading X-Git-Url: https://maxious.lambdacomplex.org/git/?p=scannr.git&a=commitdiff&h=aa30d3bc3c8200cfda6e3821314d1b6b2595f677 --- add serial port reading --- --- a/scannr.py +++ b/scannr.py @@ -8,6 +8,8 @@ import threading from pydispatch import dispatcher import wave +import serial +#python -m serial.tools.miniterm -p COM20 -e -b 115200 --cr filename = "demo.wav" MIN_LENGTH = 90000 @@ -20,7 +22,9 @@ http://stackoverflow.com/questions/2559746/getting-error-while-converting-wav-to-amr-using-ffmpeg """ print 'Worker for '+filename - + ser.write("GLG\r") + line = ser.readline() # read a '\n' terminated line + print line return def filenameMaker(): @@ -45,8 +49,11 @@ dispatcher.connect( filenameMaker, signal='SND_STARTED', sender=dispatcher.Any ) dispatcher.connect( worker, signal='FILE_CREATED', sender=dispatcher.Any ) + +ser = serial.Serial('COM20', 112500, timeout=1) + print "Scannr started..." while True: print "ready to record" record_to_async_file() - +ser.close()