X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fipdbg-la%2Fprotocol.c;h=b125f1efc8502aec362ed20be82393398c6e3bb9;hb=7f0463840ab5d6a85daaa76850558d2b71e596cf;hp=d5cc7a47340ac305010c7df85639901250cdbddb;hpb=8e249032d385a3f2e17dc52a48b9427fc79315c9;p=libsigrok.git diff --git a/src/hardware/ipdbg-la/protocol.c b/src/hardware/ipdbg-la/protocol.c index d5cc7a47..b125f1ef 100644 --- a/src/hardware/ipdbg-la/protocol.c +++ b/src/hardware/ipdbg-la/protocol.c @@ -67,10 +67,10 @@ static gboolean data_available(struct ipdbg_la_tcp *tcp) { #ifdef _WIN32 u_long bytes_available; - if(ioctlsocket(tcp->socket, FIONREAD, &bytes_available) != 0){ + if (ioctlsocket(tcp->socket, FIONREAD, &bytes_available) != 0) { #else int bytes_available; - if (ioctl(tcp->socket, FIONREAD, &bytes_available) < 0){ // TIOCMGET + if (ioctl(tcp->socket, FIONREAD, &bytes_available) < 0) { /* TIOCMGET */ #endif sr_err("FIONREAD failed: %s\n", g_strerror(errno)); return FALSE; @@ -143,12 +143,11 @@ SR_PRIV int ipdbg_la_tcp_close(struct ipdbg_la_tcp *tcp) int ret = SR_OK; #ifdef _WIN32 - if (shutdown(tcp->socket, SD_SEND) != SOCKET_ERROR) - { + if (shutdown(tcp->socket, SD_SEND) != SOCKET_ERROR) { char recvbuf[16]; int recvbuflen = 16; - // Receive until the peer closes the connection - while(recv(tcp->socket, recvbuf, recvbuflen, 0) > 0); + /* Receive until the peer closes the connection. */ + while (recv(tcp->socket, recvbuf, recvbuflen, 0) > 0); } #endif if (close(tcp->socket) < 0) @@ -181,16 +180,16 @@ static int tcp_receive_blocking(struct ipdbg_la_tcp *tcp, int received = 0; int error_count = 0; - /* Timeout after 500ms of not receiving data */ - /* increase timeout in case lab is not just beside the office */ + /* Timeout after 2s of not receiving data. */ + /* Increase timeout in case lab is not just beside the office. */ while ((received < bufsize) && (error_count < 2000)) { - int recd = ipdbg_la_tcp_receive(tcp, buf, bufsize-received); - if ( recd > 0 ) { + int recd = ipdbg_la_tcp_receive(tcp, buf, bufsize - received); + if (recd > 0) { buf += recd; received += recd; } else { error_count++; - g_usleep(1000); /* Sleep for 1ms */ + g_usleep(1000); } } @@ -339,8 +338,7 @@ SR_PRIV int ipdbg_la_receive_data(int fd, int revents, void *cb_data) } /* Send the trigger. */ - packet.type = SR_DF_TRIGGER; - sr_session_send(cb_data, &packet); + std_session_send_df_trigger(cb_data); /* Send post-trigger samples. */ packet.type = SR_DF_LOGIC; @@ -387,7 +385,7 @@ static int send_escaping(struct ipdbg_la_tcp *tcp, uint8_t *data_to_send, SR_PRIV int ipdbg_la_send_delay(struct dev_context *devc, struct ipdbg_la_tcp *tcp) { - devc->delay_value = (devc->limit_samples / 100.0) * devc->capture_ratio; + devc->delay_value = ((devc->limit_samples - 1) / 100.0) * devc->capture_ratio; uint8_t buf; buf = CMD_CFG_LA;