g_strfreev(tokens);
/* Begin frame. */
- packet.type = SR_DF_FRAME_BEGIN;
- packet.payload = NULL;
- sr_session_send(sdi, &packet);
+ std_session_send_df_frame_begin(sdi);
sr_analog_init(&analog, &encoding, &meaning, &spec, 4);
g_slist_free(l);
/* End frame. */
- packet.type = SR_DF_FRAME_END;
- packet.payload = NULL;
- sr_session_send(sdi, &packet);
+ std_session_send_df_frame_end(sdi);
sr_sw_limits_update_samples_read(&devc->limits, 1);
}
SR_PRIV int bl_acme_receive_data(int fd, int revents, void *cb_data)
{
uint64_t nrexpiration;
- struct sr_datafeed_packet packet, framep;
+ struct sr_datafeed_packet packet;
struct sr_datafeed_analog analog;
struct sr_analog_encoding encoding;
struct sr_analog_meaning meaning;
* accuracy.
*/
for (i = 0; i < nrexpiration; i++) {
- framep.type = SR_DF_FRAME_BEGIN;
- sr_session_send(sdi, &framep);
+ std_session_send_df_frame_begin(sdi);
/*
* Due to different units used in each channel we're sending
sr_session_send(sdi, &packet);
}
- framep.type = SR_DF_FRAME_END;
- sr_session_send(sdi, &framep);
+ std_session_send_df_frame_end(sdi);
}
sr_sw_limits_update_samples_read(&devc->limits, 1);
{
struct sr_scpi_dev_inst *scpi;
struct dev_context *devc;
- struct sr_datafeed_packet packet;
scpi = sdi->conn;
devc = sdi->priv;
if (devc->df_started) {
- packet.type = SR_DF_FRAME_END;
- sr_session_send(sdi, &packet);
-
+ std_session_send_df_frame_end(sdi);
std_session_send_df_end(sdi);
-
devc->df_started = FALSE;
}
} else {
/* Start acquiring next frame. */
if (devc->df_started) {
- packet.type = SR_DF_FRAME_END;
- sr_session_send(sdi, &packet);
-
- packet.type = SR_DF_FRAME_BEGIN;
- sr_session_send(sdi, &packet);
+ std_session_send_df_frame_end(sdi);
+ std_session_send_df_frame_begin(sdi);
}
devc->cur_acq_frame++;
if (!devc->df_started) {
std_session_send_df_header(sdi);
-
- packet.type = SR_DF_FRAME_BEGIN;
- sr_session_send(sdi, &packet);
-
+ std_session_send_df_frame_begin(sdi);
devc->df_started = TRUE;
}
break;
} else {
/* Start acquiring next frame. */
if (devc->df_started) {
- packet.type = SR_DF_FRAME_END;
- sr_session_send(sdi, &packet);
-
- packet.type = SR_DF_FRAME_BEGIN;
- sr_session_send(sdi, &packet);
+ std_session_send_df_frame_end(sdi);
+ std_session_send_df_frame_begin(sdi);
}
devc->cur_acq_frame++;
devc->state = START_ACQUISITION;
* 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);
/*
* Pass on the received data of the channel(s).
*/
hmo_cleanup_logic_data(devc);
- 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
*/
static void LIBUSB_CALL receive_transfer(struct libusb_transfer *transfer)
{
- struct sr_datafeed_packet packet;
struct sr_dev_inst *sdi;
struct dev_context *devc;
int num_samples, pre;
devc->framebuf = NULL;
/* Mark the end of this frame. */
- packet.type = SR_DF_FRAME_END;
- sr_session_send(sdi, &packet);
+ std_session_send_df_frame_end(sdi);
if (devc->limit_frames && ++devc->num_frames >= devc->limit_frames) {
/* Terminate session */
static int handle_event(int fd, int revents, void *cb_data)
{
const struct sr_dev_inst *sdi;
- struct sr_datafeed_packet packet;
struct timeval tv;
struct sr_dev_driver *di;
struct dev_context *devc;
devc->dev_state = FETCH_DATA;
/* Tell the frontend a new frame is on the way. */
- packet.type = SR_DF_FRAME_BEGIN;
- sr_session_send(sdi, &packet);
+ std_session_send_df_frame_begin(sdi);
break;
case CAPTURE_READY_9BIT:
/* TODO */
SR_PRIV int hung_chang_dso_2100_poll(int fd, int revents, void *cb_data)
{
- struct sr_datafeed_packet packet = { .type = SR_DF_FRAME_BEGIN };
struct sr_dev_inst *sdi;
struct dev_context *devc;
uint8_t state, buf[1000];
return FALSE;
}
- sr_session_send(sdi, &packet);
+ std_session_send_df_frame_begin(sdi);
if (devc->channel) {
while (read_subframe(sdi, buf)) {
}
}
- packet.type = SR_DF_FRAME_END;
- sr_session_send(sdi, &packet);
+ std_session_send_df_frame_end(sdi);
if (++devc->frame >= devc->frame_limit)
sr_dev_acquisition_stop(sdi);
* 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;
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
struct sr_dev_inst *sdi;
struct dev_context *devc;
struct sr_modbus_dev_inst *modbus;
- struct sr_datafeed_packet packet;
uint16_t registers[4];
(void)fd;
devc->expecting_registers = 0;
if (sr_modbus_read_holding_registers(modbus, -1, 4, registers) == SR_OK) {
- packet.type = SR_DF_FRAME_BEGIN;
- sr_session_send(sdi, &packet);
+ std_session_send_df_frame_begin(sdi);
maynuo_m97_session_send_value(sdi, sdi->channels->data,
RBFL(registers + 0),
RBFL(registers + 2),
SR_MQ_CURRENT, SR_UNIT_AMPERE, 4);
- packet.type = SR_DF_FRAME_END;
- sr_session_send(sdi, &packet);
+ std_session_send_df_frame_end(sdi);
sr_sw_limits_update_samples_read(&devc->limits, 1);
}
struct sr_dev_inst *sdi;
struct dev_context *devc;
struct sr_modbus_dev_inst *modbus;
- struct sr_datafeed_packet packet;
uint16_t registers[8];
int ret;
if (ret == SR_OK) {
/* Send channel values */
- packet.type = SR_DF_FRAME_BEGIN;
- sr_session_send(sdi, &packet);
+ std_session_send_df_frame_begin(sdi);
send_value(sdi, sdi->channels->data,
RB16(registers + 0) / devc->voltage_multiplier,
RB16(registers + 2) / 100.0f,
SR_MQ_POWER, 0, SR_UNIT_WATT, 2);
- packet.type = SR_DF_FRAME_END;
- sr_session_send(sdi, &packet);
+ std_session_send_df_frame_end(sdi);
/* Check for state changes */
if (devc->actual_ovp_state != (RB16(registers + 5) == STATE_OVP)) {
struct sr_scpi_dev_inst *scpi;
struct dev_context *devc;
struct sr_channel *ch;
- struct sr_datafeed_packet packet;
gboolean some_digital;
GSList *l;
char *cmd;
return SR_ERR;
/* Start of first frame. */
- packet.type = SR_DF_FRAME_BEGIN;
- sr_session_send(sdi, &packet);
+ std_session_send_df_frame_begin(sdi);
return SR_OK;
}
return TRUE;
if (len == -1) {
sr_err("Error while reading block header, aborting capture.");
- packet.type = SR_DF_FRAME_END;
- sr_session_send(sdi, &packet);
+ std_session_send_df_frame_end(sdi);
sr_dev_acquisition_stop(sdi);
return TRUE;
}
if (len == -1) {
sr_err("Error while reading block data, aborting capture.");
- packet.type = SR_DF_FRAME_END;
- sr_session_send(sdi, &packet);
+ std_session_send_df_frame_end(sdi);
sr_dev_acquisition_stop(sdi);
return TRUE;
}
/* End acquisition when data for all channels is acquired. */
if (!sr_scpi_read_complete(scpi) && !devc->channel_entry->next) {
sr_err("Read should have been completed");
- packet.type = SR_DF_FRAME_END;
- sr_session_send(sdi, &packet);
+ std_session_send_df_frame_end(sdi);
sr_dev_acquisition_stop(sdi);
return TRUE;
}
rigol_ds_channel_start(sdi);
} else {
/* Done with this frame. */
- packet.type = SR_DF_FRAME_END;
- sr_session_send(sdi, &packet);
+ std_session_send_df_frame_end(sdi);
if (++devc->num_frames == devc->limit_frames) {
/* Last frame, stop capture. */
rigol_ds_capture_start(sdi);
/* Start of next frame. */
- packet.type = SR_DF_FRAME_BEGIN;
- sr_session_send(sdi, &packet);
+ std_session_send_df_frame_begin(sdi);
}
}
struct lcr_parse_info *info;
uint64_t freq;
const char *model;
- struct sr_datafeed_packet packet;
devc = sdi->priv;
info = &devc->parse_info;
}
/* Data is about to get sent. Start a new frame. */
- packet.type = SR_DF_FRAME_BEGIN;
- sr_session_send(sdi, &packet);
+ std_session_send_df_frame_begin(sdi);
}
static int handle_packet(struct sr_dev_inst *sdi, const uint8_t *pkt)
struct sr_scpi_dev_inst *scpi;
struct dev_context *devc;
struct sr_channel *ch;
- struct sr_datafeed_packet packet;
gboolean some_digital;
GSList *l, *d;
return SR_ERR;
/* Start of first frame. */
- packet.type = SR_DF_FRAME_BEGIN;
- sr_session_send(sdi, &packet);
+ std_session_send_df_frame_begin(sdi);
return SR_OK;
}
return TRUE;
if (len == -1) {
sr_err("Read error, aborting capture.");
- packet.type = SR_DF_FRAME_END;
- sr_session_send(sdi, &packet);
+ std_session_send_df_frame_end(sdi);
sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
}
if (len == -1) {
sr_err("Read error, aborting capture.");
- packet.type = SR_DF_FRAME_END;
- sr_session_send(sdi, &packet);
+ std_session_send_df_frame_end(sdi);
sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
}
len = sr_scpi_read_data(scpi, (char *)devc->buffer, devc->num_samples-devc->num_block_bytes);
if (len == -1) {
sr_err("Read error, aborting capture.");
- packet.type = SR_DF_FRAME_END;
- sr_session_send(sdi, &packet);
+ std_session_send_df_frame_end(sdi);
sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
}
read_complete = TRUE;
if (!sr_scpi_read_complete(scpi)) {
sr_err("Read should have been completed.");
- packet.type = SR_DF_FRAME_END;
- sr_session_send(sdi, &packet);
+ std_session_send_df_frame_end(sdi);
sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
}
siglent_sds_channel_start(sdi);
} else {
/* Done with this frame. */
- packet.type = SR_DF_FRAME_END;
- sr_session_send(sdi, &packet);
+ std_session_send_df_frame_end(sdi);
if (++devc->num_frames == devc->limit_frames) {
/* Last frame, stop capture. */
sdi->driver->dev_acquisition_stop(sdi);
siglent_sds_capture_start(sdi);
/* Start of next frame. */
- packet.type = SR_DF_FRAME_BEGIN;
- sr_session_send(sdi, &packet);
+ std_session_send_df_frame_begin(sdi);
}
}
}
packet.type = SR_DF_LOGIC;
packet.payload = &logic;
sr_session_send(sdi, &packet);
- packet.type = SR_DF_FRAME_END;
- sr_session_send(sdi, &packet);
+ std_session_send_df_frame_end(sdi);
sdi->driver->dev_acquisition_stop(sdi);
if (++devc->num_frames == devc->limit_frames) {
siglent_sds_capture_start(sdi);
/* Start of next frame. */
- packet.type = SR_DF_FRAME_BEGIN;
- sr_session_send(sdi, &packet);
+ std_session_send_df_frame_begin(sdi);
}
}
// sr_session_send(sdi, &packet);
- // packet.type = SR_DF_FRAME_END;
- // sr_session_send(sdi, &packet);
+ // std_session_send_df_frame_end(sdi);
// sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
struct scope_state *model_state;
struct dev_context *devc;
struct sr_channel *ch;
- struct sr_datafeed_packet packet;
int chunk_len, num_bytes;
static GArray *data = NULL;
devc->data_pending = FALSE;
/* Signal the beginning of a new frame if this is the first 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);
if (dlm_block_data_header_process(data, &num_bytes) != SR_OK) {
sr_err("Encountered malformed block data header.");
* and set the next enabled channel. Then, request its data.
*/
if (!devc->current_channel->next) {
- packet.type = SR_DF_FRAME_END;
- sr_session_send(sdi, &packet);
+ std_session_send_df_frame_end(sdi);
devc->current_channel = devc->enabled_channels;
/*
sr_dbg("Current limit %f", current_limit);
/* Begin frame. */
- packet.type = SR_DF_FRAME_BEGIN;
- packet.payload = NULL;
- sr_session_send(sdi, &packet);
+ std_session_send_df_frame_begin(sdi);
sr_analog_init(&analog, &encoding, &meaning, &spec, 4);
g_slist_free(l);
/* End frame. */
- packet.type = SR_DF_FRAME_END;
- packet.payload = NULL;
- sr_session_send(sdi, &packet);
+ std_session_send_df_frame_end(sdi);
sr_sw_limits_update_samples_read(&devc->limits, 1);
if (sr_sw_limits_check(&devc->limits))