From 5038269c240675f8f7dc17288b08925023630b04 Mon Sep 17 00:00:00 2001 From: klaute Date: Wed, 21 Sep 2016 10:00:23 +0200 Subject: [PATCH] Little code improvements done. --- tools/meas.py | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/tools/meas.py b/tools/meas.py index ad5d3be..f1e95e9 100644 --- a/tools/meas.py +++ b/tools/meas.py @@ -369,12 +369,12 @@ if __name__ == "__main__": # 3. get and process the commandline arguments/parameter #if args.get_config == True and args.start_meas == False: - # print "Send: GET_CONFIG" + # print "sent: GET_CONFIG" # sendSerialData([CC_CMD_GET_CONFIG]) # dataSend = dataSend + 1 if args.start_freq != None: - print "Send: SET_START_FREQ" + print "sent: SET_START_FREQ" sendSerialData([CC_CMD_SET_START_FREQ, (args.start_freq & 0xff000000) >> 24, (args.start_freq & 0x00ff0000) >> 16, @@ -383,7 +383,7 @@ if __name__ == "__main__": dataSend = dataSend + 1 if args.end_freq != None: - print "Send: SET_END_FREQ" + print "sent: SET_END_FREQ" sendSerialData([CC_CMD_SET_END_FREQ, (args.end_freq & 0xff000000) >> 24, (args.end_freq & 0x00ff0000) >> 16, @@ -392,7 +392,7 @@ if __name__ == "__main__": dataSend = dataSend + 1 if args.step_freq != None: - print "Send: SET_FREQ_STEP" + print "sent: SET_FREQ_STEP" sendSerialData([CC_CMD_SET_FREQ_STEP, (args.step_freq & 0xff000000) >> 24, (args.step_freq & 0x00ff0000) >> 16, @@ -401,20 +401,20 @@ if __name__ == "__main__": dataSend = dataSend + 1 if args.intervall != None: - print "Send: SET_INTERVALL" + print "sent: SET_INTERVALL" sendSerialData([CC_CMD_SET_INTERVALL, (args.intervall & 0x0000ff00) >> 8, (args.intervall & 0x000000ff)]) dataSend = dataSend + 1 if args.drive_str != None: - print "Send: SET_DRIVE_STRENGTH" + print "sent: SET_DRIVE_STRENGTH" sendSerialData([CC_CMD_SET_DRIVE_STRENGTH, args.drive_str]) dataSend = dataSend + 1 if args.start_meas == True: - print "Send: START_MEASUREMENT" + print "sent: START_MEASUREMENT" sendSerialData([CC_CMD_START_MEASUREMENT]) dataSend = dataSend + 1 @@ -483,14 +483,12 @@ if __name__ == "__main__": elif e[1] == MSG_TYPE_MEAS_END_INFO: print "recv: END INFO" - if args.output_file != None: - pass # TODO impl - if args.show_graph == True: - meas_freq = [] - meas_ratio = [] - meas_r = [] - meas_p = [] + meas_freq = [] + meas_ratio = [] + meas_r = [] + meas_p = [] + if args.output_file != None or args.output_file != None: for m in meas_data: meas_freq.append(m[0]) @@ -498,7 +496,7 @@ if __name__ == "__main__": if m[1] > m[2]: meas_ratio.append(m[1] / m[2]) elif m[1] < m[2]: - meas_ratio.append(m[1] / m[2]) + meas_ratio.append(m[2] / m[1]) else: meas_ratio.append(1) @@ -512,9 +510,15 @@ if __name__ == "__main__": else: meas_p.append(0) + if args.output_file != None: + pass # TODO impl + + if args.show_graph == True: plt.plot(meas_freq, meas_ratio) plt.plot(meas_freq, meas_r) plt.plot(meas_freq, meas_p) + + print "Please close the mathplot window to exit..." plt.show() else: