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

Function std_hw_dev_acquisition_stop_serial

libsigrok4DSL/std.c:125–165  ·  view source on GitHub ↗

* Standard sr_session_stop() API helper. * * This function can be used to simplify most (serial port based) driver's * hw_dev_acquisition_stop() API callback. * * @param sdi The device instance for which acquisition should stop. * Must not be NULL. * @param cb_data Opaque 'cb_data' pointer. Must not be NULL. * @param hw_dev_close_fn Function pointer to the driver's hw_dev_close(

Source from the content-addressed store, hash-verified

123 * SR_ERR upon other errors.
124 */
125SR_PRIV int std_hw_dev_acquisition_stop_serial(struct sr_dev_inst *sdi,
126 void *cb_data, dev_close_t hw_dev_close_fn,
127 struct sr_serial_dev_inst *serial, const char *prefix)
128{
129 int ret;
130 struct sr_datafeed_packet packet;
131
132 if (!prefix) {
133 sr_err("Invalid prefix.");
134 return SR_ERR_ARG;
135 }
136
137 if (sdi->status != SR_ST_ACTIVE) {
138 sr_err("%sDevice inactive, can't stop acquisition.", prefix);
139 return SR_ERR;
140 }
141
142 sr_dbg("%sStopping acquisition.", prefix);
143
144 if ((ret = sr_source_remove(serial->fd)) < 0) {
145 sr_err("%sFailed to remove source: %d.", prefix, ret);
146 return ret;
147 }
148
149 if ((ret = hw_dev_close_fn(sdi)) < 0) {
150 sr_err("%sFailed to close device: %d.", prefix, ret);
151 return ret;
152 }
153
154 /* Send SR_DF_END packet to the session bus. */
155 sr_dbg("%sSending SR_DF_END packet.", prefix);
156 packet.type = SR_DF_END;
157 packet.status = SR_PKT_OK;
158 packet.payload = NULL;
159 if ((ret = ds_data_forward(cb_data, &packet)) < 0) {
160 sr_err("%sFailed to send SR_DF_END packet: %d.", prefix, ret);
161 return ret;
162 }
163
164 return SR_OK;
165}

Callers

nothing calls this directly

Calls 2

sr_source_removeFunction · 0.85
ds_data_forwardFunction · 0.85

Tested by

no test coverage detected