From a6dc38f81a78c47cb2dc73c814e85064303cfa2b Mon Sep 17 00:00:00 2001 From: klaute Date: Tue, 20 Sep 2016 13:08:56 +0200 Subject: [PATCH] Baudrate set to 115200 again, the serial flush call has fixed the serial sending problem. --- firmware/firmware.ino | 2 +- tools/meas.py | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/firmware/firmware.ino b/firmware/firmware.ino index 425a04b..7675131 100644 --- a/firmware/firmware.ino +++ b/firmware/firmware.ino @@ -22,7 +22,7 @@ void setup() pinMode(A1, INPUT); // Init the serial connection - Serial.begin(57600); + Serial.begin(115200); // initialize the command control module cc_init(); diff --git a/tools/meas.py b/tools/meas.py index 1a7758b..3344a7b 100644 --- a/tools/meas.py +++ b/tools/meas.py @@ -157,7 +157,7 @@ def cc_dataReceiverThread(): #print bytesToRead # TODO incoming = list(ser.read(64)) - print incoming # TODO + #print incoming # TODO # 2. process the received data for c in incoming: @@ -292,11 +292,13 @@ def openSerialDevice(d): # Why 115200? Because the host defines the baudrate for the USB serial connection. try: - ser = serial.Serial(d, 57600, timeout=0) + ser = serial.Serial(d, 115200, timeout=0) except: print "ERROR: Can't open the serial device " + device exit(1) + #time.sleep(2) + ##### def closeSerialDevice(): @@ -313,6 +315,8 @@ def sendSerialData(data): ser.write(bytearray(data)) ser.write(bytearray([ MSG_EOD1, MSG_EOD2 ])) + ser.flush() + ############################################################################### if __name__ == "__main__": @@ -398,7 +402,7 @@ if __name__ == "__main__": elif e[1] == MSG_TYPE_ANSWER_NOK: print "recv: NOT OK" - elif e[1] == MSG_TYPE_MEAS_FREQ_INFO_: + elif e[1] == MSG_TYPE_MEAS_FREQ_INFO: print "recv: FREQ INFO" freq = e[3][0] << 24 freq += e[3][1] << 16