X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Flecroy-xstream%2Fprotocol.c;h=9693c6d3404546c27ec4a216197cfb1f78e08146;hb=d7a4dad881bf;hp=591f708012d5555524b72f7cfae943ce7671ce04;hpb=d8fb599c679a6da64f28bcafce514558b786b6c7;p=libsigrok.git diff --git a/src/hardware/lecroy-xstream/protocol.c b/src/hardware/lecroy-xstream/protocol.c index 591f7080..9693c6d3 100644 --- a/src/hardware/lecroy-xstream/protocol.c +++ b/src/hardware/lecroy-xstream/protocol.c @@ -92,11 +92,11 @@ static const char *trigger_sources[] = { static const uint64_t timebases[][2] = { /* picoseconds */ - { 20, 1000000000000 }, - { 50, 1000000000000 }, - { 100, 1000000000000 }, - { 200, 1000000000000 }, - { 500, 1000000000000 }, + { 20, UINT64_C(1000000000000) }, + { 50, UINT64_C(1000000000000) }, + { 100, UINT64_C(1000000000000) }, + { 200, UINT64_C(1000000000000) }, + { 500, UINT64_C(1000000000000) }, /* nanoseconds */ { 1, 1000000000 }, { 2, 1000000000 }, @@ -626,7 +626,6 @@ SR_PRIV int lecroy_xstream_receive_data(int fd, int revents, void *cb_data) struct sr_analog_encoding encoding; struct sr_analog_meaning meaning; struct sr_analog_spec spec; - char buf[8]; (void)fd; (void)revents; @@ -645,12 +644,6 @@ SR_PRIV int lecroy_xstream_receive_data(int fd, int revents, void *cb_data) if (ch->type != SR_CHANNEL_ANALOG) return SR_ERR; - /* Pass on the received data of the channel(s). */ - if (sr_scpi_read_data(sdi->conn, buf, 4) != 4) { - sr_err("Reading header failed, scope probably didn't send any data."); - return TRUE; - } - if (sr_scpi_get_block(sdi->conn, NULL, &data) != SR_OK) { if (data) g_byte_array_free(data, TRUE); @@ -665,6 +658,8 @@ SR_PRIV int lecroy_xstream_receive_data(int fd, int revents, void *cb_data) return SR_ERR; if (analog.num_samples == 0) { + g_free(analog.data); + /* No data available, we have to acquire data first. */ g_snprintf(command, sizeof(command), "ARM;WAIT;*OPC;C%d:WAVEFORM?", ch->index + 1); sr_scpi_send(sdi->conn, command); @@ -674,18 +669,18 @@ SR_PRIV int lecroy_xstream_receive_data(int fd, int revents, void *cb_data) } else { /* Update sample rate if needed. */ if (state->sample_rate == 0) - if (lecroy_xstream_update_sample_rate(sdi, analog.num_samples) != SR_OK) + if (lecroy_xstream_update_sample_rate(sdi, analog.num_samples) != SR_OK) { + g_free(analog.data); return SR_ERR; + } } /* * Send "frame begin" packet upon reception of data for the * first enabled channel. */ - if (devc->current_channel == devc->enabled_channels) { - packet.type = SR_DF_FRAME_BEGIN; - sr_session_send(sdi, &packet); - } + if (devc->current_channel == devc->enabled_channels) + std_session_send_df_frame_begin(sdi); meaning.channels = g_slist_append(NULL, ch); packet.payload = &analog; @@ -709,8 +704,7 @@ SR_PRIV int lecroy_xstream_receive_data(int fd, int revents, void *cb_data) return TRUE; } - packet.type = SR_DF_FRAME_END; - sr_session_send(sdi, &packet); + std_session_send_df_frame_end(sdi); /* * End of frame was reached. Stop acquisition after the specified