mirror of
https://github.com/travisgoodspeed/goodwatch
synced 2024-11-24 11:26:24 +00:00
DMESG in the debug monitor. #55
This commit is contained in:
parent
37088f8731
commit
2541d96641
@ -115,7 +115,10 @@ class GoodWatch:
|
|||||||
"""Writes an 8-letter string to the LCD."""
|
"""Writes an 8-letter string to the LCD."""
|
||||||
self.transact("\x03"+string+"\x00");
|
self.transact("\x03"+string+"\x00");
|
||||||
return;
|
return;
|
||||||
|
def dmesg(self):
|
||||||
|
"""Returns the DMESG buffer."""
|
||||||
|
return self.transact("\x04");
|
||||||
|
|
||||||
if __name__=='__main__':
|
if __name__=='__main__':
|
||||||
parser = argparse.ArgumentParser(description='GoodWatch Client')
|
parser = argparse.ArgumentParser(description='GoodWatch Client')
|
||||||
parser.add_argument('-p','--port',
|
parser.add_argument('-p','--port',
|
||||||
@ -149,6 +152,9 @@ if __name__=='__main__':
|
|||||||
|
|
||||||
if args.lcd!=None:
|
if args.lcd!=None:
|
||||||
goodwatch.lcdstring(args.lcd);
|
goodwatch.lcdstring(args.lcd);
|
||||||
|
|
||||||
|
if args.dmesg>0:
|
||||||
|
print goodwatch.dmesg();
|
||||||
|
|
||||||
#Exit turbomode when we're done.
|
#Exit turbomode when we're done.
|
||||||
#goodwatch.turbomode(0);
|
#goodwatch.turbomode(0);
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "packet.h"
|
#include "packet.h"
|
||||||
#include "codeplug.h"
|
#include "codeplug.h"
|
||||||
#include "power.h"
|
#include "power.h"
|
||||||
|
#include "dmesg.h"
|
||||||
#include "gittag.h" //Autogenerated
|
#include "gittag.h" //Autogenerated
|
||||||
|
|
||||||
//Handy libraries. These are tested host-side.
|
//Handy libraries. These are tested host-side.
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include<stdio.h>
|
#include<stdio.h>
|
||||||
#include<string.h>
|
#include<string.h>
|
||||||
|
|
||||||
#define DMESGLEN 2048
|
#include "dmesg.h"
|
||||||
|
|
||||||
/* These three buffers are declared to be in the .noinit section so
|
/* 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
|
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.
|
//! Ought to be 0xdeadbeef except after power loss.
|
||||||
uint32_t dmesg_magic __attribute__ ((section (".noinit")));
|
uint32_t dmesg_magic __attribute__ ((section (".noinit")));
|
||||||
//! Index within that buffer.
|
//! Index within that buffer.
|
||||||
int dmesg_index __attribute__ ((section (".noinit")));
|
uint16_t dmesg_index __attribute__ ((section (".noinit")));
|
||||||
|
|
||||||
//! DMESG buffer itself.
|
//! DMESG buffer itself.
|
||||||
char *dmesg_buffer=(char*)0x2400;
|
char *dmesg_buffer=(char*)0x2400;
|
||||||
@ -25,7 +25,7 @@ char *dmesg_buffer=(char*)0x2400;
|
|||||||
int putchar(int c){
|
int putchar(int c){
|
||||||
dmesg_index++;
|
dmesg_index++;
|
||||||
while(dmesg_index>DMESGLEN)
|
while(dmesg_index>DMESGLEN)
|
||||||
dmesg_index-=DMESGLEN;
|
dmesg_index=dmesg_index-DMESGLEN;
|
||||||
return dmesg_buffer[dmesg_index]=(char) c;
|
return dmesg_buffer[dmesg_index]=(char) c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,14 @@
|
|||||||
\brief Kernel debug message buffer.
|
\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.
|
//! Clears the dmesg buffer.
|
||||||
void dmesg_clear();
|
void dmesg_clear();
|
||||||
|
|
||||||
|
@ -21,6 +21,27 @@ enum {
|
|||||||
} monitor_verb;
|
} 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<DMESGLEN;i++){
|
||||||
|
uart_tx(dmesg_buffer[i]);
|
||||||
|
}
|
||||||
|
//checksum
|
||||||
|
uart_tx(0x00);
|
||||||
|
uart_tx(0x00);
|
||||||
|
}
|
||||||
|
|
||||||
//! Handle a monitor command.
|
//! Handle a monitor command.
|
||||||
int monitor_handle(uint8_t *buffer, int len){
|
int monitor_handle(uint8_t *buffer, int len){
|
||||||
uint16_t *buffer16=(uint16_t*) buffer;
|
uint16_t *buffer16=(uint16_t*) buffer;
|
||||||
@ -56,7 +77,8 @@ int monitor_handle(uint8_t *buffer, int len){
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case DMESG:
|
case DMESG:
|
||||||
|
send_dmesg();
|
||||||
|
len=0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,6 @@ void uart_init(){
|
|||||||
UCA0IE |= UCRXIE; // Enable USCI_A0 RX interrupt
|
UCA0IE |= UCRXIE; // Enable USCI_A0 RX interrupt
|
||||||
//UCA0IE |= UCTXIE; // Enable USCI_A0 TX interrupt
|
//UCA0IE |= UCTXIE; // Enable USCI_A0 TX interrupt
|
||||||
|
|
||||||
printf("Done.\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Transmit a byte to the UART.
|
//! Transmit a byte to the UART.
|
||||||
@ -79,8 +78,11 @@ static void handle_txbyte(){
|
|||||||
|
|
||||||
//State machine.
|
//State machine.
|
||||||
static enum {IDLE,LL,LH,MSG,CRCL,CRCH} state=IDLE;
|
static enum {IDLE,LL,LH,MSG,CRCL,CRCH} state=IDLE;
|
||||||
|
|
||||||
|
//Do nothing whne the length is null.
|
||||||
|
if(outlength==0)
|
||||||
|
return;
|
||||||
|
|
||||||
printf("Sending packet.\n");
|
|
||||||
do{
|
do{
|
||||||
switch(state){
|
switch(state){
|
||||||
case IDLE:
|
case IDLE:
|
||||||
@ -111,11 +113,9 @@ static void handle_txbyte(){
|
|||||||
uart_tx((outcrc>>8));
|
uart_tx((outcrc>>8));
|
||||||
state=IDLE;
|
state=IDLE;
|
||||||
|
|
||||||
printf("Sent %d byte packet.\n",outlength);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}while(state!=IDLE);
|
}while(state!=IDLE);
|
||||||
printf("Done, state=%d.\n",state);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Handle a UART byte.
|
//! Handle a UART byte.
|
||||||
@ -160,7 +160,6 @@ static void handle_rxbyte(uint8_t byte){
|
|||||||
crc|= ((uint16_t)byte)<<8;
|
crc|= ((uint16_t)byte)<<8;
|
||||||
state=IDLE;
|
state=IDLE;
|
||||||
|
|
||||||
printf("Got %d byte packet.\n",length);
|
|
||||||
outlength=monitor_handle(uart_buffer, length);
|
outlength=monitor_handle(uart_buffer, length);
|
||||||
outindex=0;
|
outindex=0;
|
||||||
outcrc=crc;
|
outcrc=crc;
|
||||||
|
Loading…
Reference in New Issue
Block a user