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

[cpp][autogen] Show a message instead of throwing for unsupported property #55

Merged
merged 1 commit into from
Apr 21, 2015
Merged

Conversation

ddemidov
Copy link
Member

This changes the C++ demos to show a message instead of throwing if a property is unsupported by specific device. Example output of the ev3dev-lang-test.cpp:

Found large motor
  Current properties are:
    Commands: [ reset run-direct run-forever run-timed run-to-abs-pos run-to-rel-pos stop ]
    Count Per Rot: 360
    Driver Name: lego-ev3-l-motor
    Duty Cycle: 0
    Duty Cycle SP: 50
    Encoder Polarity: normal
    Polarity: normal
    Port Name: outB
    Position: 267
    Position P: [not supported by the device]
    Position I: [not supported by the device]
    Position D: [not supported by the device]
    Position SP: 100
    Speed: 0
    Speed SP: 0
    Ramp Up SP: 0
    Ramp Down SP: 0
    Speed Regulation Enabled: off
    Speed Regulation P: 1000
    Speed Regulation I: 60
    Speed Regulation D: 0
    State: [ ]
    Stop Command: coast
    Stop Commands: [ brake coast hold ]
    Time SP: 0

See #53 for details

WasabiFan added a commit that referenced this pull request Apr 21, 2015
[cpp][autogen] Show a message instead of throwing for unsupported property
@WasabiFan WasabiFan merged commit 43571a5 into ev3dev:develop Apr 21, 2015
<< " {{ prop.name }}: " << dev.{{ cppName }}() << endl{%
cout << " {{ prop.name }}: ";
try { cout << dev.{{ cppName }}() << endl; }
catch(...) { cout << "[not supported by the device]" << endl; }{%
Copy link
Member

Choose a reason for hiding this comment

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

"Not supported" is not the only possible error here. For example, you could get -EINVAL if an argument is invalid or a number of other errors. I would think it would be better to use strerror() to get the actual error message.

Copy link
Member Author

Choose a reason for hiding this comment

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

Addressed in #56

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.

None yet

3 participants