Skip to content

Ensure that Motor/Sensor folders was created by EV3Dev #555

Open

Description

@jabrena

After one user question:
#554

maybe it is the moment to fix this possible bad user experience in the proper way. Currently, the library wait 0.5 seconds (Fixed period of time) in order that Linux+EV3Dev process mount the folder about the motor/sensor with all information.

    public BaseRegulatedMotor(final Port motorPort, float moveP, float moveI, float moveD,
                              float holdP, float holdI, float holdD, int offset, int maxSpeed) {

        List<RegulatedMotorListener> list = new ArrayList<>();
        listenerList = Collections.synchronizedList(list);

        if(log.isInfoEnabled())
            log.info("Configuring motor connected on Port: {}", motorPort.getName());

        MAX_SPEED_AT_9V = maxSpeed;
        final EV3DevPlatforms ev3DevPlatforms = EV3DevPlatforms.getInstance();
        final String port = ev3DevPlatforms.getMotorPort(motorPort);

        if(log.isDebugEnabled())
            log.debug("Detecting motor on port: {}", port);
        this.detect(LEGO_PORT, port);
        if(log.isDebugEnabled())
            log.debug("Setting port in mode: {}", TACHO_MOTOR);
        this.setStringAttribute(MODE, TACHO_MOTOR);
        Delay.msDelay(500);
        this.detect(TACHO_MOTOR, port);
        Delay.msDelay(500);
        this.setStringAttribute(COMMAND, RESET);
        if(log.isDebugEnabled())
            log.debug("Motor ready to use on Port: {}",motorPort.getName());
    }

Maybe, it could be interesting to create a POC to see what is the best approach to do it.

Basically, we should introduce a asynchronous process to wait for the existency of a determinated number of folders.

Activity

  1. changed the title [-]Ensure that Motor/Sensor folders was created by EV3Dev properly[/-] [+]Ensure that Motor/Sensor folders was created by EV3Dev[/+] on Nov 8, 2018
  2. jabrena commented on Nov 8, 2018

    @jabrena
    MemberAuthor

    Analysis:

    any motor folder in EV3Dev has the following content:

    
    robot@ev3dev:/sys/class/tacho-motor/motor0$ ls
    address        driver_name    polarity      ramp_up_sp  stop_action
    command        duty_cycle     position      speed       stop_actions
    commands       duty_cycle_sp  position_sp   speed_pid   subsystem
    count_per_rot  hold_pid       power         speed_sp    time_sp
    device         max_speed      ramp_down_sp  state       uevent
    
    • What are the folders/files used in the library?

    In the class EV3DevMotorDevice exist the description about all files/folders used. It could be necessary to create some kind of datastructure to interate and verify the existence.

    The file doesn't differenciate between files, folders and states. It is a refactoring point.

        protected static final String POSITION_SP = "position_sp";
        protected static final String POSITION = "position";
        protected static final String SPEED = "speed_sp";
        protected static final String DUTY_CYCLE = "duty_cycle_sp";
        protected static final String COMMAND = "command";
        protected static final String STOP_COMMAND = "stop_action";
        protected static final String STATE = "state";
        protected static final String POLARITY = "polarity";
    

    For this POC, we will group this files in a map to iterate ina

  3. jabrena commented on Nov 8, 2018

    @jabrena
    MemberAuthor

    One idea from StackOverflow to manage retry behavior:
    https://stackoverflow.com/questions/40485398/retry-logic-with-completablefuture

  4. modified the milestone: v1.1.0 on Nov 24, 2018
  5. self-assigned this
    on Aug 18, 2019
  6. added this to the v1.0.0 milestone on Aug 18, 2019
  7. JakubVanek commented on Sep 2, 2019

    @JakubVanek
    Contributor

    List of udev events:

    udevadm monitor
    

    View files in a folder with permissions:

    ls -la /some/path
    

    What to check:

  8. modified the milestones: v1.0.0, v1.1.0 on Dec 2, 2019
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

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions