- memset(tmp, 0, sizeof(tmp));
- for (i = 1; i < r; i+=2) {
- memcpy(tmp, buf + i, 2);
- send_buf[1+(i/2)] = strtoul(tmp, NULL, 16);
+ if (last == 0)
+ continue;
+
+ if (verbose) {
+ print_timestamp(stdout);
+ printf("LAN > ");
+ for (i = 0; i < last; i++)
+ printf("%c", instart[i]);
+ printf("\n");
+ }
+
+ memset(out, 0, sizeof(out));
+ *outpos++ = *inpos++;
+
+ switch(*instart) {
+ case 'S':
+ parse_part_in(&inpos, (last-(inpos-instart)), &outpos, (sizeof(out)-(outpos-out)), 0);
+ parse_part_in(&inpos, (last-(inpos-instart)), &outpos, (sizeof(out)-(outpos-out)), 0);
+ parse_part_in(&inpos, (last-(inpos-instart)), &outpos, (sizeof(out)-(outpos-out)), 0);
+ parse_part_in(&inpos, (last-(inpos-instart)), &outpos, (sizeof(out)-(outpos-out)), 0);
+ parse_part_in(&inpos, (last-(inpos-instart)), &outpos, (sizeof(out)-(outpos-out)), 0);
+ parse_part_in(&inpos, (last-(inpos-instart)), &outpos, (sizeof(out)-(outpos-out)), FLAG_LENGTH_BYTE);
+ break;
+ case 'Y':
+ parse_part_in(&inpos, (last-(inpos-instart)), &outpos, (sizeof(out)-(outpos-out)), 0);
+ parse_part_in(&inpos, (last-(inpos-instart)), &outpos, (sizeof(out)-(outpos-out)), 0);
+ parse_part_in(&inpos, (last-(inpos-instart)), &outpos, (sizeof(out)-(outpos-out)), FLAG_LENGTH_BYTE);
+ break;
+ default:
+ parse_part_in(&inpos, (last-(inpos-instart)), &outpos, (sizeof(out)-(outpos-out)), FLAG_IGNORE_COMMAS);
+ break;
+ }
+
+ hmcfgusb_send(dev, out, sizeof(out), 1);