Skip to content

Commit

Permalink
Merge pull request #23 from edgetriggered/b/21
Browse files Browse the repository at this point in the history
H8SX libusb_bulk_transfer buffer size and slightly improved logging
  • Loading branch information
v0l authored Nov 4, 2022
2 parents 2656a17 + 92e8e0d commit bdb6ec3
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/h8sx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,27 +277,28 @@ auto H8SX::InquireDevice(struct dev_inq_hdr_t **hdr) const -> void
CHECK_ERR("cannot begin inquiry phase!");

// Expected response 0xE6 <- (ACK)
err = libusb_bulk_transfer(device, BULK_EP_IN, buf, sizeof(buf), &received, 0);

CHECK_ERR("I/O error!");
err = libusb_bulk_transfer(device, BULK_EP_IN, buf, BUF_SIZE, &received, 0);
CHECK_ERR("failed to receive reply to inquiry!");
if (buf[0] != 0xE6)
err = -1;
CHECK_ERR("wrong response from radio!");

// Second command 0x20 -> Supported Device Inquiry
cmd = static_cast<uint8_t>(H8SXCmd::DEVICE_INQUIRY);
err = libusb_bulk_transfer(device, BULK_EP_OUT, &cmd, 1, &transferred, 0);
CHECK_ERR("I/O error!");
CHECK_ERR("failed to query supported device!");

// Expected response <- Supported Device Response
err = libusb_bulk_transfer(device, BULK_EP_IN, buf, sizeof(buf), &received, 0);
err = libusb_bulk_transfer(device, BULK_EP_IN, buf, BUF_SIZE, &received, 0);
CHECK_ERR("failed to receive supported device response!");

// Checksum
err = libusb_bulk_transfer(device, BULK_EP_IN, buf, 1, &received, 0);
CHECK_ERR("failed to receive checksum!");

CHECK_ERR("error in device selection!");
auto dir = (struct dev_inq_hdr_t *)buf;
// TODO: Validate checksum
buf[sizeof(struct dev_inq_hdr_t) + dir->nchar] = '\0';

*hdr = dir;
}
}

0 comments on commit bdb6ec3

Please sign in to comment.