- while (1) {
- if (rdata->message_type == MESSAGE_TYPE_R) {
- if (((rdata->status & 0xff) == 0x01) ||
- ((rdata->status & 0xff) == 0x02)) {
- break;
- } else {
- if ((rdata->status & 0xff00) == 0x0400) {
- fprintf(stderr, "\nOut of credits!\n");
- } else if ((rdata->status & 0xff) == 0x08) {
- fprintf(stderr, "\nMissing ACK!\n");
- } else {
- fprintf(stderr, "\nInvalid status: %04x\n", rdata->status);
+ out[0] = 'S';
+ out[1] = (id >> 24) & 0xff;
+ out[2] = (id >> 16) & 0xff;
+ out[3] = (id >> 8) & 0xff;
+ out[4] = id & 0xff;
+ out[10] = 0x01;
+ out[11] = (tv.tv_usec >> 24) & 0xff;
+ out[12] = (tv.tv_usec >> 16) & 0xff;
+ out[13] = (tv.tv_usec >> 8) & 0xff;
+ out[14] = tv.tv_usec & 0xff;
+
+ memcpy(&out[0x0f], msg, msg[0] + 1);
+
+ memset(rdata, 0, sizeof(struct recv_data));
+ hmcfgusb_send(dev->hmcfgusb, out, sizeof(out), 1);
+
+ while (1) {
+ if (rdata->message_type == MESSAGE_TYPE_R) {
+ if (((rdata->status & 0xff) == 0x01) ||
+ ((rdata->status & 0xff) == 0x02)) {
+ break;
+ } else {
+ if ((rdata->status & 0xff00) == 0x0400) {
+ fprintf(stderr, "\nOut of credits!\n");
+ } else if ((rdata->status & 0xff) == 0x08) {
+ fprintf(stderr, "\nMissing ACK!\n");
+ } else {
+ fprintf(stderr, "\nInvalid status: %04x\n", rdata->status);
+ }
+ return 0;
+ }
+ }
+ errno = 0;
+ pfd = hmcfgusb_poll(dev->hmcfgusb, 1000);
+ if ((pfd < 0) && errno) {
+ if (errno != ETIMEDOUT) {
+ perror("\n\nhmcfgusb_poll");
+ exit(EXIT_FAILURE);
+ }