From ee10cdf4efd0ec675bc11d1121bc6e7166986c53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Ple=C3=9F?= Date: Tue, 3 Jun 2014 02:54:38 +0200 Subject: [PATCH] added basic test script --- .../displayboard_servo/software/src/main.c | 2 +- schaltungen/displayboard_servo/tester.py | 35 +++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100755 schaltungen/displayboard_servo/tester.py diff --git a/schaltungen/displayboard_servo/software/src/main.c b/schaltungen/displayboard_servo/software/src/main.c index 4daecea..9e02ce0 100644 --- a/schaltungen/displayboard_servo/software/src/main.c +++ b/schaltungen/displayboard_servo/software/src/main.c @@ -57,7 +57,7 @@ static void process_command(char *command) { // examples: // A24500,13400,12000,1,1,1B // A19900,11000,15000,1,1,1B - // A34100,15100,01000,1,1,1B + // A20000,12300,10000,1,1,1B char *token; uint8_t tokencounter = 0; diff --git a/schaltungen/displayboard_servo/tester.py b/schaltungen/displayboard_servo/tester.py new file mode 100755 index 0000000..926b6c0 --- /dev/null +++ b/schaltungen/displayboard_servo/tester.py @@ -0,0 +1,35 @@ +#!/usr/bin/python +import sys +import tty +import serial +import time + +ser = serial.Serial("/dev/ttyUSB0", 38400) + +voltage = 20000 +current = 0 +incdec = 0 + +while 1: + tdata = ser.read() + time.sleep(1) + data_left = ser.inWaiting() + tdata += ser.read(data_left) + + out = "A%05d,12300,%05d,1,1,1B" % (voltage, current) + print out + ser.write(out) + + if incdec == 0: + current = current + 1000 + else: + current = current - 1000 + + if current > 20000: + current = 20000 + incdec = 1 + + if current < 0: + current = 0 + incdec = 0 +