drivers/input: Remove some hardcoded values.
This commit is contained in:
parent
95c1fe62f7
commit
00ed77f27c
|
@ -61,7 +61,7 @@ static GSList *brymen_scan(struct sr_dev_driver *di, const char *conn,
|
||||||
goto scan_cleanup;
|
goto scan_cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = 128;
|
len = sizeof(buf);
|
||||||
ret = brymen_stream_detect(serial, buf, &len, brymen_packet_length,
|
ret = brymen_stream_detect(serial, buf, &len, brymen_packet_length,
|
||||||
brymen_packet_is_valid, 1000, 9600);
|
brymen_packet_is_valid, 1000, 9600);
|
||||||
if (ret != SR_OK)
|
if (ret != SR_OK)
|
||||||
|
|
|
@ -202,7 +202,7 @@ SR_PRIV int colead_slm_receive_data(int fd, int revents, void *cb_data)
|
||||||
|
|
||||||
serial = sdi->conn;
|
serial = sdi->conn;
|
||||||
if (devc->state == IDLE) {
|
if (devc->state == IDLE) {
|
||||||
if (serial_read_nonblocking(serial, buf, 128) != 1 || buf[0] != 0x10)
|
if (serial_read_nonblocking(serial, buf, sizeof(buf)) != 1 || buf[0] != 0x10)
|
||||||
/* Nothing there, or caught the tail end of a previous packet,
|
/* Nothing there, or caught the tail end of a previous packet,
|
||||||
* or some garbage. Unless it's a single "data ready" byte,
|
* or some garbage. Unless it's a single "data ready" byte,
|
||||||
* we don't want it. */
|
* we don't want it. */
|
||||||
|
|
|
@ -90,7 +90,7 @@ static GSList *fluke_scan(struct sr_dev_driver *di, const char *conn,
|
||||||
|
|
||||||
/* Response is first a CMD_ACK byte (ASCII '0' for OK,
|
/* Response is first a CMD_ACK byte (ASCII '0' for OK,
|
||||||
* or '1' to signify an error. */
|
* or '1' to signify an error. */
|
||||||
len = 128;
|
len = sizeof(buf);
|
||||||
serial_readline(serial, &b, &len, 150);
|
serial_readline(serial, &b, &len, 150);
|
||||||
if (len != 1)
|
if (len != 1)
|
||||||
continue;
|
continue;
|
||||||
|
@ -98,7 +98,7 @@ static GSList *fluke_scan(struct sr_dev_driver *di, const char *conn,
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* If CMD_ACK was OK, ID string follows. */
|
/* If CMD_ACK was OK, ID string follows. */
|
||||||
len = 128;
|
len = sizeof(buf);
|
||||||
serial_readline(serial, &b, &len, 850);
|
serial_readline(serial, &b, &len, 850);
|
||||||
if (len < 10)
|
if (len < 10)
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -56,7 +56,7 @@ static int init(struct sr_input *in, GHashTable *options)
|
||||||
inc->samplerate = g_variant_get_uint64(g_hash_table_lookup(options, "samplerate"));
|
inc->samplerate = g_variant_get_uint64(g_hash_table_lookup(options, "samplerate"));
|
||||||
|
|
||||||
for (i = 0; i < num_channels; i++) {
|
for (i = 0; i < num_channels; i++) {
|
||||||
snprintf(name, 16, "%d", i);
|
snprintf(name, sizeof(name), "%d", i);
|
||||||
sr_channel_new(in->sdi, i, SR_CHANNEL_LOGIC, TRUE, name);
|
sr_channel_new(in->sdi, i, SR_CHANNEL_LOGIC, TRUE, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ static int init(struct sr_input *in, GHashTable *options)
|
||||||
inc->samplerate = g_variant_get_uint64(g_hash_table_lookup(options, "samplerate"));
|
inc->samplerate = g_variant_get_uint64(g_hash_table_lookup(options, "samplerate"));
|
||||||
|
|
||||||
for (i = 0; i < num_channels; i++) {
|
for (i = 0; i < num_channels; i++) {
|
||||||
snprintf(name, 16, "%d", i);
|
snprintf(name, sizeof(name), "%d", i);
|
||||||
sr_channel_new(in->sdi, i, SR_CHANNEL_LOGIC, TRUE, name);
|
sr_channel_new(in->sdi, i, SR_CHANNEL_LOGIC, TRUE, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -291,13 +291,13 @@ static void create_channels(struct sr_input *in)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (channel = 0; channel < 16; channel++) {
|
for (channel = 0; channel < 16; channel++) {
|
||||||
snprintf(name, 8, "%c%d", get_pod_name_from_id(pod), channel);
|
snprintf(name, sizeof(name), "%c%d", get_pod_name_from_id(pod), channel);
|
||||||
inc->channels[pod][channel] =
|
inc->channels[pod][channel] =
|
||||||
sr_channel_new(in->sdi, chan_id, SR_CHANNEL_LOGIC, TRUE, name);
|
sr_channel_new(in->sdi, chan_id, SR_CHANNEL_LOGIC, TRUE, name);
|
||||||
chan_id++;
|
chan_id++;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(name, 8, "CLK%c", get_pod_name_from_id(pod));
|
snprintf(name, sizeof(name), "CLK%c", get_pod_name_from_id(pod));
|
||||||
inc->channels[pod][16] =
|
inc->channels[pod][16] =
|
||||||
sr_channel_new(in->sdi, chan_id, SR_CHANNEL_LOGIC, TRUE, name);
|
sr_channel_new(in->sdi, chan_id, SR_CHANNEL_LOGIC, TRUE, name);
|
||||||
chan_id++;
|
chan_id++;
|
||||||
|
|
|
@ -331,7 +331,7 @@ static int receive(struct sr_input *in, GString *buf)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
for (int i = 0; i < inc->num_channels; i++) {
|
for (int i = 0; i < inc->num_channels; i++) {
|
||||||
snprintf(channelname, 8, "CH%d", i + 1);
|
snprintf(channelname, sizeof(channelname), "CH%d", i + 1);
|
||||||
sr_channel_new(in->sdi, i, SR_CHANNEL_ANALOG, TRUE, channelname);
|
sr_channel_new(in->sdi, i, SR_CHANNEL_ANALOG, TRUE, channelname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,7 @@ static gboolean stream_session_data(struct sr_dev_inst *sdi)
|
||||||
sr_dbg("Opened %s.", vdev->capturefile);
|
sr_dbg("Opened %s.", vdev->capturefile);
|
||||||
} else {
|
} else {
|
||||||
/* Try as first chunk filename. */
|
/* Try as first chunk filename. */
|
||||||
snprintf(capturefile, 15, "%s-1", vdev->capturefile);
|
snprintf(capturefile, sizeof(capturefile) - 1, "%s-1", vdev->capturefile);
|
||||||
if (zip_stat(vdev->archive, capturefile, 0, &zs) != -1) {
|
if (zip_stat(vdev->archive, capturefile, 0, &zs) != -1) {
|
||||||
vdev->cur_chunk = 1;
|
vdev->cur_chunk = 1;
|
||||||
if (!(vdev->capfile = zip_fopen(vdev->archive,
|
if (!(vdev->capfile = zip_fopen(vdev->archive,
|
||||||
|
@ -108,7 +108,7 @@ static gboolean stream_session_data(struct sr_dev_inst *sdi)
|
||||||
} else {
|
} else {
|
||||||
/* Capture data is chunked, advance to the next chunk. */
|
/* Capture data is chunked, advance to the next chunk. */
|
||||||
vdev->cur_chunk++;
|
vdev->cur_chunk++;
|
||||||
snprintf(capturefile, 15, "%s-%d", vdev->capturefile,
|
snprintf(capturefile, sizeof(capturefile) - 1, "%s-%d", vdev->capturefile,
|
||||||
vdev->cur_chunk);
|
vdev->cur_chunk);
|
||||||
if (zip_stat(vdev->archive, capturefile, 0, &zs) != -1) {
|
if (zip_stat(vdev->archive, capturefile, 0, &zs) != -1) {
|
||||||
if (!(vdev->capfile = zip_fopen(vdev->archive,
|
if (!(vdev->capfile = zip_fopen(vdev->archive,
|
||||||
|
|
Loading…
Reference in New Issue