Skip to content

Micropython support - #514

Merged
WasabiFan merged 27 commits into
ev3dev-stretchfrom
micropython-support
Sep 23, 2018
Merged

WasabiFan merged 27 commits into
ev3dev-stretchfrom
micropython-support

Conversation

@WasabiFan

@WasabiFan WasabiFan commented Sep 10, 2018 •

Copy link
Copy Markdown
Member
  • Make necessary changes to support motors and sensors on micropython (cursory on-EV3 testing)
  • Get tests up-and-running on Travis with Micropython entry in build matrix
  • Thorough testing pass on-device
  • Better handling of unsupported features (currently buttons and sound)
  • Document usage under Micropython (Add documentation for Micropython usage #528)
    • Test out micropython.native decorator to see if it works
  • APT packaging
  • Stretch goal: support buttons and sound

Example build: https://travis-ci.org/ev3dev/ev3dev-lang-python/builds/426662475

Depends on ev3dev/ev3dev-lang-fake-sys#13
Fixes #492

Comment thread ev3dev2/__init__.py
def is_micropython():
return sys.implementation.name == "micropython"

def chain_exception(exception, cause):

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if I like how I did this... Micropython doesn't support exception chaining, so we have to suppress the from when running on that interpreter. But now chain_exception shows up in the call stack.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we could implement our own Exception subclass, that would carry its parent exception around, but I am not sure if that would be any better than what you did.

cd ~/

# Build micropython from source
# TODO: cache micropython build output

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is how I did it:

Adding a path to travis cache:

https://github.com/ddemidov/amgcl/blob/master/.travis.yml#L39-L42

Checking if path exists (that is, if cache was unpacked successfully):

https://github.com/ddemidov/amgcl/blob/master/.travis/install_boost.sh#L5

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Thanks for the reference!

@ddemidov ddemidov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is surprisingly small amount of changes to support micropython. Looks good to me!

Comment thread ev3dev2/__init__.py
raise driver_error

if driver_error.errno == errno.EINVAL:
driver_errorno = driver_error.args[0] if is_micropython() else driver_error.errno

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would feel nicer if this would be implemented as a function (driver_errno()) but I guess it is OK as is, since this is the only place we need it.

Comment thread .travis.yml
tags: true
condition: $TRAVIS_TAG != ev3dev-stretch/*
condition:
- $TRAVIS_TAG != ev3dev-stretch/*

@WasabiFan WasabiFan Sep 11, 2018 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect that this (the list for condition) isn't right. I need to take another look and figure out how to do it correctly.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind... although the documentation says

condition: deploy when a single bash condition evaluates to true. This must be a string value, and is equivalent to if [[ <condition> ]]; then <deploy>; fi.

It emits the correct script:

  if [[ ($TRAVIS_REPO_SLUG = "ev3dev/ev3dev-lang-python") && ($TRAVIS_TAG != ev3dev-stretch/*) && ($USE_MICROPYTHON = false) && ("$TRAVIS_TAG" != "") ]]; then

@WasabiFan
WasabiFan merged commit bbd9631 into ev3dev-stretch Sep 23, 2018
@dwalton76
dwalton76 deleted the micropython-support branch April 26, 2019 16:53
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