+static int switch_speed(struct ota_dev *dev, struct recv_data *rdata, uint8_t speed)
+{
+ uint8_t out[0x40];
+ int pfd;
+
+ printf("Entering %uk-mode\n", speed);
+
+ switch(dev->type) {
+ case DEVICE_TYPE_HMCFGUSB:
+ memset(out, 0, sizeof(out));
+ out[0] = 'G';
+ out[1] = speed;
+
+ hmcfgusb_send(dev->hmcfgusb, out, sizeof(out), 1);
+
+ while (1) {
+ errno = 0;
+ pfd = hmcfgusb_poll(dev->hmcfgusb, 1);
+ if ((pfd < 0) && errno) {
+ if (errno != ETIMEDOUT) {
+ perror("\n\nhmcfgusb_poll");
+ exit(EXIT_FAILURE);
+ }
+ }
+ if (rdata->speed == speed)
+ break;
+ }
+ break;
+ case DEVICE_TYPE_CULFW:
+ if (speed == 100) {
+ return culfw_send(dev->culfw, "AR\r\n", 4);
+ } else {
+ return culfw_send(dev->culfw, "Ar\r\n", 4);
+ }
+ break;
+ }
+
+ return 1;
+}
+
+void flash_ota_syntax(char *prog)
+{
+ fprintf(stderr, "Syntax: %s parameters options\n\n", prog);
+ fprintf(stderr, "Mandatory parameters:\n");
+ fprintf(stderr, "\t-f firmware.eq3\tfirmware file to flash\n");
+ fprintf(stderr, "\t-s SERIAL\tserial of device to flash\n");
+ fprintf(stderr, "\nPossible options:\n");
+ fprintf(stderr, "\t-c device\tenable CUL-mode with CUL at path \"device\"\n");
+ fprintf(stderr, "\t-b bps\t\tuse CUL with speed \"bps\" (default: %u)\n", DEFAULT_CUL_BPS);
+ fprintf(stderr, "\t-h\t\tthis help\n");
+}
+