public inbox for linux-iio@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tools: iio: Add single-byte case for generic_buffer
@ 2015-06-15 15:17 Tiberiu Breana
  2015-06-21 10:00 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Tiberiu Breana @ 2015-06-15 15:17 UTC (permalink / raw)
  To: linux-iio

Some sensors export data in an 8-bit format.
Add a single-byte case for the generic_buffer tool so that
these sensors' buffer data can be visualized.

Signed-off-by: Tiberiu Breana <tiberiu.a.breana@intel.com>
---
 tools/iio/generic_buffer.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/tools/iio/generic_buffer.c b/tools/iio/generic_buffer.c
index f805493..0d438e3 100644
--- a/tools/iio/generic_buffer.c
+++ b/tools/iio/generic_buffer.c
@@ -103,6 +103,14 @@ void process_scan(char *data,
 	for (k = 0; k < num_channels; k++)
 		switch (channels[k].bytes) {
 			/* only a few cases implemented so far */
+		case 1:
+			if (channels[k].is_signed) {
+				int8_t val = *(int8_t *)
+					(data + channels[k].location);
+				printf("%05f ",
+					((float)val) * channels[k].scale);
+			}
+			break;
 		case 2:
 			print2byte(*(uint16_t *)(data + channels[k].location),
 				   &channels[k]);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-06-21 10:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-15 15:17 [PATCH] tools: iio: Add single-byte case for generic_buffer Tiberiu Breana
2015-06-21 10:00 ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox