From ca1862796bd846ea0069b8588fba395804222acf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=B6gl?= Date: Sun, 18 Nov 2012 15:40:32 +0100 Subject: [PATCH] done with cleaning up --- .gitignore | 2 +- firmware/log.cpp | 12 +++++++ firmware/log.h | 14 ++++++++ reflowctl/serialmon.py | 81 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 firmware/log.cpp create mode 100644 firmware/log.h create mode 100755 reflowctl/serialmon.py diff --git a/.gitignore b/.gitignore index 9b0c4bb..c0800f9 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,4 @@ build CMakeCache.txt CMakeFiles - +*egg-info/ diff --git a/firmware/log.cpp b/firmware/log.cpp new file mode 100644 index 0000000..8e65c61 --- /dev/null +++ b/firmware/log.cpp @@ -0,0 +1,12 @@ + +#include "ProfileLog.h" + +ProfileLog::ProfileLog() { + // timestamps of event beginnings/ends + Ts_time_start = 0; + Ts_time_end = 0; + Tl_time_start = 0; + Tl_time_end = 0; + Tp_time_start = 0; + Tp_time_end = 0; +} diff --git a/firmware/log.h b/firmware/log.h new file mode 100644 index 0000000..a095f94 --- /dev/null +++ b/firmware/log.h @@ -0,0 +1,14 @@ +#ifndef _LOG_H +#define _LOG_H + +class ProfileLog { + // timestamps of event beginnings/ends + int Ts_time_start; + int Ts_time_end; + int Tl_time_start; + int Tl_time_end; + int Tp_time_start; + int Tp_time_end; +}; + +#endif diff --git a/reflowctl/serialmon.py b/reflowctl/serialmon.py new file mode 100755 index 0000000..dd956fc --- /dev/null +++ b/reflowctl/serialmon.py @@ -0,0 +1,81 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +import serial, struct, time + +ser = serial.Serial('/dev/ttyUSB0', 9600, timeout=2) + + +buf = "" +alles = [] + +#def parse(): + #buffer = list() + #while 1: + #try: + #i = ser.read(1) + #if ord(i) == 255: + #except Exception, e: + #print e + #else: + +def recv_config(): + ser.write(chr(255)) + ser.flush() + read(30) + ser.flushInput() + data = struct.unpack("hhhhhhhhhhhhhhh", buf) + print + print "Profile:" + print "ts_min:", data[0] + print "ts_max:", data[1] + print "tl:", data[2] + print "tp:", data[3] + print "time_max:", data[4] + print "ramp_up_min:", data[5] + print "ramp_up_max:", data[6] + print "ramp_down_min:", data[7] + print "ramp_down_max:", data[8] + + print "ts_duration_min:", data[9] + print "ts_duration_max:", data[10] + print "tl_duration_min:", data[11] + print "tl_duration_max:", data[12] + print "tp_duration_min:", data[13] + print "tp_duration_max:", data[14] + print + + +def recv_state(): + ser.write(chr(254)) + ser.flush() + read(11) + data = struct.unpack("hhhhhb", buf) + print "time: %ds, temperature: %d°C, last temperature: %d°C, state: %d, error condition: %d, heating: %d" % data + + +def send_config(): + ser.write(chr(253)) + ser.write(buf) + ser.flushInput() + + +def read(l): + global buf + global alles + buf = "" + while len(buf) < l: + try: + buf += ser.read(l) + alles.append(buf) + except Exception, e: + print e + ser.flushInput() + + +time.sleep(2) +recv_config() +while 1: + recv_state() + time.sleep(1) +