]> sigrok.org Git - libsigrok.git/commitdiff
radioshack-dmm: (Trivial) Convenience fixes
authorAlexandru Gagniuc <redacted>
Tue, 16 Oct 2012 06:23:50 +0000 (01:23 -0500)
committerUwe Hermann <redacted>
Tue, 16 Oct 2012 09:16:41 +0000 (11:16 +0200)
While testing the new radioshack-dmm driver with pulseview, I found
a few inconvenients.

1. Print an info message when a port is probed, and when a device is
found. This makes it easy to tell if and where the driver is looking.

2. num_samples was not reset after the first aquisition, so the
second aquisition would quit right away. Reset num_samples at start
of a new aquisition.

3. There's no need to  open the serial port RW, so change O_RDWR to
O_RDONLY when opening the port.

These changes are too trivial to split into different patches.

Signed-off-by: Alexandru Gagniuc <redacted>
hardware/radioshack-dmm/api.c

index 912a3a9dc5b4dda2e37cc714e0b5440364ed54a0..62b3c0d11308631d56a679f4e0d3ea284f2e956c 100644 (file)
@@ -140,7 +140,7 @@ static GSList *rs_22_812_scan(const char *conn, const char *serialcomm)
        size_t len;
        char buf[128], *b;
 
        size_t len;
        char buf[128], *b;
 
-       if ((fd = serial_open(conn, O_RDWR|O_NONBLOCK)) == -1) {
+       if ((fd = serial_open(conn, O_RDONLY|O_NONBLOCK)) == -1) {
                sr_err("radioshack-dmm: unable to open %s: %s",
                       conn, strerror(errno));
                return NULL;
                sr_err("radioshack-dmm: unable to open %s: %s",
                       conn, strerror(errno));
                return NULL;
@@ -150,6 +150,8 @@ static GSList *rs_22_812_scan(const char *conn, const char *serialcomm)
                return NULL;
        }
 
                return NULL;
        }
 
+       sr_info("radioshack-dmm: probing port %s readonly", conn);
+
        drvc = di->priv;
        b = buf;
        retry = 0;
        drvc = di->priv;
        b = buf;
        retry = 0;
@@ -196,6 +198,8 @@ static GSList *rs_22_812_scan(const char *conn, const char *serialcomm)
                if (good_packets == 0)
                        continue;
 
                if (good_packets == 0)
                        continue;
 
+               sr_info("radioshack-dmm: found RS 22-812 on port %s", conn);
+
                if (!(sdi = sr_dev_inst_new(0, SR_ST_INACTIVE, "Radioshack",
                                            "22-812", "")))
                        return NULL;
                if (!(sdi = sr_dev_inst_new(0, SR_ST_INACTIVE, "Radioshack",
                                            "22-812", "")))
                        return NULL;
@@ -273,7 +277,7 @@ static int hw_dev_open(struct sr_dev_inst *sdi)
                return SR_ERR_BUG;
        }
 
                return SR_ERR_BUG;
        }
 
-       devc->serial->fd = serial_open(devc->serial->port, O_RDWR | O_NONBLOCK);
+       devc->serial->fd = serial_open(devc->serial->port, O_RDONLY);
        if (devc->serial->fd == -1) {
                sr_err("radioshack-dmm: Couldn't open serial port '%s'.",
                       devc->serial->port);
        if (devc->serial->fd == -1) {
                sr_err("radioshack-dmm: Couldn't open serial port '%s'.",
                       devc->serial->port);
@@ -383,6 +387,11 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
 
        devc->cb_data = cb_data;
 
 
        devc->cb_data = cb_data;
 
+       /* Reset the number of samples to take. If we've already collected our
+        * quota, but we start a new session, and don't reset this, we'll just
+        * quit without aquiring any new samples */
+       devc->num_samples = 0;
+
        /* Send header packet to the session bus. */
        sr_dbg("radioshack-dmm: Sending SR_DF_HEADER.");
        packet.type = SR_DF_HEADER;
        /* Send header packet to the session bus. */
        sr_dbg("radioshack-dmm: Sending SR_DF_HEADER.");
        packet.type = SR_DF_HEADER;