★ wanayoo — archive 1999 https://github.com/ev3dev-lang-java/ev3dev-lang-java/issues/443Nouvelle recherche | Portail wanayoo
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Externalise EV3Dev constants to offer support for multiple EV3Dev Distros (Jessie & Stretch) #443

Closed
jabrena opened this issue Mar 28, 2018 · 12 comments

Comments

@jabrena
Copy link
Member

@jabrena jabrena commented Mar 28, 2018

Currently, the main library has support for Debian Jessie and Debian Stretch for EV3Dev but the support is stored in 2 different Git Branches. It is necessary to unify to minimize the effort to maintain.

Analyzing the changes in the library, you observe the number of changes are not huge so, it is possible to find a good solution with not so much effort.

It is necessary to find that solution.

  • Detect distro [Jessie | Stretch ]
  • Externalize data with changes in ev3dev (A possible solution is the usage of property files)
  • Review possible changes in some classes to support both distros
  • Review possible changes in some tests
@JakubVanek
Copy link
Contributor

@JakubVanek JakubVanek commented Mar 28, 2018

This might be done using Jigsaw and service providers.

@jabrena
Copy link
Member Author

@jabrena jabrena commented Mar 30, 2018

Yes, but I was thinking in the properties to have support for jessie and stretch.

Example:

Jessie:
/sys/class/power_supply/legoev3-battery

Stretch:
/sys/class/power_supply/lego-ev3-battery

Using 2 property files it is possible to load the right properties:

Related question here:
ev3dev/ev3dev#1062

robot@ev3dev:~$ cat /etc/os-release
PRETTY_NAME="ev3dev-stretch"
NAME="ev3dev-stretch"
ID=ev3dev
ID_LIKE=debian
HOME_URL="http://www.ev3dev.org"
SUPPORT_URL="http://www.ev3dev.org/support"
BUG_REPORT_URL="https://github.com/ev3dev/ev3dev/issues"

cat /etc/os-release | grep stretch | wc -l

@jabrena
Copy link
Member Author

@jabrena jabrena commented Apr 14, 2018

Reviewing the UML design the right class candidate to add a new method getDistro is EV3DevPlatforms.java

The new method could return:

  • JESSIE
  • STRETCH

The possible values will be stored in a Enum

If the class doesn´t detect one of the distro will raise a RuntimeException.

@jabrena
Copy link
Member Author

@jabrena jabrena commented Apr 14, 2018

I have disabled some tests because static methods has a similar behaviour than a Singleton object.
This library run for the following combinations:

  • DEBIAN DISTRO: JESSIE | STRETCH
  • PLATFORM: EV3 BRICK | BRICKPI | BRICKPI3 | PISTORMS

It is necessary to know, how to reset a static method or field. (Reflection problem)
https://stackoverflow.com/questions/26234742/resetting-static-fields-for-junit-tests
https://caffinc.github.io/2015/12/static-final-java-junit-test/
https://blog.box.com/blog/unit-testing-with-static-variables/

@jabrena
Copy link
Member Author

@jabrena jabrena commented Apr 14, 2018

It is necessary to identify the changes between Jessie Support & Stretch Support.

Base code:

  • Sound: In this case, exist 2 different implementations. The main problem in Stretch, is the lack of a volume endpoint.
  • LED: Different paths. Unify paths and the way to build the final paths.
  • EV3DevPlatforms: Platform, Motor Ports & Sensor Ports
  • BaseSensor: SwitchDelay. In this case, it is better to unify parameter.
  • Battery:
  • EV3Key: event path

Fake objects:

  • FakeEV3Led:
  • FakeBattery:
  • FakeLegoSensor:
  • FakeUnregulatedMotor:
  • FakeRegulatedMotor:
  • FakeLargeRegulatedMotor:

Some tests:

  • ShellTest
  • EV3DevPlatformsTest
  • EV3SensorDeviceTest
@jabrena jabrena modified the milestones: v0.8.0, v0.9.0 Apr 20, 2018
jabrena added a commit that referenced this issue Apr 20, 2018
…and some performance optimizations)
jabrena added a commit that referenced this issue Apr 23, 2018
# Conflicts:
#	build.gradle
@jabrena
Copy link
Member Author

@jabrena jabrena commented May 4, 2018

I will continue with the changes.

@jabrena
Copy link
Member Author

@jabrena jabrena commented May 5, 2018

Added changes.

@jabrena
Copy link
Member Author

@jabrena jabrena commented May 5, 2018

Pending testing with all platforms and 2 versions. (Debian Jessie & Debian Stretch)

@jabrena jabrena removed the PRIORITY label May 5, 2018
jabrena added a commit that referenced this issue May 5, 2018
@jabrena
Copy link
Member Author

@jabrena jabrena commented Aug 5, 2018

It is necessary to review some classes that raises some exceptions in Travis.

jabrena added a commit that referenced this issue Oct 28, 2018
# Conflicts:
#	src/main/java/ev3dev/hardware/EV3DevPlatforms.java
#	src/test/java/fake_ev3dev/BaseElement.java
@jabrena
Copy link
Member Author

@jabrena jabrena commented Oct 28, 2018

Added support.

@jabrena
Copy link
Member Author

@jabrena jabrena commented Oct 28, 2018

Finally, the library in the last version only support Debian Stretch. Doesn't any value to maintain 2 distros.

jabrena added a commit that referenced this issue Oct 28, 2018
# Conflicts:
#	build.gradle
#	docs/uml/graph.dot
#	docs/uml/graph.png
#	src/main/java/ev3dev/actuators/LCD.java
#	src/main/java/ev3dev/hardware/EV3DevDistros.java
#	src/main/java/ev3dev/hardware/EV3DevPlatforms.java
#	src/main/java/ev3dev/sensors/Battery.java
#	src/main/java/ev3dev/utils/Brickman.java
#	src/test/java/ev3dev/utils/SysfsTest.java
jabrena added a commit that referenced this issue Oct 28, 2018
# Conflicts:
#	docs/uml/graph.dot
#	docs/uml/graph.png
@jabrena jabrena mentioned this issue Oct 30, 2018
JakubVanek added a commit that referenced this issue Nov 4, 2018
- this contains brickman changes
jabrena added a commit that referenced this issue Nov 5, 2018
jabrena added a commit that referenced this issue Nov 5, 2018
JakubVanek added a commit that referenced this issue Nov 6, 2018
Feature/#443
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.