X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fgwinstek-gpd%2Fprotocol.c;h=6038c637ee9e751df3888723ae82d41111384478;hb=a5c0259c4ab9d3f7807e8d748551ae209ae69e4e;hp=827135e0f16a1c19071a046b5a9fb45d32799f80;hpb=b872ab7d301d7a8352b01bde8d6b9e8bde069129;p=libsigrok.git diff --git a/src/hardware/gwinstek-gpd/protocol.c b/src/hardware/gwinstek-gpd/protocol.c index 827135e0..6038c637 100644 --- a/src/hardware/gwinstek-gpd/protocol.c +++ b/src/hardware/gwinstek-gpd/protocol.c @@ -53,7 +53,7 @@ SR_PRIV int gpd_receive_reply(struct sr_serial_dev_inst *serial, char *buf, gint64 start, remaining; const int timeout_ms = 100; - if (!serial || (lines <= 0) || !buf || (buflen <= 0)) + if (!serial || !buf || (buflen <= 0)) return SR_ERR_ARG; start = g_get_monotonic_time(); @@ -118,7 +118,6 @@ SR_PRIV int gpd_receive_data(int fd, int revents, void *cb_data) serial = sdi->conn; if (revents == G_IO_IN) { - sr_dbg("%s(G_IO_IN)", __func__); if (!devc->reply_pending) { sr_err("No reply pending."); gpd_receive_reply(serial, reply, sizeof(reply)); @@ -127,6 +126,9 @@ SR_PRIV int gpd_receive_data(int fd, int revents, void *cb_data) g_free(reply_esc); } else { for (i = 0; i < devc->model->num_channels; i++) { + packet.type = SR_DF_ANALOG; + packet.payload = &analog; + reply[0] = '\0'; gpd_receive_reply(serial, reply, sizeof(reply)); if (sscanf(reply, "%f", &devc->config[i].output_voltage_max) != 1) { @@ -135,12 +137,8 @@ SR_PRIV int gpd_receive_data(int fd, int revents, void *cb_data) return TRUE; } - sr_analog_init(&analog, &encoding, &meaning, &spec, 0); - /* Send the value forward. */ - packet.type = SR_DF_ANALOG; - packet.payload = &analog; - + sr_analog_init(&analog, &encoding, &meaning, &spec, 0); analog.num_samples = 1; ch = g_slist_nth_data(sdi->channels, i); analog.meaning->channels = @@ -161,12 +159,8 @@ SR_PRIV int gpd_receive_data(int fd, int revents, void *cb_data) return TRUE; } - sr_analog_init(&analog, &encoding, &meaning, &spec, 0); - /* Send the value forward. */ - packet.type = SR_DF_ANALOG; - packet.payload = &analog; - + sr_analog_init(&analog, &encoding, &meaning, &spec, 0); analog.num_samples = 1; ch = g_slist_nth_data(sdi->channels, i); analog.meaning->channels = @@ -183,7 +177,6 @@ SR_PRIV int gpd_receive_data(int fd, int revents, void *cb_data) devc->reply_pending = FALSE; } } else { - sr_dbg("%s(TIMEOUT)", __func__); if (!devc->reply_pending) { for (i = 0; i < devc->model->num_channels; i++) gpd_send_cmd(serial, "IOUT%d?\nVOUT%d?\n",