Re: Trying to read data from accelerometer buffer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Jonathan,

Thank you for your time!

I read through libiio documentation and found what I was missing. It
was a matter of using 'iio_channel_convert'

Here is how I managed to get the data.

I used as a guide the file iio_readdev.c and changed the print_sample
function to:

static ssize_t print_sample(const struct iio_channel *chn, void *buf,
size_t len, void * d) {
/* Function called for each sample on buffer*/
    int16_t val;

    iio_channel_convert(chn, &val, buf);

    printf("Value of sample: %d", val);

    fflush(stdout);

    return len;
}

Thank you very much for your help!

Regards,
Ibrahim.

2015-10-31 8:29 GMT-02:00 Jonathan Cameron <jic23@xxxxxxxxxx>:
> On 29/10/15 10:05, Ibrahim Mattus Neto wrote:
>> Hi, I am having issues reading from a accelerometer and I hope yo
>> might help me (if I should ask this question elsewhere, please tell
>> me)
>>
>> What I am trying to do is get data from a buffer (I am using the
>> source code from iio_readdev as an example) but I can't figure it out
>> how to interpret the data properly.
> A quick google suggests this is from libiio.  Perhaps Paul or Lars
> can give more detail.
>>
>> I was expecting to get a bunch of numbers related to the X axis but
>> when it writes to stdout I get a bunch of weird characters, here is
>> the output:
>>
>> @������@������������������������������������������������
>>
>> How can I get values of x, y and z axes?
> The data is in binary, whereas piping it to stdout is presumably going to expect
> asci characters.   I would imagine, glancing at that example code
> that it was meant for piping into some other program that actually interpreted
> the stream?
>
> Alternatively, take a look at tools/iio/generic_buffer.c in the kernel source
> tree for an example of how to read from the buffers.
>>
>> Is there anything else I should provide? Is there some information missing?
>>
>> Thanks in advance!
>> Ibrahim
>> N�����r��y���b�X��ǧv�^�)޺{.n�+����{��*"��^n�r���z� ��h����&�� �G���h� (�階�ݢj"�� � m�����z�ޖ���f���h���~�mml==
>>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux