]> sigrok.org Git - libsigrok.git/blobdiff - hardware/openbench-logic-sniffer/ols.c
Start moving private stuff to sigrok-internal.h.
[libsigrok.git] / hardware / openbench-logic-sniffer / ols.c
index 7f44788e4a012d2a2742aaaaee894dffdc0f13c6..582a258c9b881abc3d7f427dc554028dae082232 100644 (file)
 #endif
 #include <glib.h>
 #include <sigrok.h>
+#include <sigrok-internal.h>
+
+#ifdef _WIN32
+#define O_NONBLOCK FIONBIO
+#endif
 
 #define NUM_PROBES                     32
 #define NUM_TRIGGER_STAGES             4
@@ -115,7 +120,7 @@ static int send_shortcommand(int fd, uint8_t command)
 
        g_debug("ols: sending cmd 0x%.2x", command);
        buf[0] = command;
-       if (write(fd, buf, 1) != 1)
+       if (serial_write(fd, buf, 1) != 1)
                return SIGROK_ERR;
 
        return SIGROK_OK;
@@ -131,7 +136,7 @@ static int send_longcommand(int fd, uint8_t command, uint32_t data)
        buf[2] = (data & 0xff0000) >> 16;
        buf[3] = (data & 0xff00) >> 8;
        buf[4] = data & 0xff;
-       if (write(fd, buf, 5) != 5)
+       if (serial_write(fd, buf, 5) != 5)
                return SIGROK_ERR;
 
        return SIGROK_OK;
@@ -276,7 +281,7 @@ static int hw_init(char *deviceinfo)
        g_poll(fds, devcnt, 1);
        for (i = 0; i < devcnt; i++) {
                if (fds[i].revents == G_IO_IN) {
-                       if (read(fds[i].fd, buf, 4) == 4) {
+                       if (serial_read(fds[i].fd, buf, 4) == 4) {
                                if (!strncmp(buf, "1SLO", 4)
                                    || !strncmp(buf, "1ALS", 4)) {
                                        if (!strncmp(buf, "1SLO", 4))
@@ -511,7 +516,7 @@ static int receive_data(int fd, int revents, void *user_data)
 
        if (revents == G_IO_IN
            && num_transfers / num_channels <= limit_samples) {
-               if (read(fd, &byte, 1) != 1)
+               if (serial_read(fd, &byte, 1) != 1)
                        return FALSE;
 
                sample[num_bytes++] = byte;
@@ -773,7 +778,7 @@ static void hw_stop_acquisition(int device_index, gpointer session_device_id)
 {
        struct datafeed_packet packet;
 
-       /* QUICK HACK */
+       /* Avoid compiler warnings. */
        device_index = device_index;
 
        packet.type = DF_END;