# HG changeset patch # User Malte Bayer # Date 1372197149 -7200 # Node ID 7127e7082ee0dbe50497aafe6354916fb1c82455 # Parent a570dd24a4134844c57439131b3224040fa45917 switched firmware to binary protocol, TODO: client implementation diff -r a570dd24a413 -r 7127e7082ee0 blackbox/Makefile --- a/blackbox/Makefile Tue Jun 25 22:18:17 2013 +0200 +++ b/blackbox/Makefile Tue Jun 25 23:52:29 2013 +0200 @@ -9,8 +9,10 @@ #F_CPU = 14318000 F_CPU = 8000000 +#F_CPU = 16000000 -BAUD=57600 +#BAUD=57600 +BAUD=33600 ISP_BAUD=115200 ifdef USB PORT=/dev/ttyUSB$(USB) diff -r a570dd24a413 -r 7127e7082ee0 blackbox/main.c --- a/blackbox/main.c Tue Jun 25 22:18:17 2013 +0200 +++ b/blackbox/main.c Tue Jun 25 23:52:29 2013 +0200 @@ -15,12 +15,13 @@ const char ok[] PROGMEM="OK\n"; const char busy[] PROGMEM="BUSY\n"; -const char prepare[] PROGMEM="!RACE PREPARE\n"; -const char countdownstart[] PROGMEM="!COUNTDOWN\n"; -const char racestart[] PROGMEM="!RACE START\n"; -const char SHORTCUT[] PROGMEM="!SHORTCUT\n"; -const char PANIC[] PROGMEM="!PANIC\n"; +const char prepare[] PROGMEM="!PRE\n"; +const char countdownstart[] PROGMEM="!SET\n"; +const char racestart[] PROGMEM="!GO\n"; + +const char SHORTCUT[] PROGMEM="!OC\n"; +const char PANIC[] PROGMEM="!STOP\n"; const char RESUME[] PROGMEM="!RESUME\n"; typedef union { @@ -29,6 +30,11 @@ uint8_t byte[4]; // all four bytes } u32; +typedef union { + uint16_t value; + uint8_t byte[2]; // all two bytes +} u16; + #define FUEL_FULL 10000 #define FUEL_JUMPSTART 5000 #define FUEL_DIV_DEFAULT 25 @@ -48,7 +54,7 @@ unsigned unlimitedfuel:1; // 1bit bool unsigned trackchange:1; // 1bit bool uint16_t jumpstart_time, fuel; - uint8_t laps; + uint16_t laps; u32 lap_time_start, lap_time; } cardata; @@ -165,6 +171,8 @@ if (status == 6) for (data=0; data 0) { - itoa(response, s, 2); + //TODO: Track response data??? + //itoa(response, s, 2); response_len = 0; //RS232_puts("ANSWER RX: "); //RS232_puts(s); diff -r a570dd24a413 -r 7127e7082ee0 blackbox/main.h --- a/blackbox/main.h Tue Jun 25 22:18:17 2013 +0200 +++ b/blackbox/main.h Tue Jun 25 23:52:29 2013 +0200 @@ -4,7 +4,7 @@ #include #include -#define VERSION "1.8" +#define VERSION "1.8.2" #define COUNTDOWN_DELAY 10 // x/10 seconds @@ -93,7 +93,7 @@ #define PIN(x) (*(&x - 2)) // address of input register of port x -// constants +// constants, do not change this #define MAX_SLOTS 6 // external variabled diff -r a570dd24a413 -r 7127e7082ee0 slotUI/freeslot.py --- a/slotUI/freeslot.py Tue Jun 25 22:18:17 2013 +0200 +++ b/slotUI/freeslot.py Tue Jun 25 23:52:29 2013 +0200 @@ -67,6 +67,8 @@ self.info = None def readline(self): + # TODO: Binärprotokoll implementieren und als "alte" ASCII Antwort zurückgeben! + # if self.com: return self.com.readline() return "" @@ -76,7 +78,8 @@ return self.com.query(msg) return "" - def connect(self, device="/dev/ttyUSB0", speed=57600): + def connect(self, device="/dev/ttyUSB0", speed=33600): + # old connection speed 57600 if self.com == None: self.com = SerialCommunicator(device, speed) if self.com.connected: diff -r a570dd24a413 -r 7127e7082ee0 slotUI/slotCli.py --- a/slotUI/slotCli.py Tue Jun 25 22:18:17 2013 +0200 +++ b/slotUI/slotCli.py Tue Jun 25 23:52:29 2013 +0200 @@ -20,7 +20,7 @@ import threading -VERSION = "1.8.1" +VERSION = "1.8.2" MAXSLOTS = 6 TERM = { "caption": "\033[1;37m\033[1;44m", @@ -607,7 +607,7 @@ self.render_slots() - if rx == "!RACE PREPARE": + if rx == "!PRE": # reset current race status # and display PREPARE PHASE self.reset_slots() @@ -615,29 +615,30 @@ self.slot[slot]["status"] = "Prepare" trigger_event("race_prepare") - if rx == "!RACE START": + if rx == "!GO": + # race start! for slot in range(MAXSLOTS): if self.slot[slot]["status"] == "~~~~~~~~~~": self.slot[slot]["status"] = "Idle" trigger_event("race_start") self.raceactive = True - if rx == "!COUNTDOWN": + if rx == "!SET": # countdown initiated for slot in range(MAXSLOTS): self.slot[slot]["status"] = "~~~~~~~~~~" trigger_event("countdown_start") - if rx == "!PANIC": - # panic mode + if rx == "!STOP": + # panic mode, race stopped trigger_event("panic") - if rx == "!SHORTCUT": - # panic mode + if rx == "!OC": + # panic mode, overcurrent trigger_event("panic_shortcut") if rx == "!RESUME": - # panic mode + # panic mode reset - race goes on normally trigger_event("resume")