]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/ipdbg-la/protocol.c
ipdbg-la: data_available(): Return gboolean.
[libsigrok.git] / src / hardware / ipdbg-la / protocol.c
index 1f7d349f7e8e5cec348d8079f41700ecdadfaf60..69c461ff6fa06d5f6995ef2f89b13cc135c324e7 100644 (file)
@@ -68,7 +68,7 @@
 /* LA subfunction command opcodes */
 #define CMD_LA_DELAY               0x1F
 
-SR_PRIV int data_available(struct ipdbg_la_tcp *tcp)
+SR_PRIV gboolean data_available(struct ipdbg_la_tcp *tcp)
 {
 #ifdef __WIN32__
        ioctlsocket(tcp->socket, FIONREAD, &bytes_available);
@@ -76,11 +76,11 @@ SR_PRIV int data_available(struct ipdbg_la_tcp *tcp)
        int status;
 
        if (ioctl(tcp->socket, FIONREAD, &status) < 0) {        // TIOCMGET
-               sr_err("FIONREAD failed: %s\n", strerror(errno));
-               return 0;
+               sr_err("FIONREAD failed: %s\n", g_strerror(errno));
+               return FALSE;
        }
 
-       return (status < 1) ? 0 : 1;
+       return (status < 1) ? FALSE : TRUE;
 #endif  // __WIN32__
 }
 
@@ -89,7 +89,6 @@ SR_PRIV struct ipdbg_la_tcp *ipdbg_la_tcp_new(void)
        struct ipdbg_la_tcp *tcp;
 
        tcp = g_malloc0(sizeof(struct ipdbg_la_tcp));
-
        tcp->address = NULL;
        tcp->port = NULL;
        tcp->socket = -1;
@@ -217,7 +216,7 @@ SR_PRIV int ipdbg_la_tcp_receive(struct ipdbg_la_tcp *tcp,
 
 SR_PRIV int ipdbg_la_convert_trigger(const struct sr_dev_inst *sdi)
 {
-       struct ipdbg_la_dev_context *devc;
+       struct dev_context *devc;
        struct sr_trigger *trigger;
        struct sr_trigger_stage *stage;
        struct sr_trigger_match *match;
@@ -288,7 +287,7 @@ SR_PRIV int ipdbg_la_convert_trigger(const struct sr_dev_inst *sdi)
 SR_PRIV int ipdbg_la_receive_data(int fd, int revents, void *cb_data)
 {
        const struct sr_dev_inst *sdi;
-       struct ipdbg_la_dev_context *devc;
+       struct dev_context *devc;
 
        (void)fd;
        (void)revents;
@@ -308,7 +307,7 @@ SR_PRIV int ipdbg_la_receive_data(int fd, int revents, void *cb_data)
                devc->raw_sample_buf =
                        g_try_malloc(devc->limit_samples * devc->DATA_WIDTH_BYTES);
                if (!devc->raw_sample_buf) {
-                       sr_warn("Sample buffer malloc failed.");
+                       sr_err("Sample buffer malloc failed.");
                        return FALSE;
                }
        }
@@ -358,7 +357,7 @@ SR_PRIV int ipdbg_la_receive_data(int fd, int revents, void *cb_data)
        return TRUE;
 }
 
-SR_PRIV int ipdbg_la_send_delay(struct ipdbg_la_dev_context *devc,
+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;
@@ -381,7 +380,7 @@ SR_PRIV int ipdbg_la_send_delay(struct ipdbg_la_dev_context *devc,
        return SR_OK;
 }
 
-SR_PRIV int ipdbg_la_send_trigger(struct ipdbg_la_dev_context *devc,
+SR_PRIV int ipdbg_la_send_trigger(struct dev_context *devc,
        struct ipdbg_la_tcp *tcp)
 {
        uint8_t buf;
@@ -473,7 +472,7 @@ SR_PRIV int send_escaping(struct ipdbg_la_tcp *tcp, uint8_t *dataToSend,
 }
 
 SR_PRIV void ipdbg_la_get_addrwidth_and_datawidth(
-       struct ipdbg_la_tcp *tcp, struct ipdbg_la_dev_context *devc)
+       struct ipdbg_la_tcp *tcp, struct dev_context *devc)
 {
        uint8_t buf[8];
        uint8_t read_cmd = CMD_GET_BUS_WIDTHS;
@@ -511,11 +510,11 @@ SR_PRIV void ipdbg_la_get_addrwidth_and_datawidth(
        devc->trigger_edge_mask = g_malloc0(devc->DATA_WIDTH_BYTES);
 }
 
-SR_PRIV struct ipdbg_la_dev_context *ipdbg_la_dev_new(void)
+SR_PRIV struct dev_context *ipdbg_la_dev_new(void)
 {
-       struct ipdbg_la_dev_context *devc;
+       struct dev_context *devc;
 
-       devc = g_malloc0(sizeof(struct ipdbg_la_dev_context));
+       devc = g_malloc0(sizeof(struct dev_context));
        devc->capture_ratio = 50;
 
        return devc;