]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/hameg-hmo/protocol.c
analog: Implement multiplication for sr_rational
[libsigrok.git] / src / hardware / hameg-hmo / protocol.c
index 60731ec46574a35f98f3594d96b523039e55a0a4..47d87528c37932b6276f2cbd347f7a43cb149294 100644 (file)
@@ -78,6 +78,7 @@ static const char *hmo_coupling_options[] = {
 static const char *scope_trigger_slopes[] = {
        "POS",
        "NEG",
+       "EITH",
        NULL,
 };
 
@@ -86,6 +87,9 @@ static const char *hmo_compact2_trigger_sources[] = {
        "CH2",
        "LINE",
        "EXT",
+       "PATT",
+       "BUS1",
+       "BUS2",
        "D0",
        "D1",
        "D2",
@@ -104,6 +108,9 @@ static const char *hmo_compact4_trigger_sources[] = {
        "CH4",
        "LINE",
        "EXT",
+       "PATT",
+       "BUS1",
+       "BUS2",
        "D0",
        "D1",
        "D2",
@@ -203,7 +210,7 @@ static const char *scope_digital_channel_names[] = {
 static const struct scope_config scope_models[] = {
        {
                /* HMO2522/3032/3042/3052 support 16 digital channels but they're not supported yet. */
-               .name = {"HMO722", "HMO1022", "HMO1522", "HMO2022", "HMO2522",
+               .name = {"HMO1002", "HMO722", "HMO1022", "HMO1522", "HMO2022", "HMO2522",
                                "HMO3032", "HMO3042", "HMO3052", NULL},
                .analog_channels = 2,
                .digital_channels = 8,
@@ -355,7 +362,8 @@ static int scope_state_get_array_option(struct sr_scpi_dev_inst *scpi,
 static int array_float_get(gchar *value, const uint64_t array[][2],
                int array_len, unsigned int *result)
 {
-       int i, pos, e;
+       int i, e;
+       size_t pos;
        uint64_t f;
        float s;
        unsigned int s_int;
@@ -365,8 +373,7 @@ static int array_float_get(gchar *value, const uint64_t array[][2],
        memset(es, 0, sizeof(es));
 
        /* Get index of the separating 'E' character and break up the string. */
-       pos = (int)g_strstr_len(value, strlen(value), "E");
-       pos -= (int)value;
+       pos = strcspn(value, "E");
 
        strncpy(ss, value, pos);
        strncpy(es, &(value[pos+1]), 3);
@@ -733,6 +740,7 @@ SR_PRIV int hmo_receive_data(int fd, int revents, void *cb_data)
        struct sr_datafeed_logic logic;
 
        (void)fd;
+       (void)revents;
 
        data = NULL;
 
@@ -742,8 +750,12 @@ SR_PRIV int hmo_receive_data(int fd, int revents, void *cb_data)
        if (!(devc = sdi->priv))
                return TRUE;
 
+       /* Although this is correct in general, the USBTMC libusb implementation
+        * currently does not generate an event prior to the first read. Often
+        * it is ok to start reading just after the 50ms timeout. See bug #785.
        if (revents != G_IO_IN)
                return TRUE;
+       */
 
        ch = devc->current_channel->data;
 
@@ -767,7 +779,7 @@ SR_PRIV int hmo_receive_data(int fd, int revents, void *cb_data)
                analog.mqflags = 0;
                packet.type = SR_DF_ANALOG_OLD;
                packet.payload = &analog;
-               sr_session_send(cb_data, &packet);
+               sr_session_send(sdi, &packet);
                g_slist_free(analog.channels);
                g_array_free(data, TRUE);
                data = NULL;
@@ -786,7 +798,7 @@ SR_PRIV int hmo_receive_data(int fd, int revents, void *cb_data)
                logic.data = data->data;
                packet.type = SR_DF_LOGIC;
                packet.payload = &logic;
-               sr_session_send(cb_data, &packet);
+               sr_session_send(sdi, &packet);
                g_array_free(data, TRUE);
                data = NULL;
                break;
@@ -802,7 +814,7 @@ SR_PRIV int hmo_receive_data(int fd, int revents, void *cb_data)
                devc->current_channel = devc->current_channel->next;
                hmo_request_data(sdi);
        } else if (++devc->num_frames == devc->frame_limit) {
-               sdi->driver->dev_acquisition_stop(sdi, cb_data);
+               sdi->driver->dev_acquisition_stop(sdi);
        } else {
                devc->current_channel = devc->enabled_channels;
                hmo_request_data(sdi);