diff --git a/bin/goodwatch.py b/bin/goodwatch.py index d1e2122..1f0bc9b 100755 --- a/bin/goodwatch.py +++ b/bin/goodwatch.py @@ -115,7 +115,10 @@ class GoodWatch: """Writes an 8-letter string to the LCD.""" self.transact("\x03"+string+"\x00"); return; - + def dmesg(self): + """Returns the DMESG buffer.""" + return self.transact("\x04"); + if __name__=='__main__': parser = argparse.ArgumentParser(description='GoodWatch Client') parser.add_argument('-p','--port', @@ -149,6 +152,9 @@ if __name__=='__main__': if args.lcd!=None: goodwatch.lcdstring(args.lcd); + + if args.dmesg>0: + print goodwatch.dmesg(); #Exit turbomode when we're done. #goodwatch.turbomode(0); diff --git a/firmware/api.h b/firmware/api.h index fd2bccb..026c565 100644 --- a/firmware/api.h +++ b/firmware/api.h @@ -25,6 +25,7 @@ #include "packet.h" #include "codeplug.h" #include "power.h" +#include "dmesg.h" #include "gittag.h" //Autogenerated //Handy libraries. These are tested host-side. diff --git a/firmware/dmesg.c b/firmware/dmesg.c index 88abe43..b5e7702 100644 --- a/firmware/dmesg.c +++ b/firmware/dmesg.c @@ -5,7 +5,7 @@ #include #include -#define DMESGLEN 2048 +#include "dmesg.h" /* These three buffers are declared to be in the .noinit section so that a reboot will not wipe the buffer. Because the memory will be @@ -16,7 +16,7 @@ //! Ought to be 0xdeadbeef except after power loss. uint32_t dmesg_magic __attribute__ ((section (".noinit"))); //! Index within that buffer. -int dmesg_index __attribute__ ((section (".noinit"))); +uint16_t dmesg_index __attribute__ ((section (".noinit"))); //! DMESG buffer itself. char *dmesg_buffer=(char*)0x2400; @@ -25,7 +25,7 @@ char *dmesg_buffer=(char*)0x2400; int putchar(int c){ dmesg_index++; while(dmesg_index>DMESGLEN) - dmesg_index-=DMESGLEN; + dmesg_index=dmesg_index-DMESGLEN; return dmesg_buffer[dmesg_index]=(char) c; } diff --git a/firmware/dmesg.h b/firmware/dmesg.h index 392eef9..d6fed4f 100644 --- a/firmware/dmesg.h +++ b/firmware/dmesg.h @@ -2,6 +2,14 @@ \brief Kernel debug message buffer. */ +#define DMESGLEN 2048 + +//! Ought to be 0xdeadbeef except after power loss. +extern uint32_t dmesg_magic; +//! Index within that buffer. +extern uint16_t dmesg_index; + + //! Clears the dmesg buffer. void dmesg_clear(); diff --git a/firmware/monitor.c b/firmware/monitor.c index 75368db..6dcdd6d 100644 --- a/firmware/monitor.c +++ b/firmware/monitor.c @@ -21,6 +21,27 @@ enum { } monitor_verb; +//! Local command to send the dmesg buffer. +static void send_dmesg(){ + uint16_t i; + char *dmesg_buffer=(char*)0x2400; + + //Start the frame. + uart_tx(0x00); + uart_tx(0x80); + //Length + uart_tx(DMESGLEN&0xFF); + uart_tx(DMESGLEN>>8); + + //dmesg + for(i=0;i>8)); state=IDLE; - printf("Sent %d byte packet.\n",outlength); break; } }while(state!=IDLE); - printf("Done, state=%d.\n",state); } //! Handle a UART byte. @@ -160,7 +160,6 @@ static void handle_rxbyte(uint8_t byte){ crc|= ((uint16_t)byte)<<8; state=IDLE; - printf("Got %d byte packet.\n",length); outlength=monitor_handle(uart_buffer, length); outindex=0; outcrc=crc;