Revision 210
Updated jumptable and Makefile for tooltron to work with bootloader
updated tooltron.py to handle NACKs
Fixed tooltron.py to send 'o' instead of 'O'
trunk/toolbox/jumptable.h | ||
---|---|---|
3 | 3 |
|
4 | 4 |
// Jump table addresses |
5 | 5 |
// If the bootloader changes, you must change the jump table addresses! |
6 |
#define JT_ADDR 0x7E0
|
|
6 |
#define JT_ADDR 0x7C0
|
|
7 | 7 |
#define JT_RS485_INIT ((void*)((JT_ADDR+0) / 2)) |
8 | 8 |
#define JT_RS485_GET_BYTE ((void*)((JT_ADDR+2)/2)) |
9 | 9 |
#define JT_RS485_SEND_BYTE ((void*)((JT_ADDR+4)/2)) |
trunk/toolbox/Makefile | ||
---|---|---|
52 | 52 |
|
53 | 53 |
|
54 | 54 |
# Output format. (can be srec, ihex, binary) |
55 |
FORMAT = ihex
|
|
55 |
FORMAT = binary
|
|
56 | 56 |
|
57 | 57 |
|
58 | 58 |
# Target file name (without extension). |
trunk/swipe/tooltron.py | ||
---|---|---|
81 | 81 |
TT_NACK = 'n' |
82 | 82 |
TT_TO = 'f' |
83 | 83 |
TT_TIMEOUT = 't' |
84 |
TT_ON = 'o' |
|
84 | 85 |
|
85 | 86 |
BAUD_RATE = 9600 |
86 | 87 |
|
... | ... | |
220 | 221 |
# ^ <src> <dest> <data> |
221 | 222 |
def sendTool(t): |
222 | 223 |
tn = keypad2toolID(t) |
223 |
msg = '^' + chr(1) + chr(tn) + 'O' + chr(1 ^ tn ^ ord('O'))
|
|
224 |
msg = '^' + chr(1) + chr(tn) + TT_ON + chr(1 ^ tn ^ ord(TT_ON))
|
|
224 | 225 |
print "seding power to tool ID",tn |
225 | 226 |
bus.write(msg) |
226 | 227 |
return |
trunk/programmer/test/main.c | ||
---|---|---|
112 | 112 |
|
113 | 113 |
PORTB = 0x7; |
114 | 114 |
|
115 |
//myaddr = eeprom_read_byte(1);
|
|
116 |
//if (myaddr == 18) {
|
|
117 |
// PORTB = 0x7;
|
|
118 |
//}
|
|
119 |
//_delay_ms(1000);
|
|
120 |
//PORTB |= _BV(PORTB0);
|
|
121 |
//_delay_ms(1000);
|
|
122 |
//reset();
|
|
115 |
/* myaddr = eeprom_read_byte(1); */
|
|
116 |
/* if (myaddr == 18) { */
|
|
117 |
/* PORTB = 0x7; */
|
|
118 |
/* } */
|
|
119 |
/* _delay_ms(1000); */
|
|
120 |
/* PORTB |= _BV(PORTB0); */
|
|
121 |
/* _delay_ms(1000); */
|
|
122 |
/* reset(); */
|
|
123 | 123 |
|
124 | 124 |
while(1) { |
125 | 125 |
_delay_ms(1000); |
trunk/programmer/netprog.py | ||
---|---|---|
90 | 90 |
printMsg(msg) |
91 | 91 |
bus.write(msg) |
92 | 92 |
|
93 |
dCount = 0 |
|
94 |
|
|
93 | 95 |
def sendData(t, data): |
94 | 96 |
body = chr(1) + chr(t) + TT_PROGD + data |
95 | 97 |
n = len(data) |
... | ... | |
99 | 101 |
xor = 0 |
100 | 102 |
for c in body: |
101 | 103 |
xor = xor ^ ord(c) |
102 |
|
|
103 | 104 |
msg = '^' + body + chr(xor) |
104 | 105 |
printMsg(msg) |
105 | 106 |
bus.write(msg) |
... | ... | |
119 | 120 |
|
120 | 121 |
return TT_BAD |
121 | 122 |
if msg[0] != '^': |
122 |
print "did not get start delimeter! ",ord(msg[0]) |
|
123 |
print "did not get start delimeter! ",ord(msg[0])," packet size:",len(msg)
|
|
123 | 124 |
return TT_BAD |
124 | 125 |
src = msg[1] |
125 | 126 |
#print "src: ", ord(src) |
... | ... | |
166 | 167 |
r = readPacket() |
167 | 168 |
if r == TT_NACK: |
168 | 169 |
print "WARNING: got NACK, trying again" |
169 |
if r == TT_BOOT: |
|
170 |
elif r == TT_BOOT:
|
|
170 | 171 |
print "ERROR: got stray boot packet" |
171 | 172 |
#TODO: restart the whole state machine after the boot packet |
172 | 173 |
exit(-2) |
173 |
if r != TT_ACK: |
|
174 |
elif r != TT_ACK:
|
|
174 | 175 |
print "ERROR: got another packet:",r |
175 | 176 |
exit(-1) |
176 | 177 |
|
... | ... | |
189 | 190 |
r = readPacket() |
190 | 191 |
if r == TT_NACK: |
191 | 192 |
print "WARNING: got NACK, trying again" |
192 |
if r == TT_BOOT: |
|
193 |
elif r == TT_BOOT:
|
|
193 | 194 |
print "ERROR: got stray boot packet" |
194 | 195 |
#TODO: restart the whole state machine after the boot packet |
195 | 196 |
exit(-2) |
196 |
if r != TT_ACK: |
|
197 |
elif r != TT_ACK:
|
|
197 | 198 |
print "ERROR: got another packet:",r |
198 | 199 |
exit(-1) |
199 | 200 |
|
Also available in: Unified diff