diff --git a/libsigrok-internal.h b/libsigrok-internal.h index 0dfbbe8a..e63ea930 100644 --- a/libsigrok-internal.h +++ b/libsigrok-internal.h @@ -122,7 +122,7 @@ SR_PRIV int sr_source_add(int fd, int events, int timeout, /*--- session.c -------------------------------------------------------------*/ SR_PRIV int sr_session_send(const struct sr_dev_inst *sdi, - struct sr_datafeed_packet *packet); + const struct sr_datafeed_packet *packet); /*--- hardware/common/serial.c ----------------------------------------------*/ diff --git a/libsigrok.h b/libsigrok.h index 9946691e..f371c944 100644 --- a/libsigrok.h +++ b/libsigrok.h @@ -268,7 +268,7 @@ struct sr_context; struct sr_datafeed_packet { uint16_t type; - void *payload; + const void *payload; }; struct sr_datafeed_header { @@ -336,7 +336,7 @@ struct sr_output_format { int (*event) (struct sr_output *o, int event_type, uint8_t **data_out, uint64_t *length_out); GString *(*recv) (struct sr_output *o, const struct sr_dev_inst *sdi, - struct sr_datafeed_packet *packet); + const struct sr_datafeed_packet *packet); int (*cleanup) (struct sr_output *o); }; diff --git a/output/analog.c b/output/analog.c index 448b112e..d2f28b6b 100644 --- a/output/analog.c +++ b/output/analog.c @@ -189,11 +189,11 @@ static void fancyprint(int unit, int mqflags, float value, GString *out) } static GString *receive(struct sr_output *o, const struct sr_dev_inst *sdi, - struct sr_datafeed_packet *packet) + const struct sr_datafeed_packet *packet) { - struct sr_datafeed_analog *analog; + const struct sr_datafeed_analog *analog; struct context *ctx; - float *fdata; + const float *fdata; int i, j; (void)sdi; @@ -214,7 +214,7 @@ static GString *receive(struct sr_output *o, const struct sr_dev_inst *sdi, break; case SR_DF_ANALOG: analog = packet->payload; - fdata = (float *)analog->data; + fdata = (const float *)analog->data; for (i = 0; i < analog->num_samples; i++) { for (j = 0; j < ctx->num_enabled_probes; j++) { g_string_append_printf(ctx->out, "%s: ", diff --git a/proto.h b/proto.h index c93a796e..870dc985 100644 --- a/proto.h +++ b/proto.h @@ -89,7 +89,7 @@ SR_API const struct sr_hwcap_option *sr_devopt_name_get(const char *optname); /*--- session.c -------------------------------------------------------------*/ typedef void (*sr_datafeed_callback_t)(const struct sr_dev_inst *sdi, - struct sr_datafeed_packet *packet); + const struct sr_datafeed_packet *packet); /* Session setup */ SR_API int sr_session_load(const char *filename); diff --git a/session.c b/session.c index 81e09b11..6a4a3c99 100644 --- a/session.c +++ b/session.c @@ -370,10 +370,10 @@ SR_API int sr_session_stop(void) * * @param packet The packet to show debugging information for. */ -static void datafeed_dump(struct sr_datafeed_packet *packet) +static void datafeed_dump(const struct sr_datafeed_packet *packet) { - struct sr_datafeed_logic *logic; - struct sr_datafeed_analog *analog; + const struct sr_datafeed_logic *logic; + const struct sr_datafeed_analog *analog; switch (packet->type) { case SR_DF_HEADER: @@ -426,7 +426,7 @@ static void datafeed_dump(struct sr_datafeed_packet *packet) * @private */ SR_PRIV int sr_session_send(const struct sr_dev_inst *sdi, - struct sr_datafeed_packet *packet) + const struct sr_datafeed_packet *packet) { GSList *l; sr_datafeed_callback_t cb;