From 4c3cc88868bc15e135c8ab0d890eee133e958e4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=B6gl?= Date: Sun, 16 Mar 2014 11:21:34 +0100 Subject: [PATCH] pulse test changes --- sensors2osc/sensors2osc/socat_pulse_test.py | 32 ++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/sensors2osc/sensors2osc/socat_pulse_test.py b/sensors2osc/sensors2osc/socat_pulse_test.py index 85e1bea..1f99269 100644 --- a/sensors2osc/sensors2osc/socat_pulse_test.py +++ b/sensors2osc/sensors2osc/socat_pulse_test.py @@ -17,11 +17,25 @@ # # Copyright (C) 2014 Stefan Kögl +# used this line before opening that script +# socat -d -d PTY,raw,echo=0,link=/tmp/pty1,b115200,user=stefan PTY,raw,echo=0,link=/tmp/pty2,b115200,user=stefan + + from __future__ import absolute_import import time, random -from sensors2osc.main import RingBuffer +import serial + +serial_sock = serial.Serial() + +serial_sock = serial.Serial() +serial_sock.port = "/tmp/pty2" +serial_sock.baudrate = 115200 +serial_sock.timeout = 0 +serial_sock.open() +import time, random, struct + class DataGenenerator(object): @@ -46,22 +60,8 @@ class DataGenenerator(object): self.get_i = (self.get_i + 1) % 6 return value -def parse(ring_buffer, reader): - t = r.read() - print t - ring_buffer.append(t) - - if t == 0: - try: - my_data = ring_buffer.getData() - print my_data - except ValueError, e: - print e - - -ring_buffer = RingBuffer(6) r = DataGenenerator() while 1: - parse(ring_buffer, r) + serial_sock.write(struct.pack("B", r.read())) time.sleep(0.5)