Skip to content

Use /sys/class/board-info/ to detect platform type#383

Merged
dwalton76 merged 4 commits intoev3dev:developfrom
dwalton76:auto-platform-detect
Sep 29, 2017
Merged

Use /sys/class/board-info/ to detect platform type#383
dwalton76 merged 4 commits intoev3dev:developfrom
dwalton76:auto-platform-detect

Conversation

@dwalton76
Copy link
Copy Markdown
Collaborator

No description provided.

Comment thread ev3dev/auto.py Outdated
return 'evb'
elif value == 'LEGO MINDSTORMS EV3':
return 'ev3'
elif value == 'TBD':
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@dlech if you can send me the BOARD_INFO_MODEL values for brickpi, pistorms, etc I'll go ahead and add those

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

perfect

Comment thread ev3dev/evb.py Outdated
@@ -0,0 +1,128 @@

"""
An assortment of classes modeling specific features of the EV3 brick.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Will s/EV3/EVB/

@ddemidov
Copy link
Copy Markdown
Member

ddemidov commented Sep 28, 2017

Awesome!

Comment thread ev3dev/auto.py Outdated
if os.path.exists(filename):
with open(filename, 'r') as fh:
current_platform = fh.read().strip()
def get_current_platform():
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.

This might be useful as a core library method

@dwalton76
Copy link
Copy Markdown
Collaborator Author

I need to test the PiStorms part but that is what was needed back in #170 (was closed because we had no way to detect if we were running on a pistorms)

@dwalton76
Copy link
Copy Markdown
Collaborator Author

Any objections to merging this one in? I need it to go in so I can post the PR for the buttons API

Comment thread ev3dev/core.py Outdated

def get_current_platform():
"""
Look in /sys/class/board-info/ to determine the platform type
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.

Document the possible return values?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

k

Comment thread ev3dev/evb.py
@staticmethod
def on_enter(state):
"""
This handler is called by `process()` whenever state of 'enter' button
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.

What is this for?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is so you can do things like

def foobar():
    print("The user pressed ENTER")

btn = Button()
btn.on_enter = foobar

while True:
    btn.process()

I'm working on making this event driven as part of the buttons API work...today you have to call it in a while loop like that to make it do what you want.

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.

Oh, I see. Damn, Python is weird 😆 Is that a common idiom? Is there not an event framework of some sort?

Either way, I don't think it's blocking.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This project is the only place I've seen this approach used...but I've only been writing python for 4 years so who knows maybe it is wildly popular and I just haven't been exposed to it.

Comment thread ev3dev/evb.py Outdated
@@ -0,0 +1,128 @@

"""
An assortment of classes modeling specific features of the EVB brick.
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.

EVB brick? I would suggest "EVB BeagleBone cape" or whatever those things are called.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I'll chop the brick part...I normally here it referred to as just an EVB

@WasabiFan
Copy link
Copy Markdown
Member

LGTM

@dwalton76 dwalton76 merged commit 1350cd5 into ev3dev:develop Sep 29, 2017
@dwalton76 dwalton76 deleted the auto-platform-detect branch September 29, 2017 01:58
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.

4 participants