Skip to content

EV3-G API: buttons #354

Closed
Closed

Description

@dwalton76

buttons-01

Activity

  1. dwalton76 commented on Sep 23, 2017

    @dwalton76
    CollaboratorAuthor

    What we have right now for class Button in ev3dev/ev3.py looks pretty good to me. Is there anything to be done for this one?

    PS
    How does one use the on_left(), etc methods?

  2. dwalton76 commented on Sep 26, 2017

    @dwalton76
    CollaboratorAuthor

    @WasabiFan @dlech can you spot anything that we are missing to be EV3-G 1:1? If not lets close this one.

  3. dlech commented on Sep 26, 2017

    @dlech
    Member

    How do you wait for a button to be pressed/released/bumped?

  4. dwalton76 commented on Sep 26, 2017

    @dwalton76
    CollaboratorAuthor

    We don't have a way to do that but from looking at the EV3-G block it doesn't either? It sounds useful though (and we have it for TouchSensor), we can add it.

  5. dlech commented on Sep 26, 2017

    @dlech
    Member

    And what about bumped?

  6. dwalton76 commented on Sep 26, 2017

    @dwalton76
    CollaboratorAuthor

    I'll add pressed, released and bumped

  7. dlech commented on Sep 26, 2017

    @dlech
    Member

    Here is a more fleshed out view of the EV3-G buttons blocks:

    image

    image

    image

    image

    image

  8. dwalton76 commented on Sep 27, 2017

    @dwalton76
    CollaboratorAuthor

    @dlech for EVB what should its _buttons be now? This is what we have for EV3

        _buttons = { 
                'up': {'name': '/dev/input/by-path/platform-gpio_keys-event', 'value': 103},
                'down': {'name': '/dev/input/by-path/platform-gpio_keys-event', 'value': 108},
                'left': {'name': '/dev/input/by-path/platform-gpio_keys-event', 'value': 105},
                'right': {'name': '/dev/input/by-path/platform-gpio_keys-event', 'value': 106},
                'enter': {'name': '/dev/input/by-path/platform-gpio_keys-event', 'value': 28},
                'backspace': {'name': '/dev/input/by-path/platform-gpio_keys-event', 'value': 14},
            }
    

    EVB barfs on

    robot@evb[bin]# ./buttons.py 
    Traceback (most recent call last):
      File "./buttons.py", line 19, in <module>
        btn = Button()
      File "/usr/local/lib/python3.5/dist-packages/python_ev3dev-0.8.0.post69-py3.5.egg/ev3dev/core.py", line 3178, in __init__
    FileNotFoundError: [Errno 2] No such file or directory: '/dev/input/by-path/platform-gpio_keys-event'
    robot@evb[bin]# 
    

    Am running this on my EVB:

    robot@evb[ev3dev-lang-python]# ev3dev-sysinfo 
    Image file:         ev3dev-stretch-bone-generic-2017-09-01
    Kernel version:     4.9.41-ev3dev-1.4.0-bb.org
    /usr/bin/ev3dev-sysinfo: line 68: warning: command substitution: ignored null byte in input
    Board:              TI AM335x BeagleBone Black
    Revision:           000c
    Brickman:           0.10.0
    ev3devKit:          0.5.2
    robot@evb[ev3dev-lang-python]# 
    
  9. dwalton76 commented on Sep 27, 2017

    @dwalton76
    CollaboratorAuthor

    you know what, I probably need to update my EVB, ignore this for a bit

  10. dwalton76 commented on Sep 27, 2017

    @dwalton76
    CollaboratorAuthor

    nope same issue

    robot@evb[bin]# ev3dev-sysinfo 
    Image file:         ev3dev-stretch-bone-generic-2017-09-01
    Kernel version:     4.9.50-ev3dev-1.5.1-bb.org
    Brickman:           0.10.0
    ev3devKit:          0.5.2
    Board:              board0
    BOARD_INFO_HW_REV=000C
    BOARD_INFO_MODEL=A335BNLT
    BOARD_INFO_SERIAL_NUM=4214BBBK2552
    BOARD_INFO_TYPE=main
    Board:              board1
    BOARD_INFO_MODEL=FatcatLab EVB
    BOARD_INFO_TYPE=aux
    robot@evb[bin]# 
    
  11. dlech commented on Sep 27, 2017

    @dlech
    Member
    robot@ev3dev-bbg:~$ ls /dev/input/by-path/
    platform-44e0b000.i2c-platform-tps65217-pwrbutton-event  platform-evb-sound-event
    platform-evb-buttons-event
    

    Looks like /dev/input/by-path/platform-evb-buttons-event will work.

  12. dwalton76 commented on Sep 28, 2017

    @dwalton76
    CollaboratorAuthor

    Will the kernel set select.POLLPRI when /dev/input/by-path/platform-evb-buttons-event is modified? It doesn't seem to be...the _wait() that I wrote is almost identical to the one used by TouchSensor but I never get an event that the file changed.

  13. dlech commented on Sep 28, 2017

    @dlech
    Member

    Try select.POLLIN. It is rare to use POLLPRI.

  14. dwalton76 commented on Sep 28, 2017

    @dwalton76
    CollaboratorAuthor

    ok it turns out polling for TouchSensor isn't working, I just thought it was because POLLIN never blocks. What I am seeing...

    Motor wait()

    • POLLPRI blocks until the file is touched, perfect
    • POLLIN does not block

    TouchSensor _wait()

    • POLLPRI does not block
    • POLLIN does not block

    buttons _wait()

    • POLLPRI blocks but doesn't fire when the file is touched
    • POLLIN does not block
  15. dlech commented on Sep 28, 2017

    @dlech
    Member

    Which kernel version? POLLIN is working for me on 4.9.49-ev3dev-1.5.1-ev3 on motors and buttons (haven't tried sensors).

  16. dlech commented on Sep 28, 2017

    @dlech
    Member

    Actually, I take that back about buttons. I'm just reading directly on a background thread without polling. read blocks until there is data available.

  17. dwalton76 commented on Sep 28, 2017

    @dwalton76
    CollaboratorAuthor
    robot@evb[ev3dev-lang-python]# ev3dev-sysinfo 
    Image file:         ev3dev-stretch-bone-generic-2017-09-01
    Kernel version:     4.9.50-ev3dev-1.5.1-bb.org
    Brickman:           0.10.0
    ev3devKit:          0.5.2
    Board:              board0
    BOARD_INFO_MODEL=FatcatLab EVB
    BOARD_INFO_TYPE=aux
    Board:              board1
    BOARD_INFO_HW_REV=000C
    BOARD_INFO_MODEL=A335BNLT
    BOARD_INFO_SERIAL_NUM=4214BBBK2552
    BOARD_INFO_TYPE=main
    robot@evb[ev3dev-lang-python]# 
    
  18. dwalton76 commented on Sep 29, 2017

    @dwalton76
    CollaboratorAuthor

    @dlech want me to file an issue for POLLIN support on motors, sensors and buttons files? Either that or POLLPRI for all three.

  19. dlech commented on Sep 29, 2017

    @dlech
    Member

    POLLIN works for me, so I can't really help much unless you have some code to reproduce the problem. I suspect that there is a problem with your code rather than a problem with ev3dev.

  20. dwalton76 commented on Sep 29, 2017

    @dwalton76
    CollaboratorAuthor

    I haven't used poll much, I just followed what was done for motors. Here is what I did for TouchSensor:
    https://github.com/rhempel/ev3dev-lang-python/blob/develop/ev3dev/core.py#L2275-L2285

    and here is the motors equivalent
    https://github.com/rhempel/ev3dev-lang-python/blob/develop/ev3dev/core.py#L920-L940

  21. dlech commented on Sep 29, 2017

    @dlech
    Member

    I don't see that notification for sensors was ever implemented, so I don't expect that to work.

    ev3dev/ev3dev#498

  22. self-assigned this
    on Sep 30, 2017
  23. dlech commented on Oct 2, 2017

    @dlech
    Member

    After a bit more research, it seems that poll with sysfs only support POLLPRI, so what you observed with the motor state sysfs attribute is the expected behavior.

  24. dlech commented on Oct 2, 2017

    @dlech
    Member

    Another thing is that if you have never read a file, poll won't block. So you have to read at least once before calling poll if you want to see it block.

  25. dwalton76 commented on Oct 3, 2017

    @dwalton76
    CollaboratorAuthor

    Ack will fix that for motors, that is the only place we are using POLLPRI

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions