Skip to content

Commit 3147a7f

Browse files
fenugrecgsigh
authored andcommitted
siglent-sds: reduce indentation
[ see a word diff for review ]
1 parent dbb6d86 commit 3147a7f

File tree

1 file changed

+60
-60
lines changed

1 file changed

+60
-60
lines changed

src/hardware/siglent-sds/protocol.c

Lines changed: 60 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -364,71 +364,71 @@ static int siglent_sds_get_digital(const struct sr_dev_inst *sdi, struct sr_chan
364364
for (l = sdi->channels; l; l = l->next) {
365365
ch = l->data;
366366
samples_index = 0;
367-
if (ch->type == SR_CHANNEL_LOGIC) {
368-
if (ch->enabled) {
369-
if (sr_scpi_send(sdi->conn, "D%d:WF? DAT2", ch->index) != SR_OK)
370-
return SR_ERR;
371-
if (sr_scpi_read_begin(scpi) != SR_OK)
372-
return TRUE;
373-
len = sr_scpi_read_data(scpi, buf, -1);
374-
if (len < 0)
375-
return TRUE;
376-
len -= 15;
377-
buffdata = g_array_sized_new(FALSE, FALSE, sizeof(uint8_t), len);
378-
buf += 15; /* Skipping the data header. */
379-
g_array_append_vals(buffdata, buf, len);
380-
tmp_samplebuf = g_array_sized_new(FALSE, FALSE, sizeof(uint8_t), len); /* New temp buffer. */
381-
for (uint64_t cur_sample_index = 0; cur_sample_index < devc->memory_depth_digital; cur_sample_index++) {
382-
char sample = (char)g_array_index(buffdata, uint8_t, cur_sample_index);
383-
for (int ii = 0; ii < 8; ii++, sample >>= 1) {
384-
if (ch->index < 8) {
385-
channel_index = ch->index;
386-
if (data_low_channels->len <= samples_index) {
387-
tmp_value = 0; /* New sample. */
388-
low_channels = TRUE; /* We have at least one enabled low channel. */
389-
} else {
390-
/* Get previous stored sample from low channel buffer. */
391-
tmp_value = g_array_index(data_low_channels, uint8_t, samples_index);
392-
}
393-
} else {
394-
channel_index = ch->index - 8;
395-
if (data_high_channels->len <= samples_index) {
396-
tmp_value = 0; /* New sample. */
397-
high_channels = TRUE; /* We have at least one enabled high channel. */
398-
} else {
399-
/* Get previous stored sample from high channel buffer. */
400-
tmp_value = g_array_index(data_high_channels, uint8_t, samples_index);
401-
}
402-
}
403-
/* Check if the current scope sample bit is set. */
404-
if (sample & 0x1)
405-
tmp_value |= 1UL << channel_index; /* Set current scope sample bit based on channel index. */
406-
g_array_append_val(tmp_samplebuf, tmp_value);
407-
samples_index++;
408-
}
409-
}
410-
411-
/* Clear the buffers to prepare for the new samples */
367+
if (ch->type != SR_CHANNEL_LOGIC)
368+
continue;
369+
if (!ch->enabled)
370+
continue;
371+
if (sr_scpi_send(sdi->conn, "D%d:WF? DAT2", ch->index) != SR_OK)
372+
return SR_ERR;
373+
if (sr_scpi_read_begin(scpi) != SR_OK)
374+
return TRUE;
375+
len = sr_scpi_read_data(scpi, buf, -1);
376+
if (len < 0)
377+
return TRUE;
378+
len -= 15;
379+
buffdata = g_array_sized_new(FALSE, FALSE, sizeof(uint8_t), len);
380+
buf += 15; /* Skipping the data header. */
381+
g_array_append_vals(buffdata, buf, len);
382+
tmp_samplebuf = g_array_sized_new(FALSE, FALSE, sizeof(uint8_t), len); /* New temp buffer. */
383+
for (uint64_t cur_sample_index = 0; cur_sample_index < devc->memory_depth_digital; cur_sample_index++) {
384+
char sample = (char)g_array_index(buffdata, uint8_t, cur_sample_index);
385+
for (int ii = 0; ii < 8; ii++, sample >>= 1) {
412386
if (ch->index < 8) {
413-
g_array_free(data_low_channels, FALSE);
414-
data_low_channels = g_array_new(FALSE, FALSE, sizeof(uint8_t));
387+
channel_index = ch->index;
388+
if (data_low_channels->len <= samples_index) {
389+
tmp_value = 0; /* New sample. */
390+
low_channels = TRUE; /* We have at least one enabled low channel. */
391+
} else {
392+
/* Get previous stored sample from low channel buffer. */
393+
tmp_value = g_array_index(data_low_channels, uint8_t, samples_index);
394+
}
415395
} else {
416-
g_array_free(data_high_channels, FALSE);
417-
data_high_channels = g_array_new(FALSE, FALSE, sizeof(uint8_t));
418-
}
419-
420-
/* Storing the converted temp values from the the scope into the buffers. */
421-
for (uint64_t index = 0; index < tmp_samplebuf->len; index++) {
422-
uint8_t value = g_array_index(tmp_samplebuf, uint8_t, index);
423-
if (ch->index < 8)
424-
g_array_append_val(data_low_channels, value);
425-
else
426-
g_array_append_val(data_high_channels, value);
396+
channel_index = ch->index - 8;
397+
if (data_high_channels->len <= samples_index) {
398+
tmp_value = 0; /* New sample. */
399+
high_channels = TRUE; /* We have at least one enabled high channel. */
400+
} else {
401+
/* Get previous stored sample from high channel buffer. */
402+
tmp_value = g_array_index(data_high_channels, uint8_t, samples_index);
403+
}
427404
}
428-
g_array_free(tmp_samplebuf, TRUE);
429-
g_array_free(buffdata, TRUE);
405+
/* Check if the current scope sample bit is set. */
406+
if (sample & 0x1)
407+
tmp_value |= 1UL << channel_index; /* Set current scope sample bit based on channel index. */
408+
g_array_append_val(tmp_samplebuf, tmp_value);
409+
samples_index++;
430410
}
431411
}
412+
413+
/* Clear the buffers to prepare for the new samples */
414+
if (ch->index < 8) {
415+
g_array_free(data_low_channels, FALSE);
416+
data_low_channels = g_array_new(FALSE, FALSE, sizeof(uint8_t));
417+
} else {
418+
g_array_free(data_high_channels, FALSE);
419+
data_high_channels = g_array_new(FALSE, FALSE, sizeof(uint8_t));
420+
}
421+
422+
/* Storing the converted temp values from the the scope into the buffers. */
423+
for (uint64_t index = 0; index < tmp_samplebuf->len; index++) {
424+
uint8_t value = g_array_index(tmp_samplebuf, uint8_t, index);
425+
if (ch->index < 8)
426+
g_array_append_val(data_low_channels, value);
427+
else
428+
g_array_append_val(data_high_channels, value);
429+
}
430+
g_array_free(tmp_samplebuf, TRUE);
431+
g_array_free(buffdata, TRUE);
432432
}
433433

434434
/* Combining the lower and higher channel buffers into one buffer for sigrok. */

0 commit comments

Comments
 (0)