Changeset 364 for asp3_tinet_ecnl_rx/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_rx/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; 83 85 #endif 84 86 #ifdef IF_ETHER_BTUSB 85 87 extern int bt_bnep_mode; 86 88 /* PANU向けリモートアドレス */ 87 89 bd_addr_t remote_addr = {0x00,0x1B,0xDC,0x09,0x27,0x26}; 90 bool_t dhcp_enable = false; 91 #else 92 bool_t dhcp_enable = true; 88 93 #endif 89 94 90 95 uint8_t mac_addr[6] = {0x12, 0x34, 0x56, 0x78, 0x9A, 0x01}; 91 bool_t dhcp_enable = true;92 96 PRI main_task_priority = MAIN_PRIORITY + 1; 93 97 … … 112 116 static void main_timeout(); 113 117 118 extern int ntshell_exit; 119 114 120 int uart_read(char *buf, int cnt, void *extobj) 115 121 { 116 return serial_rea_dat(SIO_PORTID, (char *)buf, cnt); 122 struct main_t *obj = (struct main_t *)extobj; 123 int result; 124 ER ret; 125 int timer; 126 127 obj->prev = obj->now; 128 129 /* タイマー取得 */ 130 timer = main_get_timer(); 131 132 /* 待ち */ 133 ret = serial_trea_dat(SIO_PORTID, buf, cnt, timer); 134 if ((ret < 0) && (ret != E_OK) && (ret != E_TMOUT)) { 135 syslog(LOG_NOTICE, "tslp_tsk ret: %s %d", itron_strerror(ret), timer); 136 ntshell_exit = 1; 137 return -1; 138 } 139 result = (int)ret; 140 141 ret = get_tim(&obj->now); 142 if (ret != E_OK) { 143 syslog(LOG_NOTICE, "get_tim ret: %s", itron_strerror(ret)); 144 ntshell_exit = 1; 145 return -1; 146 } 147 148 /* 時間経過 */ 149 int elapse = obj->now - obj->prev; 150 main_progress(elapse); 151 152 /* タイムアウト処理 */ 153 main_timeout(); 154 155 return result; 117 156 } 118 157 … … 120 159 { 121 160 return serial_wri_dat(SIO_PORTID, buf, cnt); 122 }123 124 unsigned char ntstdio_xi(struct ntstdio_t *handle)125 {126 char buf[1];127 if(serial_rea_dat(SIO_PORTID, buf, 1) != 1)128 return -EIO;129 return buf[0];130 }131 132 void ntstdio_xo(struct ntstdio_t *handle, unsigned char c)133 {134 char buf[1];135 buf[0] = c;136 serial_wri_dat(SIO_PORTID, buf, 1);137 161 } 138 162 … … 151 175 main_initialize(); 152 176 153 ntshell_init(&ntshell, uart_read, uart_write, cmd_execute, NULL);177 ntshell_init(&ntshell, uart_read, uart_write, cmd_execute, &main_obj); 154 178 ntshell_set_prompt(&ntshell, "NTShell>"); 155 179 ntshell_execute(&ntshell); … … 171 195 ER ret; 172 196 197 #ifdef TOPPERS_OMIT_TECS 198 serial_opn_por(SIO_PORTID); 199 #endif 200 serial_ctl_por(SIO_PORTID, IOCTL_FCSND | IOCTL_FCRCV); 201 173 202 //wolfSSL_Debugging_ON(); 174 203 175 ntshell_task_init( );204 ntshell_task_init(uart_read, uart_write, &main_obj); 176 205 177 206 main_obj.timer = TMO_FEVR; … … 308 337 } 309 338 339 int cmd_creid(int argc, char **argv) 340 { 341 if (argc != 2) { 342 printf("creid {client_id}\n"); 343 return 0; 344 } 345 346 client_set_client_id(argv[1]); 347 348 return 0; 349 } 350 351 int cmd_secret(int argc, char **argv) 352 { 353 if (argc != 2) { 354 printf("secret {client_secret}\n"); 355 return 0; 356 } 357 358 client_set_client_secret(argv[1]); 359 360 return 0; 361 } 362 310 363 int cmd_logupload(int argc, char **argv) 311 364 { 312 client_task(0); 313 return 0; 365 return client_upload_file(argc, argv); 314 366 } 315 367 … … 330 382 {"dnsc", "DNS client", usrcmd_dnsc }, 331 383 {"ntpc", "NTP client", usrcmd_ntpc }, 384 {"creid", "Regster device", cmd_creid}, 385 {"secret", "Regster device", cmd_secret}, 386 {"gdi", "get_device_id", client_get_device_id}, 387 {"gat", "get_access_token", client_get_access_token}, 388 {"uat", "update_access_token", client_update_access_token}, 389 {"rd", "revoke device", client_revoke}, 390 {"uf", "upload_file", client_upload_file}, 332 391 {"logupload", "Upload log to server", cmd_logupload}, 333 392 {"info", "This is a description text string for info command.", usrcmd_info},
Note:
See TracChangeset
for help on using the changeset viewer.