From: ian Date: Wed, 4 Jan 2006 20:55:38 +0000 (+0000) Subject: change power to 0x10 and 0x11; new crash reset command X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=c188630d920d0cb9cce13b876d674a0d9f93dc8a;p=trains.git change power to 0x10 and 0x11; new crash reset command --- diff --git a/cebpic/README.protocol b/cebpic/README.protocol index 3ceace6..42caca3 100644 --- a/cebpic/README.protocol +++ b/cebpic/README.protocol @@ -20,20 +20,22 @@ From host to PIC: > 1 0001 XXX 0 XXXXXXX (88+) PING Ping `X' (please Pong `X') > 1 0010 RRR E RRR... (90+) POLARITY Set polarity > 1 0011 000 0 MMMMMMM (98+) WATCHDOG W'dog reset, t/o ms from now - > 0 0100 001 (21) ON Power on - > 0 0100 000 (20) OFF Power off + > 0 0010 001 (11) ON Power on + > 0 0010 000 (10) OFF Power off > 00000000 CRASHED Acknowledge panic, go to readout mode - > 00000001 ACKSERERR RS232 framing or overrun (panic'd) ; In crash readout mode: ; ; 00000000 MS Select crash readout mode if not already ; Reset crash readout pointer to 0 ; +; 00001000 Acknowledge RS232 framing error or overrun +; 00001001 Reboot +; ; 1vvvvvvv M Prepare byte 0vvvvvvv for transmission to the slave ; -; 0000nnnn M (n>0) prepare to receive nnnn bytes from slave +; 00000nnn M (n>0) prepare to receive nnnn bytes from slave ; 0001nnnn M (n>0) transmit nnnn bytes of our own from the ; readout pointer ; diff --git a/detpic/crashread b/detpic/crashread index 95fa725..61a276e 100755 --- a/detpic/crashread +++ b/detpic/crashread @@ -1,6 +1,5 @@ #!/usr/bin/tclsh8.4 -if {[llength $argv] != 3} { error "need args: serial port, map file, picno" } set port [lindex $argv 0] set map [lindex $argv 1] set slave [lindex $argv 2] @@ -150,12 +149,6 @@ fconfigure $p -blocking yes -buffering none \ fconfigure stdout -buffering none -set ms [expr { - $slave < 0 ? "t" : - $slave ? "s" : - "m" -}] - proc xmit {b} { global p #debug >xmit|$b< @@ -182,9 +175,13 @@ proc junkrecv {} { fconfigure $p -blocking yes } +proc selectslave_slave {slave} { + xmit "$slave ^ 0x30" +} + proc selectslave_s {} { global slave - xmit "$slave ^ 0x30" + selectslave_slave $slave } proc xmit_s {b} { @@ -233,8 +230,6 @@ proc readbytes_t {n} { return $l } -set readcursor -1 - proc readbytes {addr n} { global readcursor ms if {$readcursor != $addr} { @@ -273,6 +268,40 @@ proc thingnext {thing} { thingbynum $thing $num } + +proc p {s} { puts -nonewline $s } + +proc ms_reset {arg} { + if {[regexp {^(\d+)\.(\d+)} $arg min max]} { + } elseif {[regexp {^(\d+)} $arg max]} { + set min 1 + } else { + error "--reset arg $arg wrong" + } + setup_m + xmit 0x89 + for {set slave $min} {$slave < $max} {incr slave} { + selectslave_slave $slave + recv 1 + } + xmit 0x09 +} + +switch -exact [llength $argv].[lindex $argv 0] { + 1.--reset { ms_reset 0 } + 2.--reset { ms_reset [lindex $argv 1] } + 3. { } + default { error "need args: serial port, map file, picno" } +} + +set readcursor -1 + +set ms [expr { + $slave < 0 ? "t" : + $slave ? "s" : + "m" +}] + thingbynum section 0 thingbynum symbol 0 set shownsection {} @@ -284,8 +313,6 @@ set displine 0 set inline 0 set shownsection {} -proc p {s} { puts -nonewline $s } - setup_$ms proc queue_show {kind value} { diff --git a/detpic/panic.asm b/detpic/panic.asm index befce3a..65e84fa 100644 --- a/detpic/panic.asm +++ b/detpic/panic.asm @@ -377,7 +377,10 @@ waiting_master ;---------- panicst_oerrferr - dec_fw RCREG + mov_fw RCREG + xor_lw 0x11 + bra_z panic_reset + xor_lw 0x10 ^ 0x11 bra_nz panicd_serialrx_err_loop ; yay! host ack'd ferr/oerr bc_f panicst, panicst_ferroerr @@ -390,7 +393,7 @@ panicd_serialrx_err mov_fw RCREG ; read RCREG } (see PIC18FXX8 DS p182) bs_f RCSTA, RCEN ; reenable } panicd_serialrx_err_loop - bt_f_if0 PIR1, RCIF ; wait for a byte 0x01 to ack the overrun/error + bt_f_if0 PIR1, RCIF ; wait for a byte 0x10 to ack the overrun/error bra panicd_serialrx_err_loop ;... ;---------- @@ -438,8 +441,13 @@ write_ifnot_00 bra write_if_master_slaveselect bt_w_if1 4 bra write_if_master_masterread + bt_w_if1 3 bra write_if_master_slaveread - return ; huh ? + + xor_lw 0x11 + bra_z panic_reset + ; nope, well, we ignore it + return ;---------- panic_crashread_setpointer @@ -455,8 +463,13 @@ panic_crashread_setpointer and_lw 0x3f ior_wfw PRODL mov_wf FSR1L +panic_noop return +;====================================================================== +panic_reset + reset + ;====================================================================== ; MASTER READOUT AND MASTER READOUT OF SLAVES diff --git a/detpic/program.asm b/detpic/program.asm index dfa21b9..4f8c3aa 100644 --- a/detpic/program.asm +++ b/detpic/program.asm @@ -102,7 +102,7 @@ serialrx_generalmsg @ bra_n serialrx_if_multibyte bra_z command_crashed - xor_lw 0x21 + xor_lw 0x11 bra_z command_power_on xor_lw 0x01 bra_z command_power_off diff --git a/hostside/stopgap-controller b/hostside/stopgap-controller index 99f3516..45d7003 100755 --- a/hostside/stopgap-controller +++ b/hostside/stopgap-controller @@ -296,7 +296,7 @@ proc watchdog {} { proc pm_hello {} { debug "got hello, starting up" - tellpic 21 + tellpic 11 gui "P 1" watchdog changewhat