From 14ae864f8d4824049fd91dc471d7b70f708bb410 Mon Sep 17 00:00:00 2001 From: Andriy Tryshnivskyy Date: Sat, 9 Oct 2021 23:10:44 +0200 Subject: binding iiodevices: Support 64-bit raw values. IIO SCMI sensor can return such values. Bug-AGL: SPEC-3865 Signed-off-by: Andriy Tryshnivskyy Change-Id: Ifbdae831fd69bce6b3d0e360fb5848264b1db4e5 --- binding/iiodevices-binding.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'binding') diff --git a/binding/iiodevices-binding.c b/binding/iiodevices-binding.c index d4d4ba8..9f4ac10 100644 --- a/binding/iiodevices-binding.c +++ b/binding/iiodevices-binding.c @@ -329,7 +329,7 @@ static int read_data(struct client_sub *client, sd_event_source* src) return -1; } - char val[10]; + char val[22]; struct channels *channel = client->channels; while(channel) { //iterate on client channels if(!channel->chn) { @@ -337,11 +337,11 @@ static int read_data(struct client_sub *client, sd_event_source* src) return -1; } - iio_channel_attr_read(channel->chn, "raw", val, 10); - int data = (int)strtol(val, NULL, 10); - AFB_API_DEBUG(afbBindingV3root, "read_data: %s %d", iio_channel_get_id(channel->chn), data); + iio_channel_attr_read(channel->chn, "raw", val, sizeof(val)); + long long data = strtoll(val, NULL, 10); + AFB_API_DEBUG(afbBindingV3root, "read_data: %s %lld", iio_channel_get_id(channel->chn), data); - json_object *value = json_object_new_int(data); + json_object *value = json_object_new_int64(data); json_object_object_add(client->jobject, channel->name, value); channel = channel->next; } -- cgit 1.2.3-korg