]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/hameg-hmo/protocol.c
hameg-hmo: Get SCPI_CMD_GET_HORIZONTAL_DIV at runtime.
[libsigrok.git] / src / hardware / hameg-hmo / protocol.c
index 9135601c73f905010c04f3a6b932910ba0eff3f4..167c1a4fe5e9960d4f1a0df91e76c20ef9209857 100644 (file)
@@ -34,6 +34,7 @@ static const char *hameg_scpi_dialect[] = {
        [SCPI_CMD_GET_DIG_DATA]               = ":FORM UINT,8;:POD%d:DATA?",
        [SCPI_CMD_GET_TIMEBASE]               = ":TIM:SCAL?",
        [SCPI_CMD_SET_TIMEBASE]               = ":TIM:SCAL %s",
+       [SCPI_CMD_GET_HORIZONTAL_DIV]         = ":TIM:DIV?",
        [SCPI_CMD_GET_COUPLING]               = ":CHAN%d:COUP?",
        [SCPI_CMD_SET_COUPLING]               = ":CHAN%d:COUP %s",
        [SCPI_CMD_GET_SAMPLE_RATE]            = ":ACQ:SRAT?",
@@ -71,6 +72,7 @@ static const char *rohde_schwarz_log_not_pod_scpi_dialect[] = {
        [SCPI_CMD_GET_DIG_DATA]               = ":FORM UINT,8;:LOG%d:DATA?",
        [SCPI_CMD_GET_TIMEBASE]               = ":TIM:SCAL?",
        [SCPI_CMD_SET_TIMEBASE]               = ":TIM:SCAL %s",
+       [SCPI_CMD_GET_HORIZONTAL_DIV]         = ":TIM:DIV?",
        [SCPI_CMD_GET_COUPLING]               = ":CHAN%d:COUP?",
        [SCPI_CMD_SET_COUPLING]               = ":CHAN%d:COUP %s",
        [SCPI_CMD_GET_SAMPLE_RATE]            = ":ACQ:SRAT?",
@@ -364,7 +366,6 @@ static struct scope_config scope_models[] = {
                .vdivs = &vdivs,
                .num_vdivs = ARRAY_SIZE(vdivs),
 
-               .num_xdivs = 12,
                .num_ydivs = 8,
 
                .scpi_dialect = &hameg_scpi_dialect,
@@ -406,7 +407,6 @@ static struct scope_config scope_models[] = {
                .vdivs = &vdivs,
                .num_vdivs = ARRAY_SIZE(vdivs),
 
-               .num_xdivs = 12,
                .num_ydivs = 8,
 
                .scpi_dialect = &hameg_scpi_dialect,
@@ -448,7 +448,6 @@ static struct scope_config scope_models[] = {
                .vdivs = &vdivs,
                .num_vdivs = ARRAY_SIZE(vdivs),
 
-               .num_xdivs = 12,
                .num_ydivs = 8,
 
                .scpi_dialect = &hameg_scpi_dialect,
@@ -490,7 +489,6 @@ static struct scope_config scope_models[] = {
                .vdivs = &vdivs,
                .num_vdivs = ARRAY_SIZE(vdivs),
 
-               .num_xdivs = 12,
                .num_ydivs = 8,
 
                .scpi_dialect = &hameg_scpi_dialect,
@@ -531,7 +529,6 @@ static struct scope_config scope_models[] = {
                .vdivs = &vdivs,
                .num_vdivs = ARRAY_SIZE(vdivs),
 
-               .num_xdivs = 12,
                .num_ydivs = 8,
 
                .scpi_dialect = &hameg_scpi_dialect,
@@ -572,7 +569,6 @@ static struct scope_config scope_models[] = {
                .vdivs = &vdivs,
                .num_vdivs = ARRAY_SIZE(vdivs),
 
-               .num_xdivs = 12,
                .num_ydivs = 8,
 
                .scpi_dialect = &rohde_schwarz_log_not_pod_scpi_dialect,
@@ -613,7 +609,6 @@ static struct scope_config scope_models[] = {
                .vdivs = &vdivs,
                .num_vdivs = ARRAY_SIZE(vdivs),
 
-               .num_xdivs = 12,
                .num_ydivs = 8,
 
                .scpi_dialect = &rohde_schwarz_log_not_pod_scpi_dialect,
@@ -654,7 +649,6 @@ static struct scope_config scope_models[] = {
                .vdivs = &vdivs,
                .num_vdivs = ARRAY_SIZE(vdivs),
 
-               .num_xdivs = 12,
                .num_ydivs = 8,
 
                .scpi_dialect = &rohde_schwarz_log_not_pod_scpi_dialect,
@@ -695,7 +689,6 @@ static struct scope_config scope_models[] = {
                .vdivs = &vdivs,
                .num_vdivs = ARRAY_SIZE(vdivs),
 
-               .num_xdivs = 12,
                .num_ydivs = 8,
 
                .scpi_dialect = &rohde_schwarz_log_not_pod_scpi_dialect,
@@ -736,7 +729,6 @@ static struct scope_config scope_models[] = {
                .vdivs = &vdivs,
                .num_vdivs = ARRAY_SIZE(vdivs),
 
-               .num_xdivs = 12,
                .num_ydivs = 8,
 
                .scpi_dialect = &rohde_schwarz_log_not_pod_scpi_dialect,
@@ -1091,6 +1083,12 @@ SR_PRIV int hmo_scope_state_get(struct sr_dev_inst *sdi)
 
        state->timebase = i;
 
+       /* Determine the number of horizontal (x) divisions. */
+       if (sr_scpi_get_int(sdi->conn,
+           (*config->scpi_dialect)[SCPI_CMD_GET_HORIZONTAL_DIV],
+           (int *)&config->num_xdivs) != SR_OK)
+               return SR_ERR;
+
        if (sr_scpi_get_float(sdi->conn,
                        (*config->scpi_dialect)[SCPI_CMD_GET_HORIZ_TRIGGERPOS],
                        &tmp_float) != SR_OK)
@@ -1182,6 +1180,7 @@ SR_PRIV int hmo_init_device(struct sr_dev_inst *sdi)
                sr_dbg("Unsupported device.");
                return SR_ERR_NA;
        }
+
        /* Configure the number of PODs given the number of digital channels. */
        scope_models[model_index].digital_pods = scope_models[model_index].digital_channels / DIGITAL_CHANNELS_PER_POD;