ipdbg_org_la_send_reset(tcp);
ipdbg_org_la_send_reset(tcp);
- ipdbg_org_la_request_id(tcp);
+
+ if (ipdbg_org_la_request_id(tcp) != SR_OK)
+ return NULL;
struct sr_dev_inst *sdi = g_malloc0(sizeof(struct sr_dev_inst));
if (!sdi) {
uint8_t *buf, int bufsize)
{
int received = 0;
+ int error_count = 0;
- while (received < bufsize) {
+ /* Timeout after 500ms of not receiving data */
+ while ((received < bufsize) && (error_count < 500)) {
if (ipdbg_org_la_tcp_receive(tcp, buf) > 0) {
buf++;
received++;
+ } else {
+ error_count++;
+ g_usleep(1000); /* Sleep for 1ms */
}
}
sr_warn("Couldn't send ID request");
char id[4];
- if (ipdbg_org_la_tcp_receive_blocking(tcp, (uint8_t *) id, 4) != 4)
- sr_warn("Couldn't read device ID");
+ if (ipdbg_org_la_tcp_receive_blocking(tcp, (uint8_t*)id, 4) != 4) {
+ sr_err("Couldn't read device ID");
+ return SR_ERR;
+ }
if (strncmp(id, "IDBG", 4)) {
sr_err("Invalid device ID: expected 'IDBG', got '%c%c%c%c'.",