Exemplo n.º 1
0
void parse(void) {

  parse_fail = 0;
  checked(char* token = parse_string());

  if ( *token == '\0' )           return;
  else if ( TOKEN_IS("SET"))      parse_set();
  else if ( TOKEN_IS("GET"))      parse_get();
  else if ( TOKEN_IS("HELLO"))    { }
  else if ( TOKEN_IS("COMMIT"))   eeprom_commit();

  //  else if ( TOKEN_IS("SELFTEST")) selftest_perform();
  else                            { parse_fail = 1; uart_puts_P(" UNKNOWN COMMAND"); }

#ifdef COMMANDLINE_DEBUG
  // string fully consumed?
  if ( *current_pos != '\0' )  {
	parse_fail = 1;
	uart_puts_P("too much input: "); 
	uart_puts(current_pos);
	uart_puts_P(NEWLINE);
  }
#endif

  if ( parse_fail ) uart_puts_P("FAIL"); 
  else uart_puts_P("OK");

  uart_puts_P(NEWLINE);

}
Exemplo n.º 2
0
void writeusersettingstoeeprom(void)
{
    uint16_t magicnumber = MAGICNUMBER;
    int size = sizeof(usersettingsstruct);

    eeprom_write_block((const void *)&magicnumber, 0, sizeof(magicnumber));
    eeprom_write_block((const void *)&size, 2, sizeof(size));
    eeprom_write_block((const void *)&usersettings, 4, size);
    eeprom_commit();
}