const char *conn, const char *serialcomm)
{
struct sr_serial_dev_inst *serial;
- GSList *devices = NULL;
- struct dev_context *devc = NULL;
- struct sr_dev_inst *sdi = NULL;
+ GSList *devices;
+ struct dev_context *devc;
+ struct sr_dev_inst *sdi;
+ size_t i;
serial = sr_serial_dev_inst_new(conn, serialcomm);
if (serial_open(serial, SERIAL_RDWR) != SR_OK)
sdi->conn = serial;
sdi->priv = devc;
- for (int i = 0; devc->channels[i].name; i++)
- sr_channel_new(sdi, i, SR_CHANNEL_ANALOG, TRUE, devc->channels[i].name);
+ for (i = 0; devc->channels[i].name; i++) {
+ sr_channel_new(sdi, i, SR_CHANNEL_ANALOG, TRUE,
+ devc->channels[i].name);
+ }
- devices = g_slist_append(devices, sdi);
+ devices = g_slist_append(NULL, sdi);
serial_close(serial);
if (!devices)
sr_serial_dev_inst_free(serial);
static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
struct sr_config *src;
- const char *conn = NULL;
- const char *serialcomm = RDTECH_TC_SERIALCOMM;
+ const char *conn;
+ const char *serialcomm;
+ conn = NULL;
+ serialcomm = RDTECH_TC_SERIALCOMM;
for (GSList *l = options; l; l = l->next) {
src = l->data;
switch (src->key) {
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
- struct dev_context *devc = sdi->priv;
- struct sr_serial_dev_inst *serial = sdi->conn;
+ struct dev_context *devc;
+ struct sr_serial_dev_inst *serial;
+ devc = sdi->priv;
sr_sw_limits_acquisition_start(&devc->limits);
std_session_send_df_header(sdi);
+ serial = sdi->conn;
serial_source_add(sdi->session, serial, G_IO_IN, 50,
rdtech_tc_receive_data, (void *)sdi);
SR_PRIV int rdtech_tc_poll(const struct sr_dev_inst *sdi)
{
- struct dev_context *devc = sdi->priv;
- struct sr_serial_dev_inst *serial = sdi->conn;
+ struct dev_context *devc;
+ struct sr_serial_dev_inst *serial;
+ serial = sdi->conn;
if (serial_write_blocking(serial, poll_cmd, strlen(poll_cmd),
SERIAL_WRITE_TIMEOUT_MS) < 0) {
sr_err("Unable to send poll request.");
return SR_ERR;
}
+ devc = sdi->priv;
devc->cmd_sent_at = g_get_monotonic_time() / 1000;
return SR_OK;
static void handle_poll_data(const struct sr_dev_inst *sdi)
{
- struct dev_context *devc = sdi->priv;
+ struct dev_context *devc;
uint8_t poll_pkt[TC_POLL_LEN];
int i;
GSList *ch;
+ devc = sdi->priv;
sr_spew("Received poll packet (len: %d).", devc->buflen);
if (devc->buflen != TC_POLL_LEN) {
sr_err("Unexpected poll packet length: %i", devc->buflen);
static void recv_poll_data(struct sr_dev_inst *sdi, struct sr_serial_dev_inst *serial)
{
- struct dev_context *devc = sdi->priv;
+ struct dev_context *devc;
int len;
/* Serial data arrived. */
+ devc = sdi->priv;
while (devc->buflen < TC_POLL_LEN) {
len = serial_read_nonblocking(serial, devc->buf + devc->buflen, 1);
if (len < 1)
if (!(sdi = cb_data))
return TRUE;
-
if (!(devc = sdi->priv))
return TRUE;
now = g_get_monotonic_time() / 1000;
elapsed = now - devc->cmd_sent_at;
-
if (elapsed > TC_POLL_PERIOD_MS)
rdtech_tc_poll(sdi);