added basic test script

This commit is contained in:
Lucas Pleß 2014-06-03 02:54:38 +02:00
parent 62d1a3bf63
commit ee10cdf4ef
2 changed files with 36 additions and 1 deletions

View File

@ -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;

View File

@ -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