예제 #1
0
static void teleinfo_send_value(struct sr_dev_inst *sdi, const char *channel_name,
                                float value, enum sr_mq mq, enum sr_unit unit)
{
	struct sr_datafeed_packet packet;
	struct sr_datafeed_analog analog;
	struct sr_analog_encoding encoding;
	struct sr_analog_meaning meaning;
	struct sr_analog_spec spec;
	struct sr_channel *ch;

	ch = teleinfo_find_channel(sdi, channel_name);

	if (!ch || !ch->enabled)
		return;

	/* Note: digits/spec_digits is actually really 0 for this device! */
	sr_analog_init(&analog, &encoding, &meaning, &spec, 0);
	analog.meaning->channels = g_slist_append(analog.meaning->channels, ch);
	analog.num_samples = 1;
	analog.meaning->mq = mq;
	analog.meaning->unit = unit;
	analog.data = &value;

	packet.type = SR_DF_ANALOG;
	packet.payload = &analog;
	sr_session_send(sdi, &packet);
	g_slist_free(analog.meaning->channels);
}
예제 #2
0
파일: protocol.c 프로젝트: anatol/libsigrok
static void teleinfo_send_value(struct sr_dev_inst *sdi, const char *channel_name,
                                float value, int mq, int unit)
{
	struct dev_context *devc;
	struct sr_datafeed_packet packet;
	struct sr_datafeed_analog analog;
	struct sr_channel *ch;

	devc = sdi->priv;
	ch = teleinfo_find_channel(sdi, channel_name);

	if (!ch || !ch->enabled)
		return;

	memset(&analog, 0, sizeof(struct sr_datafeed_analog));
	analog.channels = g_slist_append(analog.channels, ch);
	analog.num_samples = 1;
	analog.mq = mq;
	analog.unit = unit;
	analog.data = &value;

	packet.type = SR_DF_ANALOG;
	packet.payload = &analog;
	sr_session_send(devc->session_cb_data, &packet);
	g_slist_free(analog.channels);
}