# HG changeset patch # User mkanning@CL-SEC241-09.cedarville.edu # Date 2012-10-25 21:57:28 # Node ID 5b9c23cdba0a7b82028d8283014fb09103fa7517 # Parent 5e60cbe0920d90e319ea50d3c69680ab7548d996 parser for master module diff --git a/master/master/config.h b/master/master/config.h --- a/master/master/config.h +++ b/master/master/config.h @@ -11,6 +11,6 @@ #define F_CPU 11059200 #define USART_BAUDRATE 19200 - +#define MODULE_ID '1' #endif /* CONFIG_H_ */ \ No newline at end of file diff --git a/master/master/lib/serial.c b/master/master/lib/serial.c --- a/master/master/lib/serial.c +++ b/master/master/lib/serial.c @@ -13,7 +13,7 @@ void serial_SendChar( char byte ) UDR0 = byte; } -void serial_SendCommand( char moduleID, char measureType, uint8_t dataLength, char* data ) +void serial_SendCommand( char moduleID, char sensorID, uint8_t dataLength, char* data ) { char checkSum = 0x00; //initialize checksum @@ -21,8 +21,8 @@ void serial_SendCommand( char moduleID, serial_SendChar(moduleID); checkSum+=moduleID; - serial_SendChar(measureType); - checkSum+=measureType; + serial_SendChar(sensorID); + checkSum+=sensorID; //send each character of data individually for (int i=0; i +#include "../config.h" //#define DEBUG // ************* Command Definitions *************** // Serial Commands -enum luma_cmd { // CMD ID# +enum cmd // CMD ID# +{ BOARDTEMP = 0, // 0 PRESSURE, // 1 }; -// Data length of each command, in bytes -uint8_t cmd_len[] = { - 2, // BOARDTEMP_LEN - 0, // PRESSURE_LEN -}; - // Incoming command buffer uint8_t buffer[MAX_CMD_LEN+2]; // Current buffer location -uint8_t buffercount = 0; +uint8_t bufferPosition = 0; +//current length of the data transmission (and checksum) +int dataLength; +//data (and checksum) of most recent transmission +char data[16]; -/* Get char from UART */ +//ID of the sensor of most recent transmission +char sensorID; + +/* return char from UART (h/w buffer) */ uint8_t uart_getchar(void) { // Wait for chars - while (!(UCSRA & (1<