- hmcfgusb_send_null_frame(dev, 1);
- speed_buf[0] = 'G';
- speed_buf[1] = speed;
- hmcfgusb_send(dev, speed_buf, 2, 1);
+ hmcfgusb_send_null_frame(dev.hmcfgusb, 1);
+ buf[0] = 'G';
+ buf[1] = speed;
+ hmcfgusb_send(dev.hmcfgusb, buf, 2, 1);
+ } else {
+ dev.hmuartlgw = hmuart_init(uart, parse_hmuartlgw, &rdata, 1);
+ if (!dev.hmuartlgw) {
+ fprintf(stderr, "Can't initialize HM-MOD-UART!\n");
+ exit(1);
+ }
+ printf("HM-MOD-UART opened!\n");
+
+ buf[0] = HMUARTLGW_APP_SET_HMID;
+ buf[1] = 0x00;
+ buf[2] = 0x00;
+ buf[3] = 0x00;
+ hmuartlgw_send(dev.hmuartlgw, buf, 4, HMUARTLGW_APP);
+ do { hmuartlgw_poll(dev.hmuartlgw, 500); } while (errno != ETIMEDOUT);
+ if (speed == 100) {
+ buf[0] = HMUARTLGW_OS_UPDATE_MODE;
+ buf[1] = 0xe9;
+ buf[2] = 0xca;
+ hmuartlgw_send(dev.hmuartlgw, buf, 3, HMUARTLGW_OS);
+ } else {
+ buf[0] = HMUARTLGW_OS_NORMAL_MODE;
+ hmuartlgw_send(dev.hmuartlgw, buf, 1, HMUARTLGW_OS);
+ }
+ }