Skip to content

#651 - #655

Closed
JakubVanek wants to merge 6 commits into
masterfrom
sysfsIfDifferent2
Closed

#651#655
JakubVanek wants to merge 6 commits into
masterfrom
sysfsIfDifferent2

Conversation

@JakubVanek

Copy link
Copy Markdown
Contributor

This implements the proposed write-if-different solution. Also, to actually make use of it, it uses auto mode for tacho motors.

- the kernel is smart enough to detect the tacho motor on its own

- the port is by default in auto mode, so this allows the use of
  write-if-different to handle this attribute write; this way
  the mode switch can be avoided entirely in the usual cases
@JakubVanek JakubVanek self-assigned this Mar 14, 2019
@JakubVanek
JakubVanek requested a review from jabrena March 14, 2019 20:32
- other platforms cannot detect a motor, but they are probably also a lot faster than EV3
  http://docs.ev3dev.org/projects/lego-linux-drivers/en/ev3dev-stretch/motors.html#motor-autodetect
@JakubVanek

Copy link
Copy Markdown
Contributor Author

I have now noticed that other platforms really do not work with auto mode. http://docs.ev3dev.org/projects/lego-linux-drivers/en/ev3dev-stretch/motors.html#motor-autodetect So now auto mode is used only on EV3.

@JakubVanek

JakubVanek commented May 21, 2019 •

Copy link
Copy Markdown
Contributor Author

The timeout issue can actually be reproduced with a medium motor on EV3 on the 2.3.4 kernel.
Code is in issue #663: #663 (comment)

2019-05-21 20:45:33 [main] ERROR ev3dev.utils.Sysfs - File: '/sys/class/tacho-motor/motor3/command' without write permissions.
Exception in thread "main" java.lang.RuntimeException: Operation not executed: /sys/class/tacho-motor/motor3/command with value reset
	at ev3dev.hardware.EV3DevDevice.setStringAttribute(EV3DevDevice.java:118)
	at ev3dev.actuators.lego.motors.BaseRegulatedMotor.<init>(BaseRegulatedMotor.java:95)
	at ev3dev.actuators.lego.motors.EV3MediumRegulatedMotor.<init>(EV3MediumRegulatedMotor.java:26)
	at issues.Issue663.main(Issue663.java:8)

EDIT: the issue is happening on a brick overclocked to 456 MHz.

@JakubVanek JakubVanek mentioned this pull request May 30, 2019
5 tasks done
@JakubVanek

JakubVanek commented May 30, 2019 •

Copy link
Copy Markdown
Contributor Author

Tested on 4.14.117-ev3dev-2.3.4-ev3 kernel on EV3. Other platforms shouldn't be affected. They also use the write-if-different solution now, but they are still using TACHO_MOTOR mode and not the AUTO_MODE.

package issues;

import ev3dev.actuators.lego.motors.EV3MediumRegulatedMotor;
import lejos.hardware.port.MotorPort;

public class Issue655 {
    public static void main(String[] args) {
        for (int i = 0; i < 10; i++) {
            EV3MediumRegulatedMotor m = new EV3MediumRegulatedMotor(MotorPort.D);
            m.stop();
        }
    }
}

Before the fix, with 300 MHz CPU clock and a medium motor in port D, this crashes on the first iteration. With the fix, all ten iterations succeed.

@JakubVanek

JakubVanek commented Sep 2, 2019 •

Copy link
Copy Markdown
Contributor Author

This PR makes the BaseRegulatedMotor delay less necessary - it avoids triggering the udev asynchronous process if the port is already in the correct mode. This can be felt the most on the EV3 platform.

The crashes were worked around by increasing the delay to 1000ms, however I have done it only in the BaseRegulatedMotor and not in BasicMotor.

@JakubVanek

Copy link
Copy Markdown
Contributor Author

Rejected by weighing testing difficulty

@JakubVanek JakubVanek closed this Dec 1, 2019
@JakubVanek JakubVanek reopened this Dec 2, 2019
@jabrena

jabrena commented Apr 18, 2020

Copy link
Copy Markdown
Member

Rejected

@jabrena jabrena closed this Apr 18, 2020
@jabrena
jabrena deleted the sysfsIfDifferent2 branch April 18, 2020 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants