Skip to content

Commit

Permalink
Add wait_for_response to PTP/IP
Browse files Browse the repository at this point in the history
  • Loading branch information
petabyt committed Oct 4, 2023
1 parent 32ea3e6 commit efd9a08
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,19 @@ int ptp_send_bulk_packets(struct PtpRuntime *r, int length) {
int ptpip_read_packet(struct PtpRuntime *r, int of) {
int read = 0;

int rc = ptpip_cmd_read(r, r->data + of, 8);
if (rc != 8) {
ptp_verbose_log("Failed to read PTP/IP header\n");
return PTP_IO_ERR;
int rc = 0;
while (rc <= 0 && r->wait_for_response) {
rc = ptp_cmd_read(r, r->data + of + read, r->max_packet_size);

r->wait_for_response--;

if (r->wait_for_response) {
CAMLIB_SLEEP(1000);
}
}

r->wait_for_response = 1;

read += rc;

struct PtpIpHeader *h = (struct PtpIpHeader *)(r->data + of);
Expand Down

0 comments on commit efd9a08

Please sign in to comment.