Changeset 374 for asp3_tinet_ecnl_arm/trunk/ntshell/src/ntshell_main.c
- Timestamp:
- Apr 5, 2019, 9:26:53 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
asp3_tinet_ecnl_arm/trunk/ntshell/src/ntshell_main.c
r364 r374 59 59 #include "ntshell_main.h" 60 60 #include "socket_stub.h" 61 #include "usb_hbth.h"62 63 extern int bt_bnep_mode;64 61 65 62 char command[NTOPT_TEXT_MAXLEN]; 66 ntstdio_t ntstdio;67 63 68 64 extern uint8_t mac_addr[6]; … … 87 83 volatile int ntshell_state; 88 84 jmp_buf process_exit; 89 void sys_init(void); 90 NTSHELL_SERIAL_READ ntshell_serial_read = 0; 91 NTSHELL_SERIAL_WRITE ntshell_serial_write = 0; 92 void *ntshell_serial_extobj; 93 94 unsigned char ntstdio_xi(struct ntstdio_t *handle) 95 { 96 unsigned char buf[1]; 97 ntshell_serial_read((char *)buf, 1, ntshell_serial_extobj); 98 return buf[0]; 99 } 100 101 void ntstdio_xo(struct ntstdio_t *handle, unsigned char c) 102 { 103 char buf[1]; 104 buf[0] = c; 105 ntshell_serial_write(buf, 1, ntshell_serial_extobj); 106 } 107 108 void ntshell_task_init(NTSHELL_SERIAL_READ func_read, 109 NTSHELL_SERIAL_WRITE func_write, void *extobj) 110 { 111 ntshell_serial_read = func_read; 112 ntshell_serial_write = func_write; 113 ntshell_serial_extobj = extobj; 114 115 sys_init(); 116 117 ntstdio_init(&ntstdio, NTSTDIO_OPTION_LINE_ECHO | NTSTDIO_OPTION_CANON | NTSTDIO_OPTION_LF_CRLF | NTSTDIO_OPTION_LF_CR, ntstdio_xi, ntstdio_xo); 85 86 void ntshell_task_init(ID portid) 87 { 88 serial_ctl_por(portid, IOCTL_CRLF | IOCTL_FCSND | IOCTL_FCRCV); 118 89 } 119 90 … … 177 148 const cmd_table_t *p = cmd_table_info.table; 178 149 for (int i = 0; i < cmd_table_info.count; i++) { 179 ntstdio_puts(&ntstdio, p->cmd); 180 ntstdio_puts(&ntstdio, "\t:"); 181 ntstdio_puts(&ntstdio, p->desc); 182 ntstdio_puts(&ntstdio, "\n"); 150 fwrite(p->cmd, strlen(p->cmd), 1, stdout); 151 fwrite("\t:", strlen("\t:"), 1, stdout); 152 puts(p->desc); 183 153 p++; 184 154 } … … 206 176 int execute_command(int wait) 207 177 { 178 T_RTSK rtsk; 208 179 ER ret; 209 180 … … 228 199 do { 229 200 tslp_tsk(100000); 201 202 ret = ref_tsk(NTSHELL_TASK, &rtsk); 203 if ((ret != E_OK) || (rtsk.tskstat == TTS_DMT)) 204 ntshell_state = 3; 230 205 } while(ntshell_state == 1); 231 206 … … 237 212 ntlibc_strlcpy(command, text, sizeof(command)); 238 213 return execute_command(1); 239 }240 241 int stdio_close(struct _IO_FILE *fp)242 {243 return -EPERM;244 }245 246 size_t stdio_read(struct _IO_FILE *fp, unsigned char *data, size_t len)247 {248 return -EPERM;249 }250 251 size_t stdio_write(struct _IO_FILE *fp, const unsigned char *data, size_t len)252 {253 return -EPERM;254 }255 256 size_t stdin_read(struct _IO_FILE *fp, unsigned char *data, size_t len)257 {258 int i = 0;259 while (i < len) {260 int c = ntstdio_getc(&ntstdio);261 data[i++] = c;262 if ((c == EOF) || (c == '\n'))263 break;264 }265 return i;266 }267 268 size_t stdout_write(struct _IO_FILE *fp, const unsigned char *data, size_t len)269 {270 for (int i = 0; i < len; i++) {271 ntstdio_putc(&ntstdio, data[i]);272 }273 return len;274 }275 276 size_t stderr_write(struct _IO_FILE *fp, const unsigned char *data, size_t len)277 {278 for (int i = 0; i < len; i++) {279 ntstdio_putc(&ntstdio, data[i]);280 }281 return len;282 }283 284 int sio_close(struct _IO_FILE *fp)285 {286 return -EPERM;287 }288 289 size_t sio_read(struct _IO_FILE *fp, unsigned char *data, size_t len)290 {291 return -EPERM;292 }293 294 size_t sio_write(struct _IO_FILE *fp, const unsigned char *data, size_t len)295 {296 return -EPERM;297 }298 299 off_t sio_seek(struct _IO_FILE *fp, off_t ofs, int org)300 {301 return -EPERM;302 }303 304 int sio_ioctl(struct _IO_FILE *fp, int request, void *arg)305 {306 switch (request) {307 case TIOCGWINSZ:308 return 0;309 case TCGETS:310 return sio_tcgetattr(fp->fd, (struct termios *)arg);311 case TCSETS + TCSANOW:312 case TCSETS + TCSADRAIN:313 case TCSETS + TCSAFLUSH:314 return sio_tcsetattr(fp->fd, request - TCSETS, (const struct termios *)arg);315 }316 317 return -EINVAL;318 214 } 319 215 … … 456 352 } 457 353 354 int shell_kill(int pid, int sig) 355 { 356 DebugBreak(); 357 return -1; 358 } 359 360 int shell_gettimeofday(struct timeval *tv, void *tzvp) 361 { 362 SYSTIM time; 363 if (!tv) return 0; 364 get_tim(&time); 365 tv->tv_sec = time / 1000000; 366 tv->tv_usec = time - (tv->tv_sec * 1000000); 367 return 0; 368 } 369
Note:
See TracChangeset
for help on using the changeset viewer.