-
Notifications
You must be signed in to change notification settings - Fork 19
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
Fix Faraday-Telemetry For Use on Raspberry Pi #273
Conversation
Worker and main Flask threads have separate connections to the database now. It's a bit messy but should work and does log to database now with my computer. Need to test on Raspberry Pi.
Missed an old conn variable that needed to be updated to queryStationsConn.
Open and close database on every sqlInsert() call. Also found I wasn't properly closing the database prior which might be why stations failed?
Added documentation and removed unnecessary code. Cleaned up a few return False statements too.
Added telemetryWorker catching of False flag when error occurs.
Instead just raise exceptions and let it run it's course. Seems more straightforward.
Removed the rest of the code I commented out to move towards discrete DB connections per thread. I also cleaned up several areas with better/new comments.
Per an error with a locked database on line 960 cur = queryStationsDB.cursor() I moved this into the next try statement to see if it catches better.
Needed to catch a JSON decode error if faraday-telemetry returns bad JSON data on one particular instance. This allows faraday-aprs to continue and obtain new data on next call of getStations().
I never stopped the counter from incrementing and once the value reached 8280 and incremented to 8281 the telemetry suddenly was rejected/ignored by aprs.fi. This led to realizing the counter is limited to this value and I should just reset. Therefore this fix just implements a for loop counting in the infinite while loop which resets to zero after counting to 8179. Yes I stayed one count away from the maximum just incase there is misunderstanding about zero indexing.
@reillyeon I just committed cfdee3a which fixes the telemetry sequence bug found on #272! I have it running on my Raspberry Pi now but it will take 8280 * 15 seconds interval = 124,200 seconds = 2,070 minutes = 34.5 hours to find out. This means the counter will get to the rollover point around 9AM Friday morning. I'll leave it running but feel that this is now ready to pull in! |
@kb1lqc Please add |
@kb1lqd added aprslib to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed in person with Bryce. Worked on laptop, reviewed code and looks good.
Per Faraday-Software #272 and #270 the
faraday-telemetry
software did not run on the Raspberry Pi 3. @reillyeon suggested ensuring each thread had it's own database connection which this PR should do. Also, I found that that alone did not work and enabled SQLite3 Write-Ahead Logging (WAL) mode was also required. This prevented slower operations such as opening/closing the .journal file which is not usually an issue but slow enough on the Raspberry Pi to cause database access issues.Changelog
openDB()
function to help open up database connection easieropenDB()
Testing
Currently the code is running on a Raspberry Pi 3 with September 2017 Raspbian. It is updating KB1LQC-1 on aprs.fi with telemetry data in a duration test at the time of this PR submission.
Also here's a screenshot of the aprs.fi raw telemetry being sent with this branch
faraday-telemetry
code.