Skip to contentSkip to conversation

IIO Drivers

DISCUSSION Lars-Peter Clausen 3 participants 16 messages Feb 27, 2013 – Mar 5, 2013 2 messages not in the archive IIO

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 6 lines · Chris Micali

Hello Lars,

I'm doing a bit of hacking on a IIO driver based on some of your drivers on a 3.8 kernel (specifically writing a driver for a TI SPI adc.) I've been able to get a driver up and working such that I can read directly from the in_voltage0_raw on sysfs and get the correct values but I can't seem to get buffered access working (via iio_cmdsrv.) I've had a hard time finding any docs on this stuff and I was wondering if you could give me any pointers on where to look or who else perhaps to ask about this stuff? Any pointers would be very much appreciated!

Thanks,
Chris

Hi,

I'm afraid except for the the documentation in drivers/staging/iio/Documentation/, the kernel doc comments and the skeleton driver (drivers/staging/iio/iio_simple_dummy*) there is not much additional documentation available.

The general place to ask questions about IIO is the IIO mailinglist. I've put it on CC, hope you don't mind.

I think we can help you best if you post your code.

- Lars

#2 lore raw

Hi Lars,
Thanks a lot for getting back to me. I've attached my code - it's pretty simple, I just copied an existing driver. As I mentioned individual reads are working fine (if i cat in_voltage0_raw) but buffered reads are failing. I've tracked the issue to industrialio-buffer.c in iio_compute_scan_bytes() which always returns zero because, i believe, the mask is 0. I haven't been able to find any docs on what 'scan masks' mean but I have seen a few drivers that supply available scan masks. Should I be specifying scan masks? Thanks!
-chris

Quoted 23 lines · Lars-Peter Clausen
Quoted 6 lines · Chris Micali

Hello Lars,

I'm doing a bit of hacking on a IIO driver based on some of your drivers on a 3.8 kernel (specifically writing a driver for a TI SPI adc.) I've been able to get a driver up and working such that I can read directly from the in_voltage0_raw on sysfs and get the correct values but I can't seem to get buffered access working (via iio_cmdsrv.) I've had a hard time finding any docs on this stuff and I was wondering if you could give me any pointers on where to look or who else perhaps to ask about this stuff? Any pointers would be very much appreciated!

Thanks,
Chris

Hi,

I'm afraid except for the the documentation in drivers/staging/iio/Documentation/, the kernel doc comments and the skeleton driver (drivers/staging/iio/iio_simple_dummy*) there is not much additional documentation available.

The general place to ask questions about IIO is the IIO mailinglist. I've put it on CC, hope you don't mind.

I think we can help you best if you post your code.

- Lars

#3 lore raw
Quoted 4 lines · Chris Micali

Hi Lars,
Thanks a lot for getting back to me. I've attached my code - it's pretty simple, I just copied an existing driver. As I mentioned individual reads are working fine (if i cat in_voltage0_raw) but buffered reads are failing. I've tracked the issue to industrialio-buffer.c in iio_compute_scan_bytes() which always returns zero because, i believe, the mask is 0. I haven't been able to find any docs on what 'scan masks' mean but I have seen a few drivers that supply available scan masks. Should I be specifying scan masks? Thanks!
-chris

Hi Chris,

You need to enable the channels you want to sample in sysfs. If you are using the command server you can for example do this by doing a 'write ads... scan_elements/in_voltage0_en'

- Lars

Quoted 27 lines · Lars-Peter Clausen
Quoted 24 lines · Chris Micali
Quoted 6 lines

Hello Lars,

I'm doing a bit of hacking on a IIO driver based on some of your drivers on a 3.8 kernel (specifically writing a driver for a TI SPI adc.) I've been able to get a driver up and working such that I can read directly from the in_voltage0_raw on sysfs and get the correct values but I can't seem to get buffered access working (via iio_cmdsrv.) I've had a hard time finding any docs on this stuff and I was wondering if you could give me any pointers on where to look or who else perhaps to ask about this stuff? Any pointers would be very much appreciated!

Thanks,
Chris

Hi,

I'm afraid except for the the documentation in drivers/staging/iio/Documentation/, the kernel doc comments and the skeleton driver (drivers/staging/iio/iio_simple_dummy*) there is not much additional documentation available.

The general place to ask questions about IIO is the IIO mailinglist. I've put it on CC, hope you don't mind.

I think we can help you best if you post your code.

- Lars

A message that is not in the archive (sent off-list or not yet received): [email protected]

#5 lore raw
Quoted 5 lines · Chris Micali

Lars,

Thanks.. when I write 1 to scan_elements/in_voltage0_en via iio_cmdserv i get -2, from shell (echo 1>) i see write error: Invalid argument. No output in dmesg that indicates what the error is/could be though.

-c

In your driver you commented out the INDIO_BUFFER_TRIGGERED mode flag, did you add that back? Without it this won't work.

- Lars

Quoted 52 lines · Lars-Peter Clausen
Quoted 47 lines · Chris Micali
Quoted 5 lines

