Skip to content

How do I detect events from sensors? #104

Closed

Description

@eahutchins

I just tried tail -f /sys/class/msensor/sensor0/value0 and didn't see the value change as I tried toggling a touch sensor... is there a way to select/poll on /sys fs mounts, or more broadly how do I get asynchronous notifications of sensor changes?

Activity

  1. dlech commented on Jul 18, 2014

    @dlech
    Member

    sysfs does have a mechanism for select/poll, but we have not implemented it with sensors yet, but we do intend to. It is not something that just happens automatically.

  2. self-assigned this
    on Jul 18, 2014
  3. eahutchins commented on Jul 18, 2014

    @eahutchins
    Author

    I've worked on embedded systems before and could help out, is there a guide for getting up and running with the latest ev3dev kernel development environment? I think I see how to set up a debian/jessie VM and get brickstrap up and running, but having all the needed config files in one place would be really helpful.

  4. dlech commented on Jul 18, 2014

    @dlech
    Member

    For kernel hacking we cross compile instead of using brickstrap. See https://github.com/ev3dev/ev3dev-buildscripts. This might be a bit out of date, so don't hesitate to ask questions here or on IRC.

    My basic work flow is like this.

    • Follow the instructions in https://github.com/ev3dev/ev3dev-buildscripts#sharing-your-kernel.
    • Once you have installed the debian package that you created, you can then replace the uImage and modules directly without having to build another debian package (as long as you don't change the version number). See https://github.com/ev3dev/ev3dev-buildscripts/blob/master/setup-env for how to get the build scripts to install the generated files wherever you want. If you setup NFS, then you can tell it to install directly on your EV3 while it is up and running.
    • Most drivers are modules, so I modprobe -r <module>, compile (which automatically copies over the existing .ko file, and them modprobe <module>. This way I don't have to reboot every time I make a change.

    We aren't planning on doing much more with wheezy and are focusing on jessie now, so you will want the kernel from ev3dev/ev3dev-kernel, not the one at mindboards/ev3dev-kernel.

    And finally, the file you need to modify is https://github.com/ev3dev/ev3dev-kernel/blob/ev3dev-jessie/drivers/legoev3/msensor_class.c. sysfs_notify is the function that you need to add. Here is how Ralph implemented sysfs_notify for motors: ev3dev/ev3-kernel@f7557cd and here is how I fixed it because you can't call sysfs_notify from an atomic context: ev3dev/ev3-kernel@0ca28cf.

    I am also thinking that we may want a switch to turn this on and off. My concern is that this may take up quite a bit of CPU - at least for sensors that change values rapidly. If this is the case, we would want sysfs_notify disabled by default. Then users could enable it only if they really wanted it.

    This should keep your busy for a while. 😄

  5. rhempel commented on Jul 19, 2014

    @rhempel
    Member

    Yeah, I think we'd want to be able to turn sensor notifications off and on by setting limits. This would be similar to how I implemented ramping in the motor drivers - ramp value 0 means no ramping...

  6. eahutchins commented on Jul 24, 2014

    @eahutchins
    Author

    I've managed to build the kernel under docker (I'm a linux laptop guy) using the ubuntu:latest (14.04) image.

    I had to replace the uboot-mkimage package with u-boot-tools, and install bc (sudo apt-get install bc). I got some warnings:

    ERROR: ld.so: object 'libfakeroot-sysv.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS64): ignored.
    

    but I ignored them :-)

    sudo dpkg --install *.deb
    reboot
    

    seems to have worked but undone all my network/zeroconf setup.

  7. dlech commented on Jul 24, 2014

    @dlech
    Member

    Thanks for the feedback. I have updated the script and README accordingly.

    Not sure why it would wipe out your network/zeroconf setup though.

  8. eahutchins commented on Jul 24, 2014

    @eahutchins
    Author

    I think my rechargeable batteries were picking that exact moment to call it quits (the brick would boot and then power off after a few minutes)... recharging them now.

    When I get all this working correctly I'll make an ev3dev docker image which should simplify setting up the build environment a lot.

  9. eahutchins commented on Aug 7, 2014

    @eahutchins
    Author

    I've finally gotten some time to work on this again (recharged the batteries), USB networking is working but wifi doesn't. I've got the realtek 0bda:8179 USB dongle which was working fine with the prebuilt kernel, the kernel I've built:

    e68ec8a (HEAD, origin/ev3dev-jessie, origin/HEAD, ev3dev-jessie) enable IPV6
    

    seems to be missing the module. Should I use https://github.com/ev3dev/ev3dev/releases/tag/v00.01.01-rtl8188eu-module?

  10. rhempel commented on Aug 7, 2014

    @rhempel
    Member

    Yes, known issue and will be adressed in the next kernel release. Fo now, just use the module, run depmod and the next time you plug in the dongle it should magically work!

  11. eahutchins commented on Aug 7, 2014

    @eahutchins
    Author
  12. dlech commented on Aug 7, 2014

    @dlech
    Member

    Sorry, that is old info. We are now building the rtl8188eu module as a debian package that gets distributed with the kernel. https://github.com/ev3dev/rtl8188eu. Since you are building your own kernel, you will have to compile it separately - not as a debian package, but using the same source code. It should be pretty straight forward. You can ping me on IRC if you need help figuring it out.

  13. dlech commented on Dec 12, 2015

    @dlech
    Member

    This is something that has come up again more recently. My current line of thought is that the best way to do this is using a character device similar to the Linux input/event subsystem.

  14. dlech commented on Jan 10, 2016

    @dlech
    Member

    I'm closing this issue in favor of #498 since this issue is quite old and no longer has much relevant information. Any further comments should be made on #498.

  15. WasabiFan commented on Jan 10, 2016

    @WasabiFan
    Member

    I'm closing this issue...

    Uhhhh... the issue is still open half an hour later 😉 Any chance that you forgot about the "closing" bit?

  16. dlech commented on Jan 10, 2016

    @dlech
    Member

    must have hit the wrong button.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions