#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';
}