- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
I am trying to handle my python script crashing...Seeed grove LCD. Seems to run for a month or so. Some units crash more frequently.
Jan 27 02:20:42 edison libmraa[196]: i2c6: write_byte_data: Access error: Remote I/O error
Because I can't cause the error (even unplugging the LCD), I want to make sure that I can handle the exception.
First, I would like to handle it and let the rest of my code run:
while 1:
try:
lcd.write("stuff")
except:
pass
Rest of code....
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Hello Zaker,
Thanks for reaching out!
I tested your code and, as expected, it didn't fail. I'd probably have to wait a long time before being able to see the issue. I'm not sure how you could handle this error from Python, nevertheless, if the process is stopped I might have an idea of how to solve this problem.
You can use the script originally mentioned in https://communities.intel.com/message/445830# 445830 https://communities.intel.com/message/445830# 445830 in order to monitor a running process and restart it whenever it stops. The code would look like this:
# !/bin/bash
check_process() {
echo "$ts: checking $1"
[ "$1" = "" ] && return 0
[ `pgrep -n $1` ] && return 1 || return 0
}
while [ 1 ]; do
# timestamp
ts=`date +%T`
echo "$ts: begin checking..."
check_process "python lcd.py"
[ $? -eq 0 ] && echo "$ts: not running, restarting..." && `python lcd.py`
sleep 5
done
***You'll need to install procps, procps-dbg, procps-dev and procps-doc in order to use pgrep, this packages can be downloaded from the official repo.
If this solution doesn't help you, I'd suggest you to contact the developers of mraa directly ( https://github.com/intel-iot-devkit/mraa/issues) and report them the issue you are facing in order to see if they can provide you a more accurate response.
I hope this information helps you,
Pedro M.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Thanks for your reply!
Yes, the failure can be after a month or two of operation.
I will look into using your script to watch the other. It would take me time to implement that on all of my installs.
Do you not think the error would be caught by an exception in Python?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Since I'm not able to replicate the error I can't say for sure that Python is able to handle it. Since it is an error thrown by mraa, you might want to talk to them (with the link I posted above) to see if this is possible. Perhaps they can tell you if it is possible or even a hint on how to do it. The only useful thing I can share about this is Python's documentation about handling exceptions which mayhap you can find useful: https://docs.python.org/2/tutorial/errors.html.
Pedro M.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page