New info message added to the firmware. The python script was modified to print out more detaild messages of its activity.

This commit is contained in:
klaute 2016-09-20 18:51:20 +02:00
parent a6dc38f81a
commit a0f06d4fb7
3 changed files with 32 additions and 5 deletions

View file

@ -47,6 +47,9 @@ void setup()
si5351.output_enable(SI5351_CLK0, 1); // enable clock output 0 si5351.output_enable(SI5351_CLK0, 1); // enable clock output 0
si5351.drive_strength(SI5351_CLK0, SI5351_DRIVE_2MA); // 2 4 6 8ma si5351.drive_strength(SI5351_CLK0, SI5351_DRIVE_2MA); // 2 4 6 8ma
*/ */
delay(500);
Serial.println("SWR Meter firmware v0.1 by Kai Lauterbach (me@klaute.de)");
} }
void loop() void loop()

View file

@ -157,7 +157,7 @@ def cc_dataReceiverThread():
#print bytesToRead # TODO #print bytesToRead # TODO
incoming = list(ser.read(64)) incoming = list(ser.read(64))
#print incoming # TODO print incoming # TODO
# 2. process the received data # 2. process the received data
for c in incoming: for c in incoming:
@ -292,18 +292,37 @@ def openSerialDevice(d):
# Why 115200? Because the host defines the baudrate for the USB serial connection. # Why 115200? Because the host defines the baudrate for the USB serial connection.
try: try:
ser = serial.Serial(d, 115200, timeout=0) #ser = serial.Serial(d, 115200, timeout=0)
ser = serial.Serial(
port=d,\
baudrate=115200,\
parity=serial.PARITY_NONE,\
stopbits=serial.STOPBITS_ONE,\
bytesize=serial.EIGHTBITS,\
timeout=0)
except: except:
print "ERROR: Can't open the serial device " + device print "ERROR: Can't open the serial device " + device
exit(1) exit(1)
#time.sleep(2) time.sleep(2)
#ser.write(bytearray([0x00]))
#ser.write(bytearray([0x00]))
#ser.write(bytearray([0x00]))
#ser.write(bytearray([0x00]))
#ser.write(bytearray([0x00]))
ser.flush()
ser.read(1000)
##### #####
def closeSerialDevice(): def closeSerialDevice():
global ser global ser
ser.flush()
ser.read(1000)
ser.close() ser.close()
##### #####
@ -345,6 +364,7 @@ if __name__ == "__main__":
dataSend = dataSend + 1 dataSend = dataSend + 1
if args.start_freq != None: if args.start_freq != None:
print "Send: SET_START_FREQ"
sendSerialData([CC_CMD_SET_START_FREQ, sendSerialData([CC_CMD_SET_START_FREQ,
(args.start_freq & 0xff000000) >> 24, (args.start_freq & 0xff000000) >> 24,
(args.start_freq & 0x00ff0000) >> 16, (args.start_freq & 0x00ff0000) >> 16,
@ -353,6 +373,7 @@ if __name__ == "__main__":
dataSend = dataSend + 1 dataSend = dataSend + 1
if args.end_freq != None: if args.end_freq != None:
print "Send: SET_END_FREQ"
sendSerialData([CC_CMD_SET_END_FREQ, sendSerialData([CC_CMD_SET_END_FREQ,
(args.end_freq & 0xff000000) >> 24, (args.end_freq & 0xff000000) >> 24,
(args.end_freq & 0x00ff0000) >> 16, (args.end_freq & 0x00ff0000) >> 16,
@ -361,6 +382,7 @@ if __name__ == "__main__":
dataSend = dataSend + 1 dataSend = dataSend + 1
if args.step_freq != None: if args.step_freq != None:
print "Send: SET_FREQ_STEP"
sendSerialData([CC_CMD_SET_FREQ_STEP, sendSerialData([CC_CMD_SET_FREQ_STEP,
(args.step_freq & 0xff000000) >> 24, (args.step_freq & 0xff000000) >> 24,
(args.step_freq & 0x00ff0000) >> 16, (args.step_freq & 0x00ff0000) >> 16,
@ -369,17 +391,20 @@ if __name__ == "__main__":
dataSend = dataSend + 1 dataSend = dataSend + 1
if args.intervall != None: if args.intervall != None:
print "Send: SET_INTERVALL"
sendSerialData([CC_CMD_SET_INTERVALL, sendSerialData([CC_CMD_SET_INTERVALL,
(args.intervall & 0x0000ff00) >> 8, (args.intervall & 0x0000ff00) >> 8,
(args.intervall & 0x000000ff)]) (args.intervall & 0x000000ff)])
dataSend = dataSend + 1 dataSend = dataSend + 1
if args.drive_str != None: if args.drive_str != None:
print "Send: SET_DRIVE_STRENGTH"
sendSerialData([CC_CMD_SET_DRIVE_STRENGTH, sendSerialData([CC_CMD_SET_DRIVE_STRENGTH,
args.drive_str]) args.drive_str])
dataSend = dataSend + 1 dataSend = dataSend + 1
if args.start_meas == True: if args.start_meas == True:
print "Send: START_MEASUREMENT"
sendSerialData([CC_CMD_START_MEASUREMENT]) sendSerialData([CC_CMD_START_MEASUREMENT])
dataSend = dataSend + 1 dataSend = dataSend + 1
@ -387,7 +412,6 @@ if __name__ == "__main__":
while dataSend > 0 and timeout < TIMEOUT_CNT_MAX: while dataSend > 0 and timeout < TIMEOUT_CNT_MAX:
thread_lock.acquire() thread_lock.acquire()
#ser.write("9") # TODO
tmp_messages = copy.deepcopy(cc_received_messages) tmp_messages = copy.deepcopy(cc_received_messages)
thread_lock.release() thread_lock.release()

View file

@ -1,6 +1,6 @@
import serial, sys import serial, sys
port = "/dev/ttyUSB0" port = "/dev/ttyUSB0"
baudrate = 57600 baudrate = 115200
ser = serial.Serial(port,baudrate,timeout=0.001) ser = serial.Serial(port,baudrate,timeout=0.001)
while True: while True:
ser.write(bytearray([0x3c, 0x3e, 0x10, 0x0d, 0x0a])) ser.write(bytearray([0x3c, 0x3e, 0x10, 0x0d, 0x0a]))