From: ian Date: Wed, 21 Dec 2005 13:18:46 +0000 (+0000) Subject: check for receiving too much nmra data X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=b11ea0f4e84ebec8b3a380ed2ce1a8964f2919ca;p=trains.git check for receiving too much nmra data --- diff --git a/detpic/morse.messages b/detpic/morse.messages index 8ce7148..234af1d 100644 --- a/detpic/morse.messages +++ b/detpic/morse.messages @@ -20,10 +20,13 @@ # Miscellaneous E ; `expected'; we were told to panic + +# Regarding communications from the host HX ::t ; host sent unknown command HW ::t ; host sent message which was too long HO ; host RS232 read overrun HF ; host RS232 framing error +HN ; host sent too much NMRA - buffers full # Problematic interrupts IH INTCON,INTCON3,PIR1,PIR2,PIR3 ; Interrupt source not found (high pri.) diff --git a/detpic/nmra-stream.asm b/detpic/nmra-stream.asm index f88fbf4..dedc299 100644 --- a/detpic/nmra-stream.asm +++ b/detpic/nmra-stream.asm @@ -221,9 +221,8 @@ fixme need to check both interrupt handlers here and look for refies too serial_receive_done intrl_handled_nostack -receive_message_too_long - panic morse_HW - fixme reviewed up to here for inclusion in bigger program +receive_too_much_nmra panic morse_HW +receive_message_too_long panic morse_HW ; *** I *think* the interrupt bit is cleared by reading out of RCREG ; but this may be something to try in debugging if stuff doesn't work @@ -244,10 +243,24 @@ advance_write_buffer debug '5' mov_fw fromserial ; W = 00BB0000 add_lw 0x10 ; W = 0?CC0000 - bc_w 6 ; W = 00CC0000 - mov_wf fromserial ; where BB is this buffer + mov_wf t ; t = 0?CC0000 + ; where BB is this buffer ; and CC is next buffer - fixme check for overruns ie if we caught up with totrack + + ; we have to check our proposed new value for fromserial + ; against totrack before we store it in fromserial; + ; otherwise there's the possibility that we will store + ; the new value, and then the high-priority ISR will + ; interrupt us and advance totrack onto the buffer we've + ; just filled, fooling us into thinking we've overrun. + xor_wfw totrack ; W = 0?DD???? + and_lw 0x30 ; ..DD.... + bra_z receive_too_much_nmra ; where DD is (fromserial buffer) + ; xor (totrack buffer) + + mov_wf t ; W = 0?CC0000 + bc_w 6 ; W = 00CC0000 + mov_fw fromserial bra serial_receive_done @@ -258,6 +271,7 @@ not_nmra_message bra serial_receive_done ;**************************************************************************** + fixme reviewed up to here for inclusion in bigger program nmra_interrupt_timer bt_f_if0 INTCON,2,0 ; check whether timer0 interrupt set