Changeset 364 for asp3_tinet_ecnl_arm/trunk/app1_usb_watt_meter/src/main.c
- Timestamp:
- Feb 1, 2019, 9:57:09 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
asp3_tinet_ecnl_arm/trunk/app1_usb_watt_meter/src/main.c
r359 r364 45 45 #include <sil.h> 46 46 #include <setjmp.h> 47 #include <stdlib.h> 47 48 #include <string.h> 48 49 #include "syssvc/serial.h" … … 80 81 81 82 ID ws_api_mailboxid = MAIN_DATAQUEUE; 83 #ifndef NOUSE_MPF_NET_BUF 82 84 ID ws_mempoolid = MPF_NET_BUF_256; 85 #endif 83 86 84 87 #if defined(IF_ETHER_BTUSB) || defined(IF_ETHER_ENBT) … … 114 117 static void main_timeout(); 115 118 119 extern int ntshell_exit; 120 116 121 int uart_read(char *buf, int cnt, void *extobj) 117 122 { 118 return serial_rea_dat(SIO_PORTID, (char *)buf, cnt); 123 struct main_t *obj = (struct main_t *)extobj; 124 int result; 125 ER ret; 126 int timer; 127 128 obj->prev = obj->now; 129 130 /* タイマー取得 */ 131 timer = main_get_timer(); 132 133 /* 待ち */ 134 ret = serial_trea_dat(SIO_PORTID, buf, cnt, timer); 135 if ((ret < 0) && (ret != E_OK) && (ret != E_TMOUT)) { 136 syslog(LOG_NOTICE, "tslp_tsk ret: %s %d", itron_strerror(ret), timer); 137 ntshell_exit = 1; 138 return -1; 139 } 140 result = (int)ret; 141 142 ret = get_tim(&obj->now); 143 if (ret != E_OK) { 144 syslog(LOG_NOTICE, "get_tim ret: %s", itron_strerror(ret)); 145 ntshell_exit = 1; 146 return -1; 147 } 148 149 /* 時間経過 */ 150 int elapse = obj->now - obj->prev; 151 main_progress(elapse); 152 153 /* タイムアウト処理 */ 154 main_timeout(); 155 156 return result; 119 157 } 120 158 … … 122 160 { 123 161 return serial_wri_dat(SIO_PORTID, buf, cnt); 124 }125 126 unsigned char ntstdio_xi(struct ntstdio_t *handle)127 {128 char buf[1];129 if(serial_rea_dat(SIO_PORTID, buf, 1) != 1)130 return -EIO;131 return buf[0];132 }133 134 void ntstdio_xo(struct ntstdio_t *handle, unsigned char c)135 {136 char buf[1];137 buf[0] = c;138 serial_wri_dat(SIO_PORTID, buf, 1);139 162 } 140 163 … … 156 179 main_initialize(); 157 180 158 ntshell_init(&ntshell, uart_read, uart_write, cmd_execute, NULL);181 ntshell_init(&ntshell, uart_read, uart_write, cmd_execute, &main_obj); 159 182 ntshell_set_prompt(&ntshell, "NTShell>"); 160 183 ntshell_execute(&ntshell); … … 176 199 ER ret; 177 200 201 #ifdef TOPPERS_OMIT_TECS 202 serial_opn_por(SIO_PORTID); 203 #endif 204 serial_ctl_por(SIO_PORTID, IOCTL_FCSND | IOCTL_FCRCV); 205 178 206 //wolfSSL_Debugging_ON(); 179 207 180 ntshell_task_init( );208 ntshell_task_init(uart_read, uart_write, &main_obj); 181 209 182 210 main_obj.timer = TMO_FEVR; … … 313 341 } 314 342 343 int cmd_creid(int argc, char **argv) 344 { 345 if (argc != 2) { 346 printf("creid {client_id}\n"); 347 return 0; 348 } 349 350 client_set_client_id(argv[1]); 351 352 return 0; 353 } 354 355 int cmd_secret(int argc, char **argv) 356 { 357 if (argc != 2) { 358 printf("secret {client_secret}\n"); 359 return 0; 360 } 361 362 client_set_client_secret(argv[1]); 363 364 return 0; 365 } 366 315 367 int cmd_logupload(int argc, char **argv) 316 368 { 317 client_task(0); 318 return 0; 369 return client_upload_file(argc, argv); 319 370 } 320 371 … … 335 386 {"dnsc", "DNS client", usrcmd_dnsc }, 336 387 {"ntpc", "NTP client", usrcmd_ntpc }, 388 {"creid", "Regster device", cmd_creid}, 389 {"secret", "Regster device", cmd_secret}, 390 {"gdi", "get_device_id", client_get_device_id}, 391 {"gat", "get_access_token", client_get_access_token}, 392 {"uat", "update_access_token", client_update_access_token}, 393 {"rd", "revoke device", client_revoke}, 394 {"uf", "upload_file", client_upload_file}, 337 395 {"logupload", "Upload log to server", cmd_logupload}, 338 396 {"info", "This is a description text string for info command.", usrcmd_info},
Note:
See TracChangeset
for help on using the changeset viewer.