MCPcopy Create free account
hub / github.com/DreamSourceLab/DSView / std_session_send_df_header

Function std_session_send_df_header

libsigrok4DSL/std.c:76–104  ·  view source on GitHub ↗

* Standard API helper for sending an SR_DF_HEADER packet. * * This function can be used to simplify most driver's * hw_dev_acquisition_start() API callback. * * @param sdi The device instance to use. * @param prefix A driver-specific prefix string used for log messages. * Must not be NULL. An empty string is allowed. * * @return SR_OK upon success, SR_ERR_ARG upon invalid arguments, or

Source from the content-addressed store, hash-verified

74 * SR_ERR upon other errors.
75 */
76SR_PRIV int std_session_send_df_header(const struct sr_dev_inst *sdi,
77 const char *prefix)
78{
79 int ret;
80 struct sr_datafeed_packet packet;
81 struct sr_datafeed_header header;
82
83 if (!prefix) {
84 sr_err("Invalid prefix.");
85 return SR_ERR_ARG;
86 }
87
88 sr_dbg("%sStarting acquisition.", prefix);
89
90 /* Send header packet to the session bus. */
91 sr_dbg("%sSending SR_DF_HEADER packet.", prefix);
92 packet.type = SR_DF_HEADER;
93 packet.status = SR_PKT_OK;
94 packet.payload = (uint8_t *)&header;
95 header.feed_version = 1;
96 gettimeofday(&header.starttime, NULL);
97
98 if ((ret = ds_data_forward(sdi, &packet)) < 0) {
99 sr_err("%sFailed to send header packet: %d.", prefix, ret);
100 return ret;
101 }
102
103 return SR_OK;
104}
105
106/*
107 * Standard sr_session_stop() API helper.

Callers 6

dev_acquisition_startFunction · 0.85
dev_acquisition_startFunction · 0.85
dev_acquisition_startFunction · 0.85
loadfileFunction · 0.85
loadfileFunction · 0.85
loadfileFunction · 0.85

Calls 1

ds_data_forwardFunction · 0.85

Tested by

no test coverage detected