Hi Lars,
Thanks a lot for getting back to me. I've attached my code - it's pretty simple, I just copied an existing driver. As I mentioned individual reads are working fine (if i cat in_voltage0_raw) but buffered reads are failing. I've tracked the issue to industrialio-buffer.c in iio_compute_scan_bytes() which always returns zero because, i believe, the mask is 0. I haven't been able to find any docs on what 'scan masks' mean but I have seen a few drivers that supply available scan masks. Should I be specifying scan masks? Thanks!
-chris

Hi Chris,

You need to enable the channels you want to sample in sysfs. If you are using the command server you can for example do this by doing a 'write ads... scan_elements/in_voltage0_en'

- Lars

Quoted 29 lines · Lars-Peter Clausen
Quoted 26 lines · Chris Micali
Quoted 7 lines

Hello Lars,

I'm doing a bit of hacking on a IIO driver based on some of your drivers on a 3.8 kernel (specifically writing a driver for a TI SPI adc.) I've been able to get a driver up and working such that I can read directly from the in_voltage0_raw on sysfs and get the correct values but I can't seem to get buffered access working (via iio_cmdsrv.) I've had a hard time finding any docs on this stuff and I was wondering if you could give me any pointers on where to look or who else perhaps to ask about this stuff? Any pointers would be very much appreciated!

Thanks,
Chris

Hi,

I'm afraid except for the the documentation in drivers/staging/iio/Documentation/, the kernel doc comments and the skeleton driver (drivers/staging/iio/iio_simple_dummy*) there is not much additional documentation available.

The general place to ask questions about IIO is the IIO mailinglist. I've put it on CC, hope you don't mind.

I think we can help you best if you post your code.

- Lars

#6 lore raw

lars,

I was under the impression that flag gets added automatically by iio_triggered_buffer_setup (industrialiio-triggers.c:77) - I actually am now able to enable the scan_element after changing my channel .channel and .scan_index to 0 (trying to match exactly the other drivers.) When i run general_buffer (from the docs dir) with that scan element enabled it can no longer read the trigger (Could not open /trigger/current_trigger Failed to write current_trigger file) - this succeeds if that scan_element is not enabled.

Is there a guide anywhere that captures the steps to setup and read from a driver that perhaps I missed?

-c

Quoted 64 lines · Lars-Peter Clausen
Quoted 5 lines · Chris Micali

Lars,

Thanks.. when I write 1 to scan_elements/in_voltage0_en via iio_cmdserv i get -2, from shell (echo 1>) i see write error: Invalid argument. No output in dmesg that indicates what the error is/could be though.

-c

In your driver you commented out the INDIO_BUFFER_TRIGGERED mode flag, did you add that back? Without it this won't work.

- Lars

Quoted 52 lines · Lars-Peter Clausen
Quoted 49 lines · Chris Micali
Quoted 4 lines

Hi Lars,
Thanks a lot for getting back to me. I've attached my code - it's pretty simple, I just copied an existing driver. As I mentioned individual reads are working fine (if i cat in_voltage0_raw) but buffered reads are failing. I've tracked the issue to industrialio-buffer.c in iio_compute_scan_bytes() which always returns zero because, i believe, the mask is 0. I haven't been able to find any docs on what 'scan masks' mean but I have seen a few drivers that supply available scan masks. Should I be specifying scan masks? Thanks!
-chris

Hi Chris,

You need to enable the channels you want to sample in sysfs. If you are using the command server you can for example do this by doing a 'write ads... scan_elements/in_voltage0_en'

- Lars

Quoted 30 lines · Lars-Peter Clausen
Quoted 27 lines · Chris Micali
Quoted 6 lines

Hello Lars,

I'm doing a bit of hacking on a IIO driver based on some of your drivers on a 3.8 kernel (specifically writing a driver for a TI SPI adc.) I've been able to get a driver up and working such that I can read directly from the in_voltage0_raw on sysfs and get the correct values but I can't seem to get buffered access working (via iio_cmdsrv.) I've had a hard time finding any docs on this stuff and I was wondering if you could give me any pointers on where to look or who else perhaps to ask about this stuff? Any pointers would be very much appreciated!

Thanks,
Chris

Hi,

I'm afraid except for the the documentation in drivers/staging/iio/Documentation/, the kernel doc comments and the skeleton driver (drivers/staging/iio/iio_simple_dummy*) there is not much additional documentation available.

The general place to ask questions about IIO is the IIO mailinglist. I've put it on CC, hope you don't mind.

I think we can help you best if you post your code.

- Lars

maintainer
#7 lore raw
Quoted 3 lines · Chris Micali

lars,

I was under the impression that flag gets added automatically by iio_triggered_buffer_setup (industrialiio-triggers.c:77) - I actually am now able to enable the scan_element after changing my channel .channel and .scan_index to 0 (trying to match exactly the other drivers.)

Strange, scan_index should have defaulted to zero and the .channel value shouldn't have mattered for buffered reads (just effects naming). Might have caused issues with userspace expecting a channel 0 though...

Quoted 5 lines

