+ if (response->cmd & CMD_VARIABLE_SIZE_FLAG) { // new style response with variable size
+ // printf("received new style response %04" PRIx16 ", datalen = %d, arg[0] = %08" PRIx32 ", arg[1] = %08" PRIx32 ", arg[2] = %08" PRIx32 "\n",
+ // response->cmd, response->datalen, response->arg[0], response->arg[1], response->arg[2]);
+ bytes_to_read = response->datalen;
+ if (receive_from_serial(sp, prx, bytes_to_read, &rxlen)) {
+ UsbCommand resp;
+ resp.cmd = response->cmd & ~CMD_VARIABLE_SIZE_FLAG;
+ resp.arg[0] = response->arg[0];
+ resp.arg[1] = response->arg[1];
+ resp.arg[2] = response->arg[2];
+ memcpy(&resp.d.asBytes, &response->d.asBytes, response->datalen);
+ UsbCommandReceived(&resp);
+ if (resp.cmd == CMD_ACK) {
+ ACK_received = true;
+ }
+ }
+ } else { // old style response uses same data structure as commands. Fixed size.
+ // printf("received old style response %016" PRIx64 ", arg[0] = %016" PRIx64 "\n", command->cmd, command->arg[0]);
+ bytes_to_read = sizeof(UsbCommand) - bytes_to_read;
+ if (receive_from_serial(sp, prx, bytes_to_read, &rxlen)) {
+ UsbCommandReceived(command);
+ if (command->cmd == CMD_ACK) {
+ ACK_received = true;
+ }
+ }