* Trying to read data from accelerometer buffer @ 2015-10-29 10:05 Ibrahim Mattus Neto 2015-10-31 10:29 ` Jonathan Cameron 0 siblings, 1 reply; 3+ messages in thread From: Ibrahim Mattus Neto @ 2015-10-29 10:05 UTC (permalink / raw) To: linux-iio SGksIEkgYW0gaGF2aW5nIGlzc3VlcyByZWFkaW5nIGZyb20gYSBhY2NlbGVyb21ldGVyIGFuZCBJ IGhvcGUgeW8NCm1pZ2h0IGhlbHAgbWUgKGlmIEkgc2hvdWxkIGFzayB0aGlzIHF1ZXN0aW9uIGVs c2V3aGVyZSwgcGxlYXNlIHRlbGwNCm1lKQ0KDQpXaGF0IEkgYW0gdHJ5aW5nIHRvIGRvIGlzIGdl dCBkYXRhIGZyb20gYSBidWZmZXIgKEkgYW0gdXNpbmcgdGhlDQpzb3VyY2UgY29kZSBmcm9tIGlp b19yZWFkZGV2IGFzIGFuIGV4YW1wbGUpIGJ1dCBJIGNhbid0IGZpZ3VyZSBpdCBvdXQNCmhvdyB0 byBpbnRlcnByZXQgdGhlIGRhdGEgcHJvcGVybHkuDQoNCkkgd2FzIGV4cGVjdGluZyB0byBnZXQg YSBidW5jaCBvZiBudW1iZXJzIHJlbGF0ZWQgdG8gdGhlIFggYXhpcyBidXQNCndoZW4gaXQgd3Jp dGVzIHRvIHN0ZG91dCBJIGdldCBhIGJ1bmNoIG9mIHdlaXJkIGNoYXJhY3RlcnMsIGhlcmUgaXMN CnRoZSBvdXRwdXQ6DQoNCkDvv73vv73vv73vv73vv73vv71A77+977+977+977+977+977+977+9 77+977+977+977+977+977+977+977+977+977+977+977+977+977+977+977+977+977+977+9 77+977+977+977+977+977+977+977+977+977+977+977+977+977+977+977+977+977+977+9 77+977+977+9DQoNCkhvdyBjYW4gSSBnZXQgdmFsdWVzIG9mIHgsIHkgYW5kIHogYXhlcz8NCg0K SXMgdGhlcmUgYW55dGhpbmcgZWxzZSBJIHNob3VsZCBwcm92aWRlPyBJcyB0aGVyZSBzb21lIGlu Zm9ybWF0aW9uIG1pc3Npbmc/DQoNClRoYW5rcyBpbiBhZHZhbmNlIQ0KSWJyYWhpbQ0K ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Trying to read data from accelerometer buffer 2015-10-29 10:05 Trying to read data from accelerometer buffer Ibrahim Mattus Neto @ 2015-10-31 10:29 ` Jonathan Cameron 2015-11-03 11:19 ` Ibrahim Mattus Neto 0 siblings, 1 reply; 3+ messages in thread From: Jonathan Cameron @ 2015-10-31 10:29 UTC (permalink / raw) To: Ibrahim Mattus Neto, linux-iio, Paul Cercueil, Lars-Peter Clausen 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�\x1a��h����&��\x1e�G���h�\x03(�階�ݢj"��\x1a�^[m�����z�ޖ���f���h���~�mml== > ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Trying to read data from accelerometer buffer 2015-10-31 10:29 ` Jonathan Cameron @ 2015-11-03 11:19 ` Ibrahim Mattus Neto 0 siblings, 0 replies; 3+ messages in thread From: Ibrahim Mattus Neto @ 2015-11-03 11:19 UTC (permalink / raw) To: Jonathan Cameron; +Cc: linux-iio, Paul Cercueil, Lars-Peter Clausen 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@kernel.org>: > 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== >> > ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-11-03 11:19 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-10-29 10:05 Trying to read data from accelerometer buffer Ibrahim Mattus Neto 2015-10-31 10:29 ` Jonathan Cameron 2015-11-03 11:19 ` Ibrahim Mattus Neto
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.