]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/hameg-hmo/protocol.c
Simplify channel creation.
[libsigrok.git] / src / hardware / hameg-hmo / protocol.c
index 6f5c0500f00413f5e7d4163db224ac8e7ea4d573..783c3ebc26399f5d9211f1c92567900f07bd65f7 100644 (file)
@@ -50,7 +50,7 @@ static const uint32_t hmo_devopts[] = {
        SR_CONF_LIMIT_FRAMES | SR_CONF_GET | SR_CONF_SET,
        SR_CONF_TRIGGER_SOURCE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
        SR_CONF_TIMEBASE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
-       SR_CONF_NUM_TIMEBASE | SR_CONF_GET,
+       SR_CONF_NUM_HDIV | SR_CONF_GET,
        SR_CONF_TRIGGER_SLOPE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
        SR_CONF_HORIZ_TRIGGERPOS | SR_CONF_GET | SR_CONF_SET,
        SR_CONF_SAMPLERATE | SR_CONF_GET,
@@ -616,9 +616,8 @@ SR_PRIV int hmo_init_device(struct sr_dev_inst *sdi)
 
        /* Add analog channels. */
        for (i = 0; i < scope_models[model_index].analog_channels; i++) {
-               ch = sr_channel_new(i, SR_CHANNEL_ANALOG, TRUE,
+               ch = sr_channel_new(sdi, i, SR_CHANNEL_ANALOG, TRUE,
                           (*scope_models[model_index].analog_names)[i]);
-               sdi->channels = g_slist_append(sdi->channels, ch);
 
                devc->analog_groups[i] = g_malloc0(sizeof(struct sr_channel_group));
 
@@ -643,9 +642,8 @@ SR_PRIV int hmo_init_device(struct sr_dev_inst *sdi)
 
        /* Add digital channels. */
        for (i = 0; i < scope_models[model_index].digital_channels; i++) {
-               ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE,
+               ch = sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE,
                           (*scope_models[model_index].digital_names)[i]);
-               sdi->channels = g_slist_append(sdi->channels, ch);
 
                devc->digital_groups[i < 8 ? 0 : 1]->channels = g_slist_append(
                        devc->digital_groups[i < 8 ? 0 : 1]->channels, ch);
@@ -672,6 +670,8 @@ SR_PRIV int hmo_receive_data(int fd, int revents, void *cb_data)
 
        (void)fd;
 
+       data = NULL;
+
        if (!(sdi = cb_data))
                return TRUE;
 
@@ -704,6 +704,7 @@ SR_PRIV int hmo_receive_data(int fd, int revents, void *cb_data)
                        sr_session_send(cb_data, &packet);
                        g_slist_free(analog.channels);
                        g_array_free(data, TRUE);
+                       data = NULL;
                        break;
                case SR_CHANNEL_LOGIC:
                        if (sr_scpi_get_uint8v(sdi->conn, NULL, &data) != SR_OK) {
@@ -722,6 +723,7 @@ SR_PRIV int hmo_receive_data(int fd, int revents, void *cb_data)
                        packet.payload = &logic;
                        sr_session_send(cb_data, &packet);
                        g_array_free(data, TRUE);
+                       data = NULL;
                        break;
                default:
                        sr_err("Invalid channel type.");