main: Apply scale from readings for IIO buffered drivers

Add a scale output parameter in process_scan_1 so that we pass scale
information from each driver read to the driver, and apply the scale
before passing it on to the main daemon.

Closes #28
This commit is contained in:
Benjamin Tissoires
2015-06-25 13:03:52 -04:00
committed by Bastien Nocera
parent 0974fe628f
commit f04fe60af3
5 changed files with 15 additions and 6 deletions

View File

@@ -455,6 +455,7 @@ size_from_channelarray (iio_channel_info **channels,
* @buffer_data: Buffer information
* ch_name: name of channel to get
* ch_val: value for the channel
* ch_scale: scale for the channel
* ch_present: whether the channel is present
**/
void
@@ -462,6 +463,7 @@ process_scan_1 (char *data,
BufferDrvData *buffer_data,
char *ch_name,
int *ch_val,
gdouble *ch_scale,
gboolean *ch_present)
{
int k;
@@ -484,6 +486,7 @@ process_scan_1 (char *data,
if (buffer_data->channels[k]->bits_used < 32) val &= ((guint32) 1 << buffer_data->channels[k]->bits_used) - 1;
val = (gint32) (val << (32 - buffer_data->channels[k]->bits_used)) >> (32 - buffer_data->channels[k]->bits_used);
*ch_val = (int) val;
*ch_scale = buffer_data->channels[k]->scale;
*ch_present = TRUE;
}
break;