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

Python examples rework #27

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
python: navio: Navio2: RCInput: add channel number check
Print error message if channel too large
  • Loading branch information
Igor Anokhin committed Jan 10, 2018
commit d4b5f834e631ae05d015f0af2bff0604f7848422
12 changes: 8 additions & 4 deletions Python/navio/Navio2/RCInput.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ def __init__(self):
print ("Can't open file /sys/kernel/rcio/rcin/ch%d" % i)

def read(self, ch):
value = self.channels[ch].read()
position = self.channels[ch].seek(0, 0)
return value[:-1]

try:
value = self.channels[ch].read()
position = self.channels[ch].seek(0, 0)
return value[:-1]
except IndexError:
print ("Channel number too large")
exit(1)
Copy link

Choose a reason for hiding this comment

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

It's a good practice to throw exception on higher level instead of exiting inside utility method