IPR1bits.TX1IP = 0; // Low
IPR1bits.RC1IP = 1; // High
RCSTA = 0b10010000; //SPEN, 8bit, ASYNC, CREN = 0
- BAUDCON = 0b00001010; // IDLE High, BRG16, ABDEN, WUE
+ BAUDCON = 0b00001010; // IDLE High, BRG16, -ABDEN, WUE
TXSTA = 0b00100000; //8bit, ASYNC, TXEN, Break
PIE1bits.TX1IE = 0;
PIE1bits.RC1IE = 1;
IPR1bits.TX1IP = 0; // Low
IPR1bits.RC1IP = 1; // High
RCSTA = 0b10010000; //SPEN, 8bit, ASYNC, CREN
- BAUDCON = 0b00001010; // IDLE High, BRG16, ABDEN, WUE
+ BAUDCON = 0b00001010; // IDLE High, BRG16, -ABDEN, WUE
TXSTA = 0b00100000; //8bit, ASYNC, TXEN, Break
PIE1bits.TX1IE = 0;
PIE1bits.RC1IE = 1;
#include "term_shell.h"
-char cmd_shellstr[255];
+unsigned char cmd_shellstr[255];
static char shell_strbuf[255];
static char xarg1[128];
static char xarg2[128];
unsigned int ii;
char pool[128];
- cmd_shellstr[0] = '\0';
+ //cmd_shellstr[0] = '\0';
if(timeout != 0) {
t = timeout;
while((uart_getstat() & UART_WAKEUP) == 0) {
uart_term_putstr("\nOpen I2C Radio v2.0\n(C)2013- Kyuma Ohta\n");
uart_term_putstr("\n\nWelcome to shell mode (^^).\nPress help to show usage.\n");
do {
+ cmd_shellstr[0] = '\0';
uart_term_putstr("\n$>");
- uart_term_getstr(cmd_shellstr, 128, 1); // With Echo
+ uart_term_getstr(cmd_shellstr, 100, 1); // With Echo, timeout=10Sec.
+ if(cmd_shellstr[0] == TERM_CHAR_TIMEOUT){
+ uart_term_putstr("\nTimeout.\n");
+ uart_init();
+ return SHELL_CMD_NONE; // TimeOut
+ }
+
+
+
ClrWdt();
ii = shell_gettok(pool, cmd_shellstr);
// if(ii >= 128) return SHELL_CMD_TOOLONG;
#include "menu.h"
#include "uart_termio.h"
#include "shell_strutl.h"
-
+#include "power.h"
unsigned char uart_term_putstr(unsigned char *s)
{
return 0xff;
}
-void uart_term_getstr(unsigned char *s, unsigned char maxlen, unsigned char echo)
+void uart_term_getstr(unsigned char *s, unsigned int timeout, unsigned char echo)
{
unsigned char i = 0;
unsigned char c = 0x00;
- while(c != '\n'){
+ unsigned int tim;
+ unsigned char pwr;
+ unsigned char cnt;
+ tim = 0;
+ cnt = 0;
+ while(1){
ClrWdt();
c = uart_pullchar();
if(c != 0x00) {
+ if(cnt > 10) {
+ if(chk_powerbutton() != 0) {
+ shutdown(0xff);
+ }
+ cnt = 0;
+ }
+ cnt++;
s[i] = c;
+ if((c == '\i') || (c == '\n')) break;
if(echo != 0) uart_pushchar(c, 0); // Echoback
i++;
- if(i >= maxlen) break;
- }
+ if(i >= 128) break;
+ tim = 0;
+ } else if(timeout != 0) { // ZAP n * 100mSec.
+ if(chk_powerbutton() != 0) shutdown(0xff);
+ idle_time_ms(100 - 48); // Poll 0.1Sec
+ tim++;
+ if(tim > timeout) {
+ s[0] = TERM_CHAR_TIMEOUT;
+ i = 1;
+ break;
+ }
+ } else {
+ idle_time_ms(100 - 48); // Wait 100ms if none (and no Timeout).
+ if(chk_powerbutton() != 0) shutdown(0xff);
+ }
}
s[i] = '\0';
}
extern "C" {
#endif
+#define TERM_CHAR_TIMEOUT 0xff
extern unsigned char uart_term_putstr(unsigned char *s);
-extern void uart_term_getstr(unsigned char *s, unsigned char maxlen, unsigned char echo);
+extern void uart_term_getstr(unsigned char *s, unsigned int maxlen, unsigned char echo);
#ifdef __cplusplus