Skip to content

ERROR ev3dev.utils.Sysfs - File: '/sys/class/tacho-motor/motor9/command' without write permissions. #554

Closed

Description

@robl0377

Have installed ev3dev on debian stretch on my EV3 Brick and tried the sample program
example.robotics.ev3.actuator.motor.BasicMotorOperationExample from yesterday's template-project-gradle:

package example.robotics.ev3.actuator.motor;

import ev3dev.actuators.lego.motors.EV3LargeRegulatedMotor;
import lejos.hardware.port.MotorPort;
import lejos.utility.Delay;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

class BasicMotorOperationExample {
    public static final EV3LargeRegulatedMotor mA = new EV3LargeRegulatedMotor(MotorPort.B);
    public static Logger LOGGER = LoggerFactory.getLogger(BasicMotorOperationExample.class);
    public static int DELAY = 2000; //2 Seconds

    public static void main(String[] args) {
        mA.brake();
        LOGGER.info("Starting motor on B");
        mA.setSpeed(500);
        LOGGER.info("Forward");
        mA.forward();
        LOGGER.info("Large Motor is moving: {}, at speed {}", mA.isMoving(), mA.getSpeed());
        Delay.msDelay(DELAY);
        LOGGER.info("Stop");
        mA.stop();
        LOGGER.info("Large Motor is moving: {}, at speed {}", mA.isMoving(), mA.getSpeed());
        Delay.msDelay(DELAY);
        LOGGER.info("Backward");
        mA.backward();
        LOGGER.info("Large Motor is moving: {}, at speed {}", mA.isMoving(), mA.getSpeed());
        Delay.msDelay(2000);
        LOGGER.info("Stop");
        mA.stop();
        LOGGER.info("Large Motor is moving: {}, at speed {}", mA.isMoving(), mA.getSpeed());
        Delay.msDelay(DELAY);
        LOGGER.info("Forward");
        mA.forward();
        Delay.msDelay(2000);
        mA.stop();
        LOGGER.info("Stop");
    }
}

On the ssh console I get this:

> Task :remoteRun
java -server -jar /home/robot/EV3dev_Examples-all-0.3.0.jar 
ev3dev#27|2018-11-07 11:51:05 [main] DEBUG ev3dev.hardware.EV3DevDistros - Debian Stretch detected
ev3dev#27|2018-11-07 11:51:06 [main] DEBUG ev3dev.hardware.EV3DevDistros - Debian Stretch detected
ev3dev#27|2018-11-07 11:51:06 [main] DEBUG ev3dev.hardware.EV3DevFileSystem - Root Path: /sys/class
ev3dev#27|2018-11-07 11:51:07 [main] INFO  e.a.lego.motors.BaseRegulatedMotor - Configuring motor connected on Port: B
ev3dev#27|2018-11-07 11:51:07 [main] DEBUG e.a.lego.motors.BaseRegulatedMotor - Detecting motor on port: ev3-ports:outB
ev3dev#27|2018-11-07 11:51:07 [main] DEBUG ev3dev.hardware.EV3DevDevice - Detected device on path: /sys/class/lego-port/port5/address, ev3-ports:outB
ev3dev#27|2018-11-07 11:51:07 [main] DEBUG e.a.lego.motors.BaseRegulatedMotor - Setting port in mode: tacho-motor
ev3dev#27|2018-11-07 11:51:08 [main] DEBUG ev3dev.hardware.EV3DevDevice - Detected device on path: /sys/class/tacho-motor/motor9/address, ev3-ports:outB
ev3dev#27|2018-11-07 11:51:09 [main] ERROR ev3dev.utils.Sysfs - File: '/sys/class/tacho-motor/motor9/command' without write permissions.
ev3dev#27|Exception in thread "main" java.lang.ExceptionInInitializerError
ev3dev#27|Caused by: java.lang.RuntimeException: Operation not executed: /sys/class/tacho-motor/motor9/command with value reset
ev3dev#27|	at ev3dev.hardware.EV3DevDevice.setStringAttribute(EV3DevDevice.java:118)
ev3dev#27|	at ev3dev.actuators.lego.motors.BaseRegulatedMotor.<init>(BaseRegulatedMotor.java:94)
ev3dev#27|	at ev3dev.actuators.lego.motors.EV3LargeRegulatedMotor.<init>(EV3LargeRegulatedMotor.java:26)
ev3dev#27|	at example.robotics.ev3.actuator.motor.BasicMotorOperationExample.<clinit>(BasicMotorOperationExample.java:16)

Java Runtime:

openjdk version "10" 2018-03-20
OpenJDK Runtime Environment (build 10+46-ev3)
OpenJDK Client VM (build 10+46-ev3, mixed mode, sharing)

Main libraries:

  • ev3dev-lang-java-2.4.7-SNAPSHOT.jar
  • lejos-commons-0.7.1.jar

However, it works on Oracle Java 8

java version "1.8.0"
Java(TM) SE Embedded Runtime Environment (build 1.8.0-b132, headless)
Java HotSpot(TM) Embedded Client VM (build 25.0-b70, mixed mode)