When i run general_buffer (from the docs dir) with that scan element enabled it can no longer read the trigger (Could not open /trigger/current_trigger Failed to write current_trigger file) - this succeeds if that scan_element is not enabled.

Is there a guide anywhere that captures the steps to setup and read from a driver that perhaps I missed?

Saddly there was a while back but it got so out of date that it because counter productive.

userspace wise, buffer_generic.c is the example of the steps.

Briefly.

1) Enable some channels via /sys/bus/iio/devices/iio:device0/scan_elements
2) Associate a trigger with the device. For the failed to write above are you specifying a trigger? If not it'll guess the device is supplying one and try looking for that. (which doesn't exist). Hmm. that error message could probably do with some detail!
3) Enable the buffer
4) Read from the associated chrdev.

Quoted 77 lines

-c

Quoted 64 lines · Lars-Peter Clausen
Quoted 5 lines · Chris Micali

Lars,

Thanks.. when I write 1 to scan_elements/in_voltage0_en via iio_cmdserv i get -2, from shell (echo 1>) i see write error: Invalid argument. No output in dmesg that indicates what the error is/could be though.

-c

In your driver you commented out the INDIO_BUFFER_TRIGGERED mode flag, did you add that back? Without it this won't work.

- Lars

Quoted 52 lines · Lars-Peter Clausen
Quoted 49 lines · Chris Micali
Quoted 4 lines

Hi Lars,
Thanks a lot for getting back to me. I've attached my code - it's pretty simple, I just copied an existing driver. As I mentioned individual reads are working fine (if i cat in_voltage0_raw) but buffered reads are failing. I've tracked the issue to industrialio-buffer.c in iio_compute_scan_bytes() which always returns zero because, i believe, the mask is 0. I haven't been able to find any docs on what 'scan masks' mean but I have seen a few drivers that supply available scan masks. Should I be specifying scan masks? Thanks!
-chris

Hi Chris,

You need to enable the channels you want to sample in sysfs. If you are using the command server you can for example do this by doing a 'write ads... scan_elements/in_voltage0_en'

- Lars

Quoted 30 lines · Lars-Peter Clausen
Quoted 27 lines · Chris Micali
Quoted 6 lines

Hello Lars,

I'm doing a bit of hacking on a IIO driver based on some of your drivers on a 3.8 kernel (specifically writing a driver for a TI SPI adc.) I've been able to get a driver up and working such that I can read directly from the in_voltage0_raw on sysfs and get the correct values but I can't seem to get buffered access working (via iio_cmdsrv.) I've had a hard time finding any docs on this stuff and I was wondering if you could give me any pointers on where to look or who else perhaps to ask about this stuff? Any pointers would be very much appreciated!

Thanks,
Chris

Hi,

I'm afraid except for the the documentation in drivers/staging/iio/Documentation/, the kernel doc comments and the skeleton driver (drivers/staging/iio/iio_simple_dummy*) there is not much additional documentation available.

The general place to ask questions about IIO is the IIO mailinglist. I've put it on CC, hope you don't mind.

I think we can help you best if you post your code.

- Lars

--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#8 lore raw
Quoted 5 lines · Jonathan Cameron
Quoted 3 lines · Chris Micali

lars,

I was under the impression that flag gets added automatically by iio_triggered_buffer_setup (industrialiio-triggers.c:77) - I actually am now able to enable the scan_element after changing my channel .channel and .scan_index to 0 (trying to match exactly the other drivers.)

Yea, you are right I missed the iio_triggered_buffer_setup part.

Quoted 3 lines

Strange, scan_index should have defaulted to zero and the .channel value shouldn't have mattered for buffered reads (just effects naming). Might have caused issues with userspace expecting a channel 0 though...

I guess the scan_index had nothing to do with this, but I suggested to set scan_elements/in_voltage0_en to 1, so this clearly wouldn't have worked with .channel being 1.

Quoted 2 lines
Quoted 2 lines

When i run general_buffer (from the docs dir) with that scan element enabled it can no longer read the trigger (Could not open /trigger/current_trigger Failed to write current_trigger file) - this succeeds if that scan_element is not enabled.

You can't change the trigger if the buffer is currently enabled. Make sure that he buffer is disabled (check the buffer/enable attribute).

- Lars
u

#9 lore raw

Guys, =20

Thanks a lot for the help=21 I finally tracked down issues, it was a com= bination of a few things:

1. The .channel had to be 0, not 1 in the driver (scan=5Findex didn't mat= ter)
2. 1 or more scan=5Felements have to be enabled as you mentioned
2. When echoing into the sysfs files it has to have a space after the num= ber (cat 1 > in=5Fvoltage0=5Fen and not cat 1>in=5Fvo=E2=80=A6) (duh=21)=

3. The generic=5Fbuffer.c program had a few bugs in it causing crashes. = I updated the iio=5Futils.h to a newer version I found here: https://gith=
ub.com/analogdevicesinc/iio-oscilloscope and then made a few modification= s (the newer iio=5Futils did not parse a few things right in the channel = details like bigendian/littleendian)

So generic=5Fbuffer is now correctly sampling (although it crashes after = a couple, it's probably another iio=5Futils issue)

Thanks=21=21

-chris

Quoted 5 lines · Lars-Peter Clausen
Quoted 4 lines · Jonathan Cameron
Quoted 3 lines · Chris Micali

lars, =20
=20
I was under the impression that flag gets added automatically by ii=

o=5Ftriggered=5Fbuffer=5Fsetup (industrialiio-triggers.c:77) - I actually=
am now able to enable the scan=5Felement after changing my channel .chan=
nel and .scan=5Findex to 0 (trying to match exactly the other drivers.)

Quoted 4 lines

=20
Yea, you are right I missed the iio=5Ftriggered=5Fbuffer=5Fsetup part. =20

Quoted 1 line

Strange, scan=5Findex should have defaulted to zero and the .channel =

value shouldn't have mattered

Quoted 1 line
Quoted 1 line

for buffered reads (just effects naming). Might have caused issues wi=

th userspace expecting a channel 0

Quoted 5 lines
Quoted 1 line

though...

=20
=20
=20
I guess the scan=5Findex had nothing to do with this, but I suggested t=

o set

Quoted 1 line

scan=5Felements/in=5Fvoltage0=5Fen to 1, so this clearly wouldn't have =

worked with

Quoted 4 lines

.channel being 1.
=20

Quoted 2 lines

=20

Quoted 1 line

When i run general=5Fbuffer (from the docs dir) with that scan elem=

ent enabled it can no longer read the trigger (Could not open /trigger/cu= rrent=5Ftrigger =46ailed to write current=5Ftrigger file) - this succeeds=
if that scan=5Felement is not enabled. =20

Quoted 2 lines

=20
You can't change the trigger if the buffer is currently enabled. Make s=

ure that

Quoted 4 lines

he buffer is disabled (check the buffer/enable attribute). =20
- Lars
u

#10 lore raw

Last question :) I'd like to sample from this device as quickly as possible - so I'm assuming I need to trigger quickly? Should I use iio-trig-periodic-rtc? Any hints/instructions on how to use that? Should the driver supply it's own trigger that uses an hrtimer instead?

Thanks!
Chris

Quoted 49 lines · Chris Micali

Guys,

Thanks a lot for the help! I finally tracked down issues, it was a combination of a few things:

1. The .channel had to be 0, not 1 in the driver (scan_index didn't matter)
2. 1 or more scan_elements have to be enabled as you mentioned
2. When echoing into the sysfs files it has to have a space after the number (cat 1 > in_voltage0_en and not cat 1>in_vo…) (duh!)
3. The generic_buffer.c program had a few bugs in it causing crashes. I updated the iio_utils.h to a newer version I found here: https://github.com/analogdevicesinc/iio-oscilloscope and then made a few modifications (the newer iio_utils did not parse a few things right in the channel details like bigendian/littleendian)

So generic_buffer is now correctly sampling (although it crashes after a couple, it's probably another iio_utils issue)

Thanks!!

-chris

Quoted 30 lines · Lars-Peter Clausen
Quoted 4 lines · Jonathan Cameron
Quoted 3 lines · Chris Micali

lars,

I was under the impression that flag gets added automatically by iio_triggered_buffer_setup (industrialiio-triggers.c:77) - I actually am now able to enable the scan_element after changing my channel .channel and .scan_index to 0 (trying to match exactly the other drivers.)

Yea, you are right I missed the iio_triggered_buffer_setup part.

Quoted 3 lines

Strange, scan_index should have defaulted to zero and the .channel value shouldn't have mattered for buffered reads (just effects naming). Might have caused issues with userspace expecting a channel 0 though...

I guess the scan_index had nothing to do with this, but I suggested to set scan_elements/in_voltage0_en to 1, so this clearly wouldn't have worked with .channel being 1.

Quoted 2 lines
Quoted 2 lines

When i run general_buffer (from the docs dir) with that scan element enabled it can no longer read the trigger (Could not open /trigger/current_trigger Failed to write current_trigger file) - this succeeds if that scan_element is not enabled.

You can't change the trigger if the buffer is currently enabled. Make sure that he buffer is disabled (check the buffer/enable attribute).

- Lars
u

#11 lore raw
Quoted 4 lines · Chris Micali

Last question :) I'd like to sample from this device as quickly as possible - so I'm assuming I need to trigger quickly? Should I use iio-trig-periodic-rtc? Any hints/instructions on how to use that? Should the driver supply it's own trigger that uses an hrtimer instead?

Thanks!
Chris

Hi,

There is a generic hrtimer based trigger:
https://github.com/lclausen-adi/linux-2.6/commit/a3b5c3f7aafbcac562d6f00a6589b110bd9fb71c

Unfortunately it's not upstream ready yet.

I can be registered via a platform_device

static struct platform_device iio_trigger_hrtimer = {
	.name = "iio-trigger-hrtimer",
	.id = 0,
};

- Lars

Quoted 59 lines · Chris Micali
Quoted 9 lines

Guys,

Thanks a lot for the help! I finally tracked down issues, it was a combination of a few things:

1. The .channel had to be 0, not 1 in the driver (scan_index didn't matter)
2. 1 or more scan_elements have to be enabled as you mentioned
2. When echoing into the sysfs files it has to have a space after the number (cat 1 > in_voltage0_en and not cat 1>in_vo…) (duh!)
3. The generic_buffer.c program had a few bugs in it causing crashes. I updated the iio_utils.h to a newer version I found here: https://github.com/analogdevicesinc/iio-oscilloscope and then made a few modifications (the newer iio_utils did not parse a few things right in the channel details like bigendian/littleendian)

Quoted 40 lines

So generic_buffer is now correctly sampling (although it crashes after a couple, it's probably another iio_utils issue)

Thanks!!

-chris

Quoted 30 lines · Lars-Peter Clausen
Quoted 4 lines · Jonathan Cameron
Quoted 3 lines · Chris Micali

lars,

I was under the impression that flag gets added automatically by iio_triggered_buffer_setup (industrialiio-triggers.c:77) - I actually am now able to enable the scan_element after changing my channel .channel and .scan_index to 0 (trying to match exactly the other drivers.)

Yea, you are right I missed the iio_triggered_buffer_setup part.

Quoted 3 lines

Strange, scan_index should have defaulted to zero and the .channel value shouldn't have mattered for buffered reads (just effects naming). Might have caused issues with userspace expecting a channel 0 though...

I guess the scan_index had nothing to do with this, but I suggested to set scan_elements/in_voltage0_en to 1, so this clearly wouldn't have worked with .channel being 1.

Quoted 2 lines
Quoted 2 lines

When i run general_buffer (from the docs dir) with that scan element enabled it can no longer read the trigger (Could not open /trigger/current_trigger Failed to write current_trigger file) - this succeeds if that scan_element is not enabled.

You can't change the trigger if the buffer is currently enabled. Make sure that he buffer is disabled (check the buffer/enable attribute).

- Lars
u

--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#12 lore raw

Thanks lars - i'm actually on 3.8, you don't happen to have a DT example do you?

Quoted 90 lines · Lars-Peter Clausen
Quoted 4 lines · Chris Micali

Last question :) I'd like to sample from this device as quickly as possible - so I'm assuming I need to trigger quickly? Should I use iio-trig-periodic-rtc? Any hints/instructions on how to use that? Should the driver supply it's own trigger that uses an hrtimer instead?

Thanks!
Chris

Hi,

There is a generic hrtimer based trigger:
https://github.com/lclausen-adi/linux-2.6/commit/a3b5c3f7aafbcac562d6f00a6589b110bd9fb71c

Unfortunately it's not upstream ready yet.

I can be registered via a platform_device

static struct platform_device iio_trigger_hrtimer = { .name = "iio-trigger-hrtimer",
.id = 0,
};

- Lars

Quoted 65 lines · Chris Micali
Quoted 9 lines

Guys,

Thanks a lot for the help! I finally tracked down issues, it was a combination of a few things:

1. The .channel had to be 0, not 1 in the driver (scan_index didn't matter)
2. 1 or more scan_elements have to be enabled as you mentioned
2. When echoing into the sysfs files it has to have a space after the number (cat 1 > in_voltage0_en and not cat 1>in_vo…) (duh!)
3. The generic_buffer.c program had a few bugs in it causing crashes. I updated the iio_utils.h to a newer version I found here: https://github.com/analogdevicesinc/iio-oscilloscope and then made a few modifications (the newer iio_utils did not parse a few things right in the channel details like bigendian/littleendian)

Quoted 44 lines

So generic_buffer is now correctly sampling (although it crashes after a couple, it's probably another iio_utils issue)

Thanks!!

-chris

Quoted 34 lines · Lars-Peter Clausen
Quoted 4 lines · Jonathan Cameron
Quoted 3 lines · Chris Micali

lars,

I was under the impression that flag gets added automatically by iio_triggered_buffer_setup (industrialiio-triggers.c:77) - I actually am now able to enable the scan_element after changing my channel .channel and .scan_index to 0 (trying to match exactly the other drivers.)

Yea, you are right I missed the iio_triggered_buffer_setup part.

Quoted 3 lines

Strange, scan_index should have defaulted to zero and the .channel value shouldn't have mattered for buffered reads (just effects naming). Might have caused issues with userspace expecting a channel 0 though...

I guess the scan_index had nothing to do with this, but I suggested to set scan_elements/in_voltage0_en to 1, so this clearly wouldn't have worked with .channel being 1.

Quoted 2 lines
Quoted 2 lines

When i run general_buffer (from the docs dir) with that scan element enabled it can no longer read the trigger (Could not open /trigger/current_trigger Failed to write current_trigger file) - this succeeds if that scan_element is not enabled.

You can't change the trigger if the buffer is currently enabled. Make sure that he buffer is disabled (check the buffer/enable attribute).

- Lars
u

--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected] (mailto:[email protected]) More majordomo info at http://vger.kernel.org/majordomo-info.html

#13 lore raw
Quoted 1 line · Chris Micali

Thanks lars - i'm actually on 3.8, you don't happen to have a DT example do you?

uhm, should be just as simple:

hrtimer-trigger@0 {
	compatible = "iio-trigger-hrtimer";
};

You need to add the proper of match table to the driver though.

- Lars

Quoted 97 lines · Lars-Peter Clausen
Quoted 91 lines · Chris Micali
Quoted 4 lines

Last question :) I'd like to sample from this device as quickly as possible - so I'm assuming I need to trigger quickly? Should I use iio-trig-periodic-rtc? Any hints/instructions on how to use that? Should the driver supply it's own trigger that uses an hrtimer instead?

Thanks!
Chris

Hi,

There is a generic hrtimer based trigger:
https://github.com/lclausen-adi/linux-2.6/commit/a3b5c3f7aafbcac562d6f00a6589b110bd9fb71c

Unfortunately it's not upstream ready yet.

I can be registered via a platform_device

static struct platform_device iio_trigger_hrtimer = { .name = "iio-trigger-hrtimer",
.id = 0,
};

- Lars

Quoted 65 lines · Chris Micali
Quoted 9 lines

Guys,

Thanks a lot for the help! I finally tracked down issues, it was a combination of a few things:

1. The .channel had to be 0, not 1 in the driver (scan_index didn't matter)
2. 1 or more scan_elements have to be enabled as you mentioned
2. When echoing into the sysfs files it has to have a space after the number (cat 1 > in_voltage0_en and not cat 1>in_vo…) (duh!)
3. The generic_buffer.c program had a few bugs in it causing crashes. I updated the iio_utils.h to a newer version I found here: https://github.com/analogdevicesinc/iio-oscilloscope and then made a few modifications (the newer iio_utils did not parse a few things right in the channel details like bigendian/littleendian)

Quoted 44 lines

So generic_buffer is now correctly sampling (although it crashes after a couple, it's probably another iio_utils issue)

Thanks!!

-chris

Quoted 34 lines · Lars-Peter Clausen
Quoted 4 lines · Jonathan Cameron
Quoted 3 lines · Chris Micali

lars,

I was under the impression that flag gets added automatically by iio_triggered_buffer_setup (industrialiio-triggers.c:77) - I actually am now able to enable the scan_element after changing my channel .channel and .scan_index to 0 (trying to match exactly the other drivers.)

Yea, you are right I missed the iio_triggered_buffer_setup part.

Quoted 3 lines

Strange, scan_index should have defaulted to zero and the .channel value shouldn't have mattered for buffered reads (just effects naming). Might have caused issues with userspace expecting a channel 0 though...

I guess the scan_index had nothing to do with this, but I suggested to set scan_elements/in_voltage0_en to 1, so this clearly wouldn't have worked with .channel being 1.

Quoted 2 lines
Quoted 2 lines

When i run general_buffer (from the docs dir) with that scan element enabled it can no longer read the trigger (Could not open /trigger/current_trigger Failed to write current_trigger file) - this succeeds if that scan_element is not enabled.

You can't change the trigger if the buffer is currently enabled. Make sure that he buffer is disabled (check the buffer/enable attribute).

- Lars
u

--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected] (mailto:[email protected]) More majordomo info at http://vger.kernel.org/majordomo-info.html

#14 lore raw

I'll give it a shot - thanks!

Quoted 119 lines · Lars-Peter Clausen
Quoted 1 line · Chris Micali

Thanks lars - i'm actually on 3.8, you don't happen to have a DT example do you?

uhm, should be just as simple:

hrtimer-trigger@0 {
compatible = "iio-trigger-hrtimer";
};

You need to add the proper of match table to the driver though.

- Lars

Quoted 103 lines · Lars-Peter Clausen
Quoted 99 lines · Chris Micali
Quoted 4 lines

Last question :) I'd like to sample from this device as quickly as possible - so I'm assuming I need to trigger quickly? Should I use iio-trig-periodic-rtc? Any hints/instructions on how to use that? Should the driver supply it's own trigger that uses an hrtimer instead?

Thanks!
Chris

Hi,

There is a generic hrtimer based trigger:
https://github.com/lclausen-adi/linux-2.6/commit/a3b5c3f7aafbcac562d6f00a6589b110bd9fb71c

Unfortunately it's not upstream ready yet.

I can be registered via a platform_device

static struct platform_device iio_trigger_hrtimer = { .name = "iio-trigger-hrtimer",
.id = 0,
};

- Lars

Quoted 71 lines · Chris Micali
Quoted 9 lines

Guys,

Thanks a lot for the help! I finally tracked down issues, it was a combination of a few things:

1. The .channel had to be 0, not 1 in the driver (scan_index didn't matter)
2. 1 or more scan_elements have to be enabled as you mentioned
2. When echoing into the sysfs files it has to have a space after the number (cat 1 > in_voltage0_en and not cat 1>in_vo…) (duh!)
3. The generic_buffer.c program had a few bugs in it causing crashes. I updated the iio_utils.h to a newer version I found here: https://github.com/analogdevicesinc/iio-oscilloscope and then made a few modifications (the newer iio_utils did not parse a few things right in the channel details like bigendian/littleendian)

Quoted 48 lines

So generic_buffer is now correctly sampling (although it crashes after a couple, it's probably another iio_utils issue)

Thanks!!

-chris

Quoted 38 lines · Lars-Peter Clausen
Quoted 4 lines · Jonathan Cameron
Quoted 3 lines · Chris Micali

lars,

I was under the impression that flag gets added automatically by iio_triggered_buffer_setup (industrialiio-triggers.c:77) - I actually am now able to enable the scan_element after changing my channel .channel and .scan_index to 0 (trying to match exactly the other drivers.)

Yea, you are right I missed the iio_triggered_buffer_setup part.

Quoted 3 lines

Strange, scan_index should have defaulted to zero and the .channel value shouldn't have mattered for buffered reads (just effects naming). Might have caused issues with userspace expecting a channel 0 though...

I guess the scan_index had nothing to do with this, but I suggested to set scan_elements/in_voltage0_en to 1, so this clearly wouldn't have worked with .channel being 1.

Quoted 2 lines
Quoted 2 lines

When i run general_buffer (from the docs dir) with that scan element enabled it can no longer read the trigger (Could not open /trigger/current_trigger Failed to write current_trigger file) - this succeeds if that scan_element is not enabled.

You can't change the trigger if the buffer is currently enabled. Make sure that he buffer is disabled (check the buffer/enable attribute).

- Lars
u

--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected] (mailto:[email protected]) More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#15 lore raw
In reply to Chris Micali
Quoted 11 lines · Chris Micali

Guys,

Thanks a lot for the help! I finally tracked down issues, it was a combination of a few things:

1. The .channel had to be 0, not 1 in the driver (scan_index didn't matter)
2. 1 or more scan_elements have to be enabled as you mentioned
2. When echoing into the sysfs files it has to have a space after the number (cat 1 > in_voltage0_en and not cat 1>in_vo…) (duh!)
3. The generic_buffer.c program had a few bugs in it causing crashes. I updated the iio_utils.h to a newer version I found here: https://github.com/analogdevicesinc/iio-oscilloscope and then made a few modifications (the newer iio_utils did not parse a few things right in the channel details like bigendian/littleendian)

So generic_buffer is now correctly sampling (although it crashes after a couple, it's probably another iio_utils issue)

If you do track down why this is happening, please do report back so we can get it fixed. I wasn't previously aware of any particular issues in the example code so any feedback is helpful!

Looking foward to seeing the driver code when you are happy with it.

Jonathan

Quoted 36 lines

Thanks!!

-chris

Quoted 26 lines · Lars-Peter Clausen
Quoted 4 lines · Jonathan Cameron
Quoted 3 lines · Chris Micali

lars,

I was under the impression that flag gets added automatically by iio_triggered_buffer_setup (industrialiio-triggers.c:77) - I actually am now able to enable the scan_element after changing my channel .channel and .scan_index to 0 (trying to match exactly the other drivers.)

Yea, you are right I missed the iio_triggered_buffer_setup part.

Quoted 3 lines

Strange, scan_index should have defaulted to zero and the .channel value shouldn't have mattered for buffered reads (just effects naming). Might have caused issues with userspace expecting a channel 0 though...

I guess the scan_index had nothing to do with this, but I suggested to set scan_elements/in_voltage0_en to 1, so this clearly wouldn't have worked with .channel being 1.

Quoted 2 lines
Quoted 2 lines

When i run general_buffer (from the docs dir) with that scan element enabled it can no longer read the trigger (Could not open /trigger/current_trigger Failed to write current_trigger file) - this succeeds if that scan_element is not enabled.

You can't change the trigger if the buffer is currently enabled. Make sure that he buffer is disabled (check the buffer/enable attribute).

- Lars
u

#16 lore raw

Jonathan,

Thanks - I'll share back my findings this week.

One thing i've run into is throughput - it seems like the linux spi subsystem has a non-deterministic 50-150us delay before an spi_sync or spi_async command is processed. I can't seem to find any way around this - so if i use larger multi-byte transfers using spi_async and DMA I get great, stable throughput, but that is broken up by these 50-150us delays between transfers (i'm using the beagle bone, so AM3359 that has a dedicated SPI controller and DMA.)

Have any of you guys had success getting reliable >1MSPS throughput via IIO over SPI? It seems like this inherent delay in the SPI subsystem would make this pretty difficult.

-chris

Quoted 66 lines · Jonathan Cameron
Quoted 10 lines · Chris Micali

Guys,

Thanks a lot for the help! I finally tracked down issues, it was a combination of a few things:

1. The .channel had to be 0, not 1 in the driver (scan_index didn't matter)
2. 1 or more scan_elements have to be enabled as you mentioned
2. When echoing into the sysfs files it has to have a space after the number (cat 1 > in_voltage0_en and not cat 1>in_vo…) (duh!)
3. The generic_buffer.c program had a few bugs in it causing crashes. I updated the iio_utils.h to a newer version I found here: https://github.com/analogdevicesinc/iio-oscilloscope and then made a few modifications (the newer iio_utils did not parse a few things right in the channel details like bigendian/littleendian)

So generic_buffer is now correctly sampling (although it crashes after a couple, it's probably another iio_utils issue)

If you do track down why this is happening, please do report back so we can get it fixed. I wasn't previously aware of any particular issues in the example code so any feedback is helpful!

Looking foward to seeing the driver code when you are happy with it.

Jonathan

Quoted 45 lines

Thanks!!

-chris

Quoted 36 lines · Lars-Peter Clausen
Quoted 7 lines · Jonathan Cameron
Quoted 4 lines · Chris Micali

lars,

I was under the impression that flag gets added automatically by iio_triggered_buffer_setup (industrialiio-triggers.c:77) - I actually am now able to enable the scan_element after changing my channel .channel and .scan_index to 0 (trying to match exactly the other drivers.)

Yea, you are right I missed the iio_triggered_buffer_setup part.

Quoted 4 lines

Strange, scan_index should have defaulted to zero and the .channel value shouldn't have mattered for buffered reads (just effects naming). Might have caused issues with userspace expecting a channel 0 though...

I guess the scan_index had nothing to do with this, but I suggested to set scan_elements/in_voltage0_en to 1, so this clearly wouldn't have worked with .channel being 1.

Quoted 4 lines
Quoted 2 lines

When i run general_buffer (from the docs dir) with that scan element enabled it can no longer read the trigger (Could not open /trigger/current_trigger Failed to write current_trigger file) - this succeeds if that scan_element is not enabled.

You can't change the trigger if the buffer is currently enabled. Make sure that he buffer is disabled (check the buffer/enable attribute).

- Lars
u

#17 lore raw
Quoted 7 lines · Chris Micali

Jonathan,

Thanks - I'll share back my findings this week.

One thing i've run into is throughput - it seems like the linux spi subsystem has a non-deterministic 50-150us delay before an spi_sync or spi_async command is processed. I can't seem to find any way around this - so if i use larger multi-byte transfers using spi_async and DMA I get great, stable throughput, but that is broken up by these 50-150us delays between transfers (i'm using the beagle bone, so AM3359 that has a dedicated SPI controller and DMA.)

Have any of you guys had success getting reliable >1MSPS throughput via IIO over SPI? It seems like this inherent delay in the SPI subsystem would make this pretty difficult.

No, not really, I think I never used more than 100kHz so far. Are you sure the delay is really in the SPI subsystem and not just random interrupts kicking in?

I'm also curious did you implement your own IIO buffer, or are you just starting a large SPI transfer which samples multiple samples at once?

- Lars

Quoted 73 lines · Jonathan Cameron
Quoted 67 lines · Chris Micali
Quoted 10 lines

Guys,

Thanks a lot for the help! I finally tracked down issues, it was a combination of a few things:

1. The .channel had to be 0, not 1 in the driver (scan_index didn't matter)
2. 1 or more scan_elements have to be enabled as you mentioned
2. When echoing into the sysfs files it has to have a space after the number (cat 1 > in_voltage0_en and not cat 1>in_vo…) (duh!)
3. The generic_buffer.c program had a few bugs in it causing crashes. I updated the iio_utils.h to a newer version I found here: https://github.com/analogdevicesinc/iio-oscilloscope and then made a few modifications (the newer iio_utils did not parse a few things right in the channel details like bigendian/littleendian)

So generic_buffer is now correctly sampling (although it crashes after a couple, it's probably another iio_utils issue)

If you do track down why this is happening, please do report back so we can get it fixed. I wasn't previously aware of any particular issues in the example code so any feedback is helpful!

Looking foward to seeing the driver code when you are happy with it.

Jonathan

Quoted 45 lines

Thanks!!

-chris

Quoted 36 lines · Lars-Peter Clausen
Quoted 7 lines · Jonathan Cameron
Quoted 4 lines · Chris Micali

lars,

I was under the impression that flag gets added automatically by iio_triggered_buffer_setup (industrialiio-triggers.c:77) - I actually am now able to enable the scan_element after changing my channel .channel and .scan_index to 0 (trying to match exactly the other drivers.)

Yea, you are right I missed the iio_triggered_buffer_setup part.

Quoted 4 lines

Strange, scan_index should have defaulted to zero and the .channel value shouldn't have mattered for buffered reads (just effects naming). Might have caused issues with userspace expecting a channel 0 though...

I guess the scan_index had nothing to do with this, but I suggested to set scan_elements/in_voltage0_en to 1, so this clearly wouldn't have worked with .channel being 1.

Quoted 4 lines
Quoted 2 lines

When i run general_buffer (from the docs dir) with that scan element enabled it can no longer read the trigger (Could not open /trigger/current_trigger Failed to write current_trigger file) - this succeeds if that scan_element is not enabled.

You can't change the trigger if the buffer is currently enabled. Make sure that he buffer is disabled (check the buffer/enable attribute).

- Lars
u