Example #1
0
File: client.c Project: prcek/RFPad
void client_autorun() {
	print(PSTR("client autorun\n\r"));
	rf_client_hack();
	client_init();
	while(!uart_read_ready()) {
        	client_loop();
        }
}
Example #2
0
File: pad.c Project: prcek/RFPad
void pad_autoread() {
	print(PSTR("pad autoread\n\r"));
	pad_init();
	uint8_t ld =0;
	while(!uart_read_ready()) {
        uint8_t d = pad_read();
	    if (ld!=d) {	
		    print_hb(0,d);
    		ld=d;
		}
    }
}
Example #3
0
u08 cmd_uart_get_next(u08 **data)
{
  rx_size = 0;
  int button_press = 0;
  while(1) {
      while(!uart_read_ready()) {
#ifdef USE_BUTTON_CONTROL
          // check buttons
          if(button1_pressed()) {
              while(button1_pressed()) {}
              rx_buf[0] = 'R';
              rx_size = 1;
              button_press = 1;
              break;
          }
          if(button2_pressed()) {
              while(button2_pressed()) {}
              rx_buf[0] = 'W';
              rx_size = 1;
              button_press = 1;
              break;
          }
#endif
      }
      if(button_press) {
          break;
      }

      u08 c;
      uart_read(&c);
      uart_send(c);
      if((c == '\n')||(c == '\r')) {
          break;
      }
      rx_buf[rx_size] = c;
      rx_size++;
  }
  *data = rx_buf;
  uart_send_crlf();
  return rx_size;
}
Example #4
0
u32 cmdline_getline(void)
{
    uart_send_string((u08 *)"> ");
    
    u32 i = 0;
    while(i<CMDLINE_LEN) {
        // wait for next char
        while(!uart_read_ready());
        
        u08 data;
        uart_read(&data);
        uart_send(data);
        
        if(data == '\r') {
            uart_send('\n');
            break;
        }
        if(data == '\n')
            continue;
            
        cmdline[i++] = data;
    }
    return i;
}
Example #5
0
File: client.c Project: prcek/RFPad
uint8_t client_do_prompt() {
        char cmd[17];
        //scanf("%16s",cmd);
        scan_key(cmd,17);
        if (strcmp(cmd,"init")==0) {
                        client_init();
			print_ok_nl();
                        return 1;
        }
        if (strcmp(cmd,"loop")==0) {
                        uint16_t count = scan_uint16();

                        if (count == 0) {
                                print(PSTR("client loop...."));
                                while(!uart_read_ready()) {
                                        client_loop();
                                }
                                print(PSTR("   end\n\r"));
                        } else {
                                while(count--) {
                                        print_char('.');
                                        client_loop();
                                }
                        }

                        return 1;
        }
	if (strcmp(cmd,"autotune")==0) {
			client_autotune();
			return 1;
	}

	if (strcmp(cmd,"channel")==0) {
			uint8_t c = scan_uint8();
			client_select_channel(c);
			return 1;
	}

	if (strcmp(cmd,"check")==0) {
			uint8_t c = scan_uint8();
			if (client_check_for_server(c)) {
				print(PSTR("ok\r\n"));
			} else {
				print(PSTR("fail\r\n"));
			}
			return 1;
	}

	if (strcmp(cmd,"pad")==0) {
		uint8_t l = client_read_pad();
		print_hb(0,l);
		while(!uart_read_ready()) {
			uint8_t d = client_read_pad();		
			if (d!=l) {
				l = d;
				print_hb(PSTR(" "), d);
			}
		}
		
		return 1;
	}

	if (strcmp(cmd,"reset_stats")==0) {
		stats_ok = 0;
		stats_inv_seq = 0;
		stats_bad_crc = 0;
		stats_timeout = 0;
		print(PSTR("stat reset ok"));
		return 1;
	}

	if (strcmp(cmd,"stats")==0) {
		print_dw(PSTR("ok: "), stats_ok);
		print_dw(PSTR(" inv_seq: "), stats_inv_seq);
		print_dw(PSTR(" bad_crc: "), stats_bad_crc);
		print_dw(PSTR(" timeout: "), stats_timeout);
		print_nl();
		return 1;
	}



        return 1;

}