Activity

  1. robl0377 commented on Nov 7, 2018

    @robl0377
    Author

    After a reboot of the EV3 Brick I tried it again and it worked with both JDK 8 and JDK 10 just fine!

  2. robl0377 commented on Nov 8, 2018

    @robl0377
    Author

    Got a similar error today when running the ev3dev.actuators.lego.motors.UnregulatedMotorDemo on the same EV3 brick with OpenJDK 10:

    package ev3dev.actuators.lego.motors;
    import lejos.hardware.port.MotorPort;
    import lejos.utility.Delay;
    public class UnregulatedMotorDemo {
    	// Motor Definition
    	private static UnregulatedMotor umotor1 = new UnregulatedMotor(MotorPort.C);
    	// Configuration
    	private final static int motorPower = 50;
    	private final static int ONE_SECOND = 1000;
    
    	public static void main(String[] args) {
    		System.out.println("UnregulatedMotorDemo: Set Motor Power");
    		// Set power for DC Motor
    		umotor1.setPower(motorPower);
    		// Testing DC-Motor 1
    		umotor1.forward();
    		System.out.println("forward: " + umotor1.isMoving());
    		Delay.msDelay(ONE_SECOND);
    		umotor1.stop();
    		System.out.println("stop: " + umotor1.isMoving());
    		umotor1.backward();
    		System.out.println("backward: " + umotor1.isMoving());
    		Delay.msDelay(ONE_SECOND);
    		umotor1.stop();
    		System.out.println("stop: " + umotor1.isMoving());
    		umotor1.forward();
    		System.out.println("forward: " + umotor1.isMoving());
    		Delay.msDelay(ONE_SECOND);
    		umotor1.stop();
    		System.out.println("stop: " + umotor1.isMoving());
    	}
    }

    On the ssh console I get this:

    > Task :remoteRun
    Host key checking is off. It may be vulnerable to man-in-the-middle attacks.
    java -server -jar /home/robot/EV3dev-java-systemtests-2.4.7-SNAPSHOT-all.jar 
    
    ev3dev#47|2018-11-08 09:49:09 [main] DEBUG ev3dev.hardware.EV3DevDistros - Debian Stretch detected
    ev3dev#47|2018-11-08 09:49:10 [main] DEBUG ev3dev.hardware.EV3DevDistros - Debian Stretch detected
    ev3dev#47|2018-11-08 09:49:10 [main] DEBUG ev3dev.hardware.EV3DevFileSystem - Root Path: /sys/class
    ev3dev#47|2018-11-08 09:49:10 [main] TRACE ev3dev.utils.Sysfs - ls /sys/class/power_supply/lego-ev3-battery
    ev3dev#47|2018-11-08 09:49:10 [main] TRACE ev3dev.hardware.EV3DevPlatformsImpl - Detected platform: EV3BRICK
    ev3dev#47|2018-11-08 09:49:10 [main] TRACE ev3dev.hardware.EV3DevDevice - Retrieving devices in path: 
    ev3dev#47|2018-11-08 09:49:10 [main] TRACE ev3dev.utils.Sysfs - ls /sys/class/lego-port
    ev3dev#47|2018-11-08 09:49:10 [main] TRACE ev3dev.hardware.EV3DevDevice - Checking devices on: /sys/class/lego-port
    ev3dev#47|2018-11-08 09:49:10 [main] TRACE ev3dev.hardware.EV3DevDevice - Device 1:
    ev3dev#47|2018-11-08 09:49:10 [main] TRACE ev3dev.utils.Sysfs - cat /sys/class/lego-port/port6/address
    ev3dev#47|2018-11-08 09:49:11 [main] TRACE ev3dev.utils.Sysfs - value: ev3-ports:outC
    ev3dev#47|2018-11-08 09:49:11 [main] TRACE ev3dev.hardware.EV3DevDevice - Port expected: ev3-ports:outC, actual: ev3-ports:outC.
    ev3dev#47|2018-11-08 09:49:11 [main] DEBUG ev3dev.hardware.EV3DevDevice - Detected device on path: /sys/class/lego-port/port6/address, ev3-ports:outC
    ev3dev#47|2018-11-08 09:49:11 [main] TRACE ev3dev.utils.Sysfs - echo dc-motor > /sys/class/lego-port/port6/mode
    ev3dev#47|2018-11-08 09:49:11 [main] TRACE ev3dev.hardware.EV3DevDevice - Retrieving devices in path: 
    ev3dev#47|2018-11-08 09:49:11 [main] TRACE ev3dev.utils.Sysfs - ls /sys/class/dc-motor
    ev3dev#47|2018-11-08 09:49:12 [main] TRACE ev3dev.hardware.EV3DevDevice - Checking devices on: /sys/class/dc-motor
    ev3dev#47|2018-11-08 09:49:12 [main] TRACE ev3dev.hardware.EV3DevDevice - Device 1:
    ev3dev#47|2018-11-08 09:49:12 [main] TRACE ev3dev.utils.Sysfs - cat /sys/class/dc-motor/motor2/address
    ev3dev#47|2018-11-08 09:49:12 [main] TRACE ev3dev.utils.Sysfs - value: ev3-ports:outC
    ev3dev#47|2018-11-08 09:49:12 [main] TRACE ev3dev.hardware.EV3DevDevice - Port expected: ev3-ports:outC, actual: ev3-ports:outC.
    ev3dev#47|2018-11-08 09:49:12 [main] DEBUG ev3dev.hardware.EV3DevDevice - Detected device on path: /sys/class/dc-motor/motor2/address, ev3-ports:outC
    ev3dev#47|UnregulatedMotorDemo: Set Motor Power
    ev3dev#47|2018-11-08 09:49:12 [main] TRACE ev3dev.utils.Sysfs - echo 50 > /sys/class/dc-motor/motor2/duty_cycle_sp
    ev3dev#47|2018-11-08 09:49:12 [main] ERROR ev3dev.utils.Sysfs - File: '/sys/class/dc-motor/motor2/duty_cycle_sp' without write permissions.
    ev3dev#47|Exception in thread "main" java.lang.RuntimeException: Operation not executed: /sys/class/dc-motor/motor2/duty_cycle_sp with value 50
    ev3dev#47|	at ev3dev.hardware.EV3DevDevice.setIntegerAttribute(EV3DevDevice.java:131)
    ev3dev#47|	at ev3dev.actuators.lego.motors.BasicMotor.setPower(BasicMotor.java:56)
    ev3dev#47|	at ev3dev.actuators.lego.motors.UnregulatedMotorDemo.main(UnregulatedMotorDemo.java:19)
    
    > Task :remoteRun FAILED
    Failed command ev3dev#47 with status 1: java -server -jar /home/robot/EV3dev-java-systemtests-2.4.7-SNAPSHOT-all.jar 
    
    FAILURE: Build failed with an exception.
    

    You can run it several times on OpenJDK 10, it always gives this error.
    However then running on the Oracle JDK 8 it works fine.
    After the Oracle JDK 8 run I tried it with OpenJDK 10 again: same error.
    Rebooted the EV3..
    Running on OpenJDK 10 again: same error:

    robot@ev3dev:~$ java -jar EV3dev-java-systemtests-2.4.7-SNAPSHOT-all.jar
    2018-11-08 10:10:19 [main] DEBUG ev3dev.hardware.EV3DevDistros - Debian Stretch detected
    2018-11-08 10:10:19 [main] DEBUG ev3dev.hardware.EV3DevDistros - Debian Stretch detected
    2018-11-08 10:10:19 [main] DEBUG ev3dev.hardware.EV3DevFileSystem - Root Path: /sys/class
    2018-11-08 10:10:20 [main] TRACE ev3dev.utils.Sysfs - ls /sys/class/power_supply/lego-ev3-battery
    2018-11-08 10:10:20 [main] TRACE ev3dev.hardware.EV3DevPlatformsImpl - Detected platform: EV3BRICK
    2018-11-08 10:10:20 [main] TRACE ev3dev.hardware.EV3DevDevice - Retrieving devices in path:
    2018-11-08 10:10:20 [main] TRACE ev3dev.utils.Sysfs - ls /sys/class/lego-port
    2018-11-08 10:10:20 [main] TRACE ev3dev.hardware.EV3DevDevice - Checking devices on: /sys/class/lego-port
    2018-11-08 10:10:20 [main] TRACE ev3dev.hardware.EV3DevDevice - Device 1:
    2018-11-08 10:10:20 [main] TRACE ev3dev.utils.Sysfs - cat /sys/class/lego-port/port6/address
    2018-11-08 10:10:20 [main] TRACE ev3dev.utils.Sysfs - value: ev3-ports:outC
    2018-11-08 10:10:20 [main] TRACE ev3dev.hardware.EV3DevDevice - Port expected: ev3-ports:outC, actual: ev3-ports:outC.
    2018-11-08 10:10:20 [main] DEBUG ev3dev.hardware.EV3DevDevice - Detected device on path: /sys/class/lego-port/port6/address, ev3-ports:outC
    2018-11-08 10:10:20 [main] TRACE ev3dev.utils.Sysfs - echo dc-motor > /sys/class/lego-port/port6/mode
    2018-11-08 10:10:21 [main] TRACE ev3dev.hardware.EV3DevDevice - Retrieving devices in path:
    2018-11-08 10:10:21 [main] TRACE ev3dev.utils.Sysfs - ls /sys/class/dc-motor
    2018-11-08 10:10:21 [main] TRACE ev3dev.hardware.EV3DevDevice - Checking devices on: /sys/class/dc-motor
    2018-11-08 10:10:21 [main] TRACE ev3dev.hardware.EV3DevDevice - Device 1:
    2018-11-08 10:10:21 [main] TRACE ev3dev.utils.Sysfs - cat /sys/class/dc-motor/motor0/address
    2018-11-08 10:10:21 [main] TRACE ev3dev.utils.Sysfs - value: ev3-ports:outC
    2018-11-08 10:10:21 [main] TRACE ev3dev.hardware.EV3DevDevice - Port expected: ev3-ports:outC, actual: ev3-ports:outC.
    2018-11-08 10:10:21 [main] DEBUG ev3dev.hardware.EV3DevDevice - Detected device on path: /sys/class/dc-motor/motor0/address, ev3-ports:outC
    UnregulatedMotorDemo: Set Motor Power
    2018-11-08 10:10:22 [main] TRACE ev3dev.utils.Sysfs - echo 50 > /sys/class/dc-motor/motor0/duty_cycle_sp
    2018-11-08 10:10:22 [main] ERROR ev3dev.utils.Sysfs - File: '/sys/class/dc-motor/motor0/duty_cycle_sp' without write permissions.
    Exception in thread "main" java.lang.RuntimeException: Operation not executed: /sys/class/dc-motor/motor0/duty_cycle_sp with value 50
            at ev3dev.hardware.EV3DevDevice.setIntegerAttribute(EV3DevDevice.java:131)
            at ev3dev.actuators.lego.motors.BasicMotor.setPower(BasicMotor.java:56)
            at ev3dev.actuators.lego.motors.UnregulatedMotorDemo.main(UnregulatedMotorDemo.java:19)
    robot@ev3dev:~$
    

    So it seems reasonable reproducible on OpenJDK 10.

    Just for reference: Here is the output of the successful run on OracleJDK 8:

    robot@ev3dev:~$ /opt/ejdk1.8.0/linux_arm_sflt/jre/bin/java -jar EV3dev-java-systemtests-2.4.7-SNAPSHOT-all.jar
    2018-11-08 10:14:25 [main] DEBUG ev3dev.hardware.EV3DevDistros - Debian Stretch detected
    2018-11-08 10:14:25 [main] DEBUG ev3dev.hardware.EV3DevDistros - Debian Stretch detected
    2018-11-08 10:14:31 [main] DEBUG ev3dev.hardware.EV3DevFileSystem - Root Path: /sys/class
    2018-11-08 10:14:32 [main] TRACE ev3dev.utils.Sysfs - ls /sys/class/power_supply/lego-ev3-battery
    2018-11-08 10:14:32 [main] TRACE ev3dev.hardware.EV3DevPlatformsImpl - Detected platform: EV3BRICK
    2018-11-08 10:14:32 [main] TRACE ev3dev.hardware.EV3DevDevice - Retrieving devices in path:
    2018-11-08 10:14:32 [main] TRACE ev3dev.utils.Sysfs - ls /sys/class/lego-port
    2018-11-08 10:14:32 [main] TRACE ev3dev.hardware.EV3DevDevice - Checking devices on: /sys/class/lego-port
    2018-11-08 10:14:32 [main] TRACE ev3dev.hardware.EV3DevDevice - Device 1:
    2018-11-08 10:14:32 [main] TRACE ev3dev.utils.Sysfs - cat /sys/class/lego-port/port6/address
    2018-11-08 10:14:33 [main] TRACE ev3dev.utils.Sysfs - value: ev3-ports:outC
    2018-11-08 10:14:33 [main] TRACE ev3dev.hardware.EV3DevDevice - Port expected: ev3-ports:outC, actual: ev3-ports:outC.
    2018-11-08 10:14:33 [main] DEBUG ev3dev.hardware.EV3DevDevice - Detected device on path: /sys/class/lego-port/port6/address, ev3-ports:outC
    2018-11-08 10:14:33 [main] TRACE ev3dev.utils.Sysfs - echo dc-motor > /sys/class/lego-port/port6/mode
    2018-11-08 10:14:33 [main] TRACE ev3dev.hardware.EV3DevDevice - Retrieving devices in path:
    2018-11-08 10:14:33 [main] TRACE ev3dev.utils.Sysfs - ls /sys/class/dc-motor
    2018-11-08 10:14:34 [main] TRACE ev3dev.hardware.EV3DevDevice - Checking devices on: /sys/class/dc-motor
    2018-11-08 10:14:34 [main] TRACE ev3dev.hardware.EV3DevDevice - Device 1:
    2018-11-08 10:14:34 [main] TRACE ev3dev.utils.Sysfs - cat /sys/class/dc-motor/motor1/address
    2018-11-08 10:14:34 [main] TRACE ev3dev.utils.Sysfs - value: ev3-ports:outC
    2018-11-08 10:14:34 [main] TRACE ev3dev.hardware.EV3DevDevice - Port expected: ev3-ports:outC, actual: ev3-ports:outC.
    2018-11-08 10:14:34 [main] DEBUG ev3dev.hardware.EV3DevDevice - Detected device on path: /sys/class/dc-motor/motor1/address, ev3-ports:outC
    UnregulatedMotorDemo: Set Motor Power
    2018-11-08 10:14:34 [main] TRACE ev3dev.utils.Sysfs - echo 50 > /sys/class/dc-motor/motor1/duty_cycle_sp
    2018-11-08 10:14:34 [main] TRACE ev3dev.utils.Sysfs - echo normal > /sys/class/dc-motor/motor1/polarity
    2018-11-08 10:14:34 [main] TRACE ev3dev.utils.Sysfs - echo 50 > /sys/class/dc-motor/motor1/duty_cycle_sp
    2018-11-08 10:14:34 [main] TRACE ev3dev.utils.Sysfs - echo run-forever > /sys/class/dc-motor/motor1/command
    2018-11-08 10:14:34 [main] TRACE ev3dev.utils.Sysfs - cat /sys/class/dc-motor/motor1/state
    2018-11-08 10:14:34 [main] TRACE ev3dev.utils.Sysfs - value: running ramping
    forward: true
    2018-11-08 10:14:35 [main] TRACE ev3dev.utils.Sysfs - echo stop > /sys/class/dc-motor/motor1/command
    2018-11-08 10:14:35 [main] TRACE ev3dev.utils.Sysfs - cat /sys/class/dc-motor/motor1/state
    2018-11-08 10:14:35 [main] TRACE ev3dev.utils.Sysfs - value:
    stop: false
    2018-11-08 10:14:35 [main] TRACE ev3dev.utils.Sysfs - echo inversed > /sys/class/dc-motor/motor1/polarity
    2018-11-08 10:14:36 [main] TRACE ev3dev.utils.Sysfs - echo 50 > /sys/class/dc-motor/motor1/duty_cycle_sp
    2018-11-08 10:14:36 [main] TRACE ev3dev.utils.Sysfs - echo run-forever > /sys/class/dc-motor/motor1/command
    2018-11-08 10:14:36 [main] TRACE ev3dev.utils.Sysfs - cat /sys/class/dc-motor/motor1/state
    2018-11-08 10:14:36 [main] TRACE ev3dev.utils.Sysfs - value: running ramping
    backward: true
    2018-11-08 10:14:37 [main] TRACE ev3dev.utils.Sysfs - echo stop > /sys/class/dc-motor/motor1/command
    2018-11-08 10:14:37 [main] TRACE ev3dev.utils.Sysfs - cat /sys/class/dc-motor/motor1/state
    2018-11-08 10:14:37 [main] TRACE ev3dev.utils.Sysfs - value:
    stop: false
    2018-11-08 10:14:37 [main] TRACE ev3dev.utils.Sysfs - echo normal > /sys/class/dc-motor/motor1/polarity
    2018-11-08 10:14:37 [main] TRACE ev3dev.utils.Sysfs - echo 50 > /sys/class/dc-motor/motor1/duty_cycle_sp
    2018-11-08 10:14:37 [main] TRACE ev3dev.utils.Sysfs - echo run-forever > /sys/class/dc-motor/motor1/command
    2018-11-08 10:14:37 [main] TRACE ev3dev.utils.Sysfs - cat /sys/class/dc-motor/motor1/state
    2018-11-08 10:14:37 [main] TRACE ev3dev.utils.Sysfs - value: running ramping
    forward: true
    2018-11-08 10:14:38 [main] TRACE ev3dev.utils.Sysfs - echo stop > /sys/class/dc-motor/motor1/command
    2018-11-08 10:14:38 [main] TRACE ev3dev.utils.Sysfs - cat /sys/class/dc-motor/motor1/state
    2018-11-08 10:14:38 [main] TRACE ev3dev.utils.Sysfs - value:
    stop: false
    robot@ev3dev:~$
    
  3. JakubVanek commented on Nov 8, 2018

    @JakubVanek
    Contributor

    Hi,

    I did some research about this, but I'm not sure what might be causing this. Could you try running this in SSH? If the /sys/class/dc-motor/motor0 directory doesn't exist, please try another one for this and the next test.

    if [ -w "/sys/class/dc-motor/motor0/duty_cycle_sp" ]
    then echo "access writable";
    else echo "access unwritable"; fi
    ls -la /sys/class/dc-motor/motor0/duty_cycle_sp

    That will check that file for writability hopefully by using access() system call equivalent (see below) and then print the permissions of the file. Then, could you please try running this:

    echo 50 > /sys/class/dc-motor/motor0/duty_cycle_sp

    If this fails, the problem is really with permissions.

    I'm a bit puzzled that this happens only on JDK10 and not JDK8. This is a part of Sysfs.writeString function:

    final File file = new File(filePath);
    if(file.canWrite()) { /* <- this fails */
        //TODO Review if it possible to improve
        PrintWriter out = new PrintWriter(file);
        out.println(value);
        out.flush();
        out.close();
    //TODO Review
    }else {
        log.error("File: '{}' without write permissions.", filePath); /* <- this is what we see in the log */
        return false;
    }

    I have looked into the publicly available sources of JDK8 and JDK10 and both do these things to check for writable access:

    1. java.io.File.canWrite() is called.
    2. java.io.UnixFileSystem.checkAccess() is called.
    3. Native JNI function Java_java_io_UnixFileSystem_checkAccess() is called.
    4. access(path, W_OK) system call is invoked on the file.

    I looked into ev3dev's duty_cycle_sp store for dc-motor and I don't think that causes the write to fail (disclaimer: this is the first time I read the code which handles sysfs, I might be wrong). However, on my desktop Ubuntu, normal users cannot write into sysfs by default. However, I have read that ev3dev uses udev rules to combat this problem. I don't know what is the difference between JVM versions then though.

    Could you please try running this while JDK8 and then JDK10 are running:

    ps -u -p `pidof java`

    This should display the user who is running the Java process.

    Also, please send us your kernel version:

    uname -a
    

    @dlech what do you think about this problem?

    Regards,

    Jakub Vanek

  4. dlech commented on Nov 8, 2018

    @dlech

    FWIW, the permission come from here: https://github.com/ev3dev/lego-linux-drivers/blob/ev3dev-stretch/motors/dc_motor_class.c#L572

    I think in ev3dev-lang-python, they had to make sure that each attribute was opened with the same permissions. If a file is read-only, it has to be opened for reading only, if it is write only, it has to be opened for writing only, and if it is read/write, it has to be opened for both reading and writing.

  5. JakubVanek commented on Nov 8, 2018

    @JakubVanek
    Contributor

    Hi,

    thanks for your response - yup, I looked there now and I see ev3dev-lang-python uses stat() and keeps the file descriptors open if the user needs to reaccess them:

        def _attribute_file_open(self, name):
            path = os.path.join(self._path, name)
            mode = stat.S_IMODE(os.stat(path)[stat.ST_MODE])
            r_ok = mode & stat.S_IRGRP
            w_ok = mode & stat.S_IWGRP
    
            if r_ok and w_ok:
                mode_str = 'r+'
            elif w_ok:
                mode_str = 'w'
            else:
                mode_str = 'r'
    
            return io.FileIO(path, mode_str)
    
        def _set_attribute(self, attribute, name, value):
            """Device attribute setter"""
            try:
                if attribute is None:
                    attribute = self._attribute_file_open( name )
                else:
                    attribute.seek(0)
    
                if isinstance(value, str):
                    value = value.encode()
                attribute.write(value)
                attribute.flush()
            except Exception as ex:
                self._raise_friendly_access_error(ex, name)
            return attribute

    However I think the operation would fail here as well, if access() reports whether the file can be opened for writing even when only the group bit matches. The attribute fd here would be opened only for reading and then the write on file opened as read-only would probably fail.

    Regards

  6. jabrena commented on Nov 8, 2018

    @jabrena
    Member

    Hi @robl0377,

    I have tested many times the motors and I didn't find that issue.
    In my case, I am testing now with latest build from OpenJDK12 and Debian Stretch. If you like, can you upgrade, I would like to help you and test in team.

    Juan Antonio

  7. robl0377 commented on Nov 8, 2018

    @robl0377
    Author
  8. jabrena commented on Nov 8, 2018

    @jabrena
    Member

    I think that the problem is not related with the JVM.

    In the past, sometimes, I had the same problem and this is the reason that I added the following delay with 0.5 seconds:

        /**
         * Constructor
         * @param motorPort motor port
         * @param moveP moveP
         * @param moveI moveI
         * @param moveD moveD
         * @param holdP holdP
         * @param holdI holdI
         * @param holdD holdD
         * @param offset offset
         * @param maxSpeed maxSpeed
         */
        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 I could increase a bit more that delay. The reason to have the delay, is because in some way EV3Dev, change internally the folder of the motor and it is necessary to wait a bit. Maybe in the future, we could create some kind of more sophisticated system with CompletableFuture... but at the moment, this is the current solution. Normally, when appear this kind of problem disconnecting the motor and connecting again, the problem is solved. You could have the same problem with the gyro.

    But trust me that the problem is not the JVM.

    If you add in the example a new delay before the method setPower a new delay, the probability of this scenario should not exist.

    package ev3dev.actuators.lego.motors;
    import lejos.hardware.port.MotorPort;
    import lejos.utility.Delay;
    public class UnregulatedMotorDemo {
    	// Motor Definition
    	private static UnregulatedMotor umotor1 = new UnregulatedMotor(MotorPort.C);
    	// Configuration
    	private final static int motorPower = 50;
    	private final static int ONE_SECOND = 1000;
    
    	public static void main(String[] args) {
    		System.out.println("UnregulatedMotorDemo: Set Motor Power");
    		// Set power for DC Motor
    		umotor1.setPower(motorPower);
    		// Testing DC-Motor 1
    		umotor1.forward();
    		System.out.println("forward: " + umotor1.isMoving());
    		Delay.msDelay(ONE_SECOND);
    		umotor1.stop();
    		System.out.println("stop: " + umotor1.isMoving());
    		umotor1.backward();
    		System.out.println("backward: " + umotor1.isMoving());
    		Delay.msDelay(ONE_SECOND);
    		umotor1.stop();
    		System.out.println("stop: " + umotor1.isMoving());
    		umotor1.forward();
    		System.out.println("forward: " + umotor1.isMoving());
    		Delay.msDelay(ONE_SECOND);
    		umotor1.stop();
    		System.out.println("stop: " + umotor1.isMoving());
    	}
    }

    Another question I have is: Are you using RCX Unregulated Motor?
    This object is designed for Motors without any encoder like the RCX Unregulated motor:
    If you are not using this device:

    http://bricker.info/parts/5292/

    or

    Maybe, the result is not predictable.

    If you used any EV3 Motor, you should use the example:

    UnregulatedMotorDemo2.java

    package examples.actuators;
    
    import ev3dev.actuators.lego.motors.EV3LargeRegulatedMotor;
    import lejos.hardware.port.MotorPort;
    import lejos.utility.Delay;
    
    public class UnregulatedMotorDemo2 {
    
    	//Robot Definition
    	private static EV3LargeRegulatedMotor umotor1 = new EV3LargeRegulatedMotor(MotorPort.A);
    
        //Configuration
        private final static int motorPower = 30;
        private final static int ONE_SECOND = 1000;
    	
    	public static void main(String[] args) {
    
    		//Set power for DC Motors
    
    		umotor1.resetTachoCount();
    		umotor1.suspendRegulation();
    		umotor1.setSpeed(motorPower);
    		umotor1.brake();
    
    		//Testing DC-Motor 1
    		umotor1.forward();
    		System.out.println("" + umotor1.isMoving());
    		Delay.msDelay(ONE_SECOND);
    		umotor1.stop();
    		System.out.println("" + umotor1.isMoving());
    		umotor1.backward();
    		System.out.println("" + umotor1.isMoving());
    		Delay.msDelay(ONE_SECOND);
    		umotor1.stop();
    		System.out.println("" + umotor1.isMoving());
    		umotor1.forward();
    		System.out.println("" + umotor1.isMoving());
    		Delay.msDelay(ONE_SECOND);
    		umotor1.stop();
    
    	}
    
    }

    This example use the unregulated features from a normal motor with EV3Dev.

    Tomorrow more and welcome to the project.

    Juan Antonio

  9. jabrena commented on Nov 8, 2018

    @jabrena
    Member

    We have in the backlog the creation of a TestingLab to execute from a Jenkins all tests.
    #479

    Using this way, we could detect the kind of problem that you describe.
    In my manual tests, (Maybe in 3 years, thousands) I mitigated this case with the delay but some times, it is possible that exist this problem.

    Reviewing the case, I make the question again: What kind of motor are you using to test the feature about UnregulatedMotors.

  10. jabrena commented on Nov 8, 2018

    @jabrena
    Member

    I think that it will be not necessary to reinstall any JVM.
    I suspect that you are using a EV3 Large/Medium Motor, but I need your confirmation.

    I like the interest in the project. You will enjoy so much (I hope :))

    Cheers

    Juan Antonio

  11. self-assigned this
    on Nov 8, 2018
  12. 25 remaining items

  13. robl0377 commented on Nov 10, 2018

    @robl0377
    Author

    So I have copied the library's BaseRegulatedMotor class into the test package and changed the delay to 500ms. The LargeMotorDemo program uses the modified class:

    > Task :remoteRun
    Host key checking is off. It may be vulnerable to man-in-the-middle attacks.
    java -server -jar /home/robot/EV3dev-java-systemtests-2.4.9-SNAPSHOT-all.jar 
    
    ev3dev#7|2018-11-10 11:20:45 [main] INFO  examples.LargeMotorDemo - Starting motors on B
    ev3dev#7|2018-11-10 11:20:46 [main] INFO  ev3dev.hardware.EV3DevDistros - Providing an EV3DevDistros instance
    ev3dev#7|2018-11-10 11:20:46 [main] DEBUG ev3dev.utils.Shell - Command: cat /etc/os-release
    ev3dev#7|2018-11-10 11:20:47 [main] DEBUG ev3dev.hardware.EV3DevDistros - Debian Stretch detected
    ev3dev#7|2018-11-10 11:20:48 [main] INFO  ev3dev.hardware.EV3DevPlatforms - Providing a EV3DevPlatforms instance
    ev3dev#7|2018-11-10 11:20:48 [main] DEBUG ev3dev.hardware.EV3DevPlatforms - Detecting platform with the battery approach
    ev3dev#7|2018-11-10 11:20:48 [main] DEBUG ev3dev.hardware.EV3DevFileSystem - Root Path: /sys/class
    ev3dev#7|2018-11-10 11:20:48 [main] TRACE ev3dev.utils.Sysfs - ls /sys/class/power_supply/lego-ev3-battery
    ev3dev#7|2018-11-10 11:20:48 [main] TRACE ev3dev.hardware.EV3DevPlatforms - Detected platform: EV3BRICK
    ev3dev#7|2018-11-10 11:20:48 [main] INFO  examples.BaseRegulatedMotor - Configuring motor connected on Port: B
    ev3dev#7|2018-11-10 11:20:48 [main] DEBUG examples.BaseRegulatedMotor - Detecting motor on port: ev3-ports:outB
    ev3dev#7|2018-11-10 11:20:49 [main] TRACE ev3dev.hardware.EV3DevDevice - Retrieving devices in path: 
    ev3dev#7|2018-11-10 11:20:49 [main] TRACE ev3dev.utils.Sysfs - ls /sys/class/lego-port
    ev3dev#7|2018-11-10 11:20:49 [main] TRACE ev3dev.hardware.EV3DevDevice - Checking devices on: /sys/class/lego-port
    ev3dev#7|2018-11-10 11:20:49 [main] TRACE ev3dev.hardware.EV3DevDevice - Device 1:
    ev3dev#7|2018-11-10 11:20:49 [main] TRACE ev3dev.utils.Sysfs - cat /sys/class/lego-port/port6/address
    ev3dev#7|2018-11-10 11:20:49 [main] TRACE ev3dev.utils.Sysfs - value: ev3-ports:outC
    ev3dev#7|2018-11-10 11:20:49 [main] TRACE ev3dev.hardware.EV3DevDevice - Port expected: ev3-ports:outB, actual: ev3-ports:outC.
    ev3dev#7|2018-11-10 11:20:49 [main] TRACE ev3dev.hardware.EV3DevDevice - Skipped device
    ev3dev#7|2018-11-10 11:20:49 [main] TRACE ev3dev.hardware.EV3DevDevice - Device 2:
    ev3dev#7|2018-11-10 11:20:49 [main] TRACE ev3dev.utils.Sysfs - cat /sys/class/lego-port/port4/address
    ev3dev#7|2018-11-10 11:20:49 [main] TRACE ev3dev.utils.Sysfs - value: ev3-ports:outA
    ev3dev#7|2018-11-10 11:20:49 [main] TRACE ev3dev.hardware.EV3DevDevice - Port expected: ev3-ports:outB, actual: ev3-ports:outA.
    ev3dev#7|2018-11-10 11:20:49 [main] TRACE ev3dev.hardware.EV3DevDevice - Skipped device
    ev3dev#7|2018-11-10 11:20:49 [main] TRACE ev3dev.hardware.EV3DevDevice - Device 3:
    ev3dev#7|2018-11-10 11:20:49 [main] TRACE ev3dev.utils.Sysfs - cat /sys/class/lego-port/port2/address
    ev3dev#7|2018-11-10 11:20:49 [main] TRACE ev3dev.utils.Sysfs - value: ev3-ports:in3
    ev3dev#7|2018-11-10 11:20:49 [main] TRACE ev3dev.hardware.EV3DevDevice - Port expected: ev3-ports:outB, actual: ev3-ports:in3.
    ev3dev#7|2018-11-10 11:20:49 [main] TRACE ev3dev.hardware.EV3DevDevice - Skipped device
    ev3dev#7|2018-11-10 11:20:49 [main] TRACE ev3dev.hardware.EV3DevDevice - Device 4:
    ev3dev#7|2018-11-10 11:20:49 [main] TRACE ev3dev.utils.Sysfs - cat /sys/class/lego-port/port0/address
    ev3dev#7|2018-11-10 11:20:49 [main] TRACE ev3dev.utils.Sysfs - value: ev3-ports:in1
    ev3dev#7|2018-11-10 11:20:49 [main] TRACE ev3dev.hardware.EV3DevDevice - Port expected: ev3-ports:outB, actual: ev3-ports:in1.
    ev3dev#7|2018-11-10 11:20:49 [main] TRACE ev3dev.hardware.EV3DevDevice - Skipped device
    ev3dev#7|2018-11-10 11:20:49 [main] TRACE ev3dev.hardware.EV3DevDevice - Device 5:
    ev3dev#7|2018-11-10 11:20:49 [main] TRACE ev3dev.utils.Sysfs - cat /sys/class/lego-port/port7/address
    ev3dev#7|2018-11-10 11:20:49 [main] TRACE ev3dev.utils.Sysfs - value: ev3-ports:outD
    ev3dev#7|2018-11-10 11:20:49 [main] TRACE ev3dev.hardware.EV3DevDevice - Port expected: ev3-ports:outB, actual: ev3-ports:outD.
    ev3dev#7|2018-11-10 11:20:49 [main] TRACE ev3dev.hardware.EV3DevDevice - Skipped device
    ev3dev#7|2018-11-10 11:20:49 [main] TRACE ev3dev.hardware.EV3DevDevice - Device 6:
    ev3dev#7|2018-11-10 11:20:49 [main] TRACE ev3dev.utils.Sysfs - cat /sys/class/lego-port/port5/address
    ev3dev#7|2018-11-10 11:20:49 [main] TRACE ev3dev.utils.Sysfs - value: ev3-ports:outB
    ev3dev#7|2018-11-10 11:20:49 [main] TRACE ev3dev.hardware.EV3DevDevice - Port expected: ev3-ports:outB, actual: ev3-ports:outB.
    ev3dev#7|2018-11-10 11:20:49 [main] DEBUG ev3dev.hardware.EV3DevDevice - Detected device on path: /sys/class/lego-port/port5/address, ev3-ports:outB
    ev3dev#7|2018-11-10 11:20:49 [main] DEBUG examples.BaseRegulatedMotor - Setting port in mode: tacho-motor
    ev3dev#7|2018-11-10 11:20:49 [main] TRACE ev3dev.utils.Sysfs - echo tacho-motor > /sys/class/lego-port/port5/mode
    ev3dev#7|2018-11-10 11:20:50 [main] TRACE ev3dev.hardware.EV3DevDevice - Retrieving devices in path: 
    ev3dev#7|2018-11-10 11:20:50 [main] TRACE ev3dev.utils.Sysfs - ls /sys/class/tacho-motor
    ev3dev#7|2018-11-10 11:20:50 [main] TRACE ev3dev.hardware.EV3DevDevice - Checking devices on: /sys/class/tacho-motor
    ev3dev#7|2018-11-10 11:20:50 [main] TRACE ev3dev.hardware.EV3DevDevice - Device 1:
    ev3dev#7|2018-11-10 11:20:50 [main] TRACE ev3dev.utils.Sysfs - cat /sys/class/tacho-motor/motor0/address
    ev3dev#7|2018-11-10 11:20:50 [main] TRACE ev3dev.utils.Sysfs - value: ev3-ports:outA
    ev3dev#7|2018-11-10 11:20:50 [main] TRACE ev3dev.hardware.EV3DevDevice - Port expected: ev3-ports:outB, actual: ev3-ports:outA.
    ev3dev#7|2018-11-10 11:20:51 [main] TRACE ev3dev.hardware.EV3DevDevice - Skipped device
    ev3dev#7|2018-11-10 11:20:51 [main] TRACE ev3dev.hardware.EV3DevDevice - Device 2:
    ev3dev#7|2018-11-10 11:20:51 [main] TRACE ev3dev.utils.Sysfs - cat /sys/class/tacho-motor/motor4/address
    ev3dev#7|2018-11-10 11:20:51 [main] TRACE ev3dev.utils.Sysfs - value: ev3-ports:outB
    ev3dev#7|2018-11-10 11:20:51 [main] TRACE ev3dev.hardware.EV3DevDevice - Port expected: ev3-ports:outB, actual: ev3-ports:outB.
    ev3dev#7|2018-11-10 11:20:51 [main] DEBUG ev3dev.hardware.EV3DevDevice - Detected device on path: /sys/class/tacho-motor/motor4/address, ev3-ports:outB
    ev3dev#7|2018-11-10 11:20:51 [main] TRACE ev3dev.utils.Sysfs - echo reset > /sys/class/tacho-motor/motor4/command
    ev3dev#7|2018-11-10 11:20:52 [main] ERROR ev3dev.utils.Sysfs - File: '/sys/class/tacho-motor/motor4/command' without write permissions.
    ev3dev#7|Exception in thread "main" java.lang.RuntimeException: Operation not executed: /sys/class/tacho-motor/motor4/command with value reset
    ev3dev#7|	at ev3dev.hardware.EV3DevDevice.setStringAttribute(EV3DevDevice.java:118)
    ev3dev#7|	at examples.BaseRegulatedMotor.<init>(BaseRegulatedMotor.java:99)
    ev3dev#7|	at examples.EV3LargeRegulatedMotor1.<init>(LargeMotorDemo.java:38)
    ev3dev#7|	at examples.LargeMotorDemo.main(LargeMotorDemo.java:14)
    
    > Task :remoteRun FAILED
    Failed command ev3dev#7 with status 1: java -server -jar /home/robot/EV3dev-java-systemtests-2.4.9-SNAPSHOT-all.jar 
    
    FAILURE: Build failed with an exception.
    
  14. jabrena commented on Nov 10, 2018

    @jabrena
    Member

    Nooo, @robl0377 I didn't explain clear.

    I said that if with latest snapshot you observe that you experiment a stable feeling now. After some execution, I mean. If the problem continue, you could deploy the jar from the source project, not from the example project adding the example, the jar will be the same.

  15. robl0377 commented on Nov 10, 2018

    @robl0377
    Author

    Hmm.. So I don't need to play with some internal delays in the BaseRegulatedMotor class, which could depend on environmental conditions (temperature, voltage, age of the motor..)?

  16. jabrena commented on Nov 10, 2018

    @jabrena
    Member

    @robl0377 No,

    I only need that your run 5 times the same example with the snapshot 2.4.9-SNAPSHOT directly. If the execution is right, I will merge the new delay.

    I decrease my EV3Brick with Stretch to the original speed:

    ev3dev-sysinfo -m
    
    ev3dev#4|<!-- Copy everything between these lines -->
    ev3dev#4|**System info (from `ev3dev-sysinfo`)**
    ev3dev#4|```
    ev3dev#4|Image file:         ev3dev-stretch-ev3-generic-2018-08-06
    ev3dev#4|Kernel version:     4.14.71-ev3dev-2.3.0-ev3
    ev3dev#4|Brickman:           0.10.0
    ev3dev#4|BogoMIPS:           148.88
    ev3dev#4|Board:              board0
    ev3dev#4|BOARD_INFO_HW_REV=7
    ev3dev#4|BOARD_INFO_MODEL=LEGO MINDSTORMS EV3
    ev3dev#4|BOARD_INFO_ROM_REV=6
    ev3dev#4|BOARD_INFO_SERIAL_NUM=001653413CAE
    ev3dev#4|BOARD_INFO_TYPE=main
    ev3dev#4|```
    ev3dev#4|<!-- Copy everything between these lines -->
    

    And the code has similar times:

    With EV3 Overclocked:

    ev3dev#8|real	0m40.844s
    ev3dev#8|user	0m26.563s
    ev3dev#8|sys	0m2.134s
    

    With normal speed:

    time java -jar /home/robot/ev3dev-lang-java-2.4.10-SNAPSHOT-all.jar 
    
    ev3dev#3|2018-11-10 11:36:02 [main] INFO  examples.LargeMotorDemo - Starting motors on A
    ev3dev#3|2018-11-10 11:36:03 [main] INFO  ev3dev.hardware.EV3DevDistros - Providing an EV3DevDistros instance
    ev3dev#3|2018-11-10 11:36:03 [main] DEBUG ev3dev.utils.Shell - Command: cat /etc/os-release
    ev3dev#3|2018-11-10 11:36:05 [main] DEBUG ev3dev.hardware.EV3DevDistros - Debian Stretch detected
    ev3dev#3|2018-11-10 11:36:05 [main] INFO  ev3dev.hardware.EV3DevPlatforms - Providing a EV3DevPlatforms instance
    ev3dev#3|2018-11-10 11:36:06 [main] DEBUG ev3dev.hardware.EV3DevPlatforms - Detecting platform with the battery approach
    ev3dev#3|2018-11-10 11:36:06 [main] DEBUG ev3dev.hardware.EV3DevFileSystem - Root Path: /sys/class
    ev3dev#3|2018-11-10 11:36:06 [main] TRACE ev3dev.utils.Sysfs - ls /sys/class/power_supply/lego-ev3-battery
    ev3dev#3|2018-11-10 11:36:06 [main] TRACE ev3dev.hardware.EV3DevPlatforms - Detected platform: EV3BRICK
    ev3dev#3|2018-11-10 11:36:06 [main] INFO  e.a.lego.motors.BaseRegulatedMotor - Configuring motor connected on Port: A
    ev3dev#3|2018-11-10 11:36:06 [main] DEBUG e.a.lego.motors.BaseRegulatedMotor - Detecting motor on port: ev3-ports:outA
    ev3dev#3|2018-11-10 11:36:06 [main] TRACE ev3dev.hardware.EV3DevDevice - Retrieving devices in path: 
    ev3dev#3|2018-11-10 11:36:06 [main] TRACE ev3dev.utils.Sysfs - ls /sys/class/lego-port
    ev3dev#3|2018-11-10 11:36:06 [main] TRACE ev3dev.hardware.EV3DevDevice - Checking devices on: /sys/class/lego-port
    ev3dev#3|2018-11-10 11:36:06 [main] TRACE ev3dev.hardware.EV3DevDevice - Device 1:
    ev3dev#3|2018-11-10 11:36:06 [main] TRACE ev3dev.utils.Sysfs - cat /sys/class/lego-port/port6/address
    ev3dev#3|2018-11-10 11:36:07 [main] TRACE ev3dev.utils.Sysfs - value: ev3-ports:outC
    ev3dev#3|2018-11-10 11:36:07 [main] TRACE ev3dev.hardware.EV3DevDevice - Port expected: ev3-ports:outA, actual: ev3-ports:outC.
    ev3dev#3|2018-11-10 11:36:07 [main] TRACE ev3dev.hardware.EV3DevDevice - Skipped device
    ev3dev#3|2018-11-10 11:36:07 [main] TRACE ev3dev.hardware.EV3DevDevice - Device 2:
    ev3dev#3|2018-11-10 11:36:07 [main] TRACE ev3dev.utils.Sysfs - cat /sys/class/lego-port/port4/address
    ev3dev#3|2018-11-10 11:36:07 [main] TRACE ev3dev.utils.Sysfs - value: ev3-ports:outA
    ev3dev#3|2018-11-10 11:36:07 [main] TRACE ev3dev.hardware.EV3DevDevice - Port expected: ev3-ports:outA, actual: ev3-ports:outA.
    ev3dev#3|2018-11-10 11:36:07 [main] DEBUG ev3dev.hardware.EV3DevDevice - Detected device on path: /sys/class/lego-port/port4/address, ev3-ports:outA
    ev3dev#3|2018-11-10 11:36:07 [main] DEBUG e.a.lego.motors.BaseRegulatedMotor - Setting port in mode: tacho-motor
    ev3dev#3|2018-11-10 11:36:07 [main] TRACE ev3dev.utils.Sysfs - echo tacho-motor > /sys/class/lego-port/port4/mode
    ev3dev#3|2018-11-10 11:36:07 [main] TRACE ev3dev.hardware.EV3DevDevice - Retrieving devices in path: 
    ev3dev#3|2018-11-10 11:36:08 [main] TRACE ev3dev.utils.Sysfs - ls /sys/class/tacho-motor
    ev3dev#3|2018-11-10 11:36:08 [main] TRACE ev3dev.hardware.EV3DevDevice - Checking devices on: /sys/class/tacho-motor
    ev3dev#3|2018-11-10 11:36:08 [main] TRACE ev3dev.hardware.EV3DevDevice - Device 1:
    ev3dev#3|2018-11-10 11:36:08 [main] TRACE ev3dev.utils.Sysfs - cat /sys/class/tacho-motor/motor2/address
    ev3dev#3|2018-11-10 11:36:08 [main] TRACE ev3dev.utils.Sysfs - value: ev3-ports:outA
    ev3dev#3|2018-11-10 11:36:08 [main] TRACE ev3dev.hardware.EV3DevDevice - Port expected: ev3-ports:outA, actual: ev3-ports:outA.
    ev3dev#3|2018-11-10 11:36:08 [main] DEBUG ev3dev.hardware.EV3DevDevice - Detected device on path: /sys/class/tacho-motor/motor2/address, ev3-ports:outA
    ev3dev#3|2018-11-10 11:36:08 [main] TRACE ev3dev.utils.Sysfs - echo reset > /sys/class/tacho-motor/motor2/command
    ev3dev#3|2018-11-10 11:36:08 [main] DEBUG e.a.lego.motors.BaseRegulatedMotor - Motor ready to use on Port: A
    ev3dev#3|2018-11-10 11:36:08 [main] TRACE ev3dev.utils.Sysfs - echo 500 > /sys/class/tacho-motor/motor2/speed_sp
    ev3dev#3|2018-11-10 11:36:08 [main] TRACE ev3dev.utils.Sysfs - echo brake > /sys/class/tacho-motor/motor2/stop_action
    ev3dev#3|2018-11-10 11:36:08 [main] TRACE ev3dev.utils.Sysfs - echo normal > /sys/class/tacho-motor/motor2/polarity
    ev3dev#3|2018-11-10 11:36:08 [main] TRACE ev3dev.utils.Sysfs - echo 500 > /sys/class/tacho-motor/motor2/speed_sp
    ev3dev#3|2018-11-10 11:36:08 [main] TRACE ev3dev.utils.Sysfs - echo run-forever > /sys/class/tacho-motor/motor2/command
    ev3dev#3|2018-11-10 11:36:08 [main] TRACE ev3dev.utils.Sysfs - cat /sys/class/tacho-motor/motor2/state
    ev3dev#3|2018-11-10 11:36:08 [main] TRACE ev3dev.utils.Sysfs - value: running
    ev3dev#3|2018-11-10 11:36:09 [main] TRACE ev3dev.utils.Sysfs - cat /sys/class/tacho-motor/motor2/speed_sp
    ev3dev#3|2018-11-10 11:36:09 [main] TRACE ev3dev.utils.Sysfs - value: 500
    ev3dev#3|2018-11-10 11:36:09 [main] INFO  examples.LargeMotorDemo - Large Motor is moving: true at speed 500
    ev3dev#3|2018-11-10 11:36:11 [main] TRACE ev3dev.utils.Sysfs - echo stop > /sys/class/tacho-motor/motor2/command
    ev3dev#3|2018-11-10 11:36:11 [main] INFO  examples.LargeMotorDemo - Stopped motors
    ev3dev#3|
    ev3dev#3|real	0m52.572s
    ev3dev#3|user	0m34.847s
    ev3dev#3|sys	0m2.619s
    

    In this release, we added a new required library compile("net.java.dev.jna:jna:4.5.2") to interact with the new LCD Driver, but reviewing the times, this fact doesn't affect the global performance. It is a pity that you are experimented this case. At the moment, the unique solution is to increase a bit the delay but I need to check with you that the new delay mitigate the case in your case.

  17. JakubVanek commented on Nov 10, 2018

    @JakubVanek
    Contributor

    @jabrena I propose this solution:

    	public static boolean writeString(final String filePath, final String value) {
    		if(log.isTraceEnabled()) log.trace("echo '{}' > '{}'", value, filePath);
    		
    		byte[] bytes = value.getBytes();
    		Path path = Paths.get(filePath);
    		
    		for (int tries = 1; tries <= 10; tries++) {
    			try {
    				Files.write(path, bytes, StandardOpenOption.WRITE, StandardOpenOption.SYNC);
    				if(log.isTraceEnabled()) log.trace("-> success");
    				return true;
    			} catch(IOException e) {
    				if(log.isTraceEnabled()) log.trace("-> failed at try '{}': '{}'", tries, e.toString());
    				Thread.sleep(100);
    				continue;
    			}
    		}
    		log.error("write failed!");
    		return false;
    	}
  18. jabrena commented on Nov 10, 2018

    @jabrena
    Member

    Hi @JakubVanek,

    We are not going to introduce any retry mechanism in that class.
    Put this comment in this issue: #555

  19. jabrena commented on Nov 10, 2018

    @jabrena
    Member

    We only need the tests from @robl0377 with the new delay.

  20. added a commit that references this issue on Nov 10, 2018
  21. jabrena commented on Nov 10, 2018

    @jabrena
    Member

    Hi @robl0377,

    we are waiting for you tests.

    We have created a new Snapshot with sources for the library ev3dev-lang-java and lejos-commons:
    https://jitpack.io/#ev3dev-lang-java/ev3dev-lang-java/2.4.12-SNAPSHOT

    this Snapshot don't change the delay value, it has the same value than snapshot 2.4.9-SNAPSHOT:

    Delay.msDelay(700);

    We need to confirm that success tests to close that issue for this release.

    Juan Antonio

  22. robl0377 commented on Nov 10, 2018

    @robl0377
    Author

    To answer your question: I certainly had it running with the original 2.4.9-SNAPSHOT more than 5 times, although I did not test with different temperatures or voltages. Also my motors are a little used.

    BTW: I got the book "Beginning Robotics Programming in Java with LEGO Mindstorms" by Wei Lu / Apress 2016. It gives an introduction to robotics programming with classical LeJOS. So I'm now working with the LeJOS again and enjoy the ease of work with the LeJOS Eclipse plugin and the LCD and Buttons :-)

  23. jabrena commented on Nov 10, 2018

    @jabrena
    Member

    Thanks for the tests @robl0377
    We will merge the change tomorrow and we will release.

    Note: You are invited to this project when you want to use multiple Bricks, new objects from the JVM 8+, the experience of a complete Linux Distro & an USB support ;)

    Cheers

    Juan Antonio

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