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

Fix Faraday-Telemetry For Use on Raspberry Pi #273

Merged
merged 13 commits into from
Sep 28, 2017

Conversation

kb1lqc
Copy link
Member

@kb1lqc kb1lqc commented Sep 15, 2017

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

  • Created openDB() function to help open up database connection easier
  • Distributed individual database connections to each thread/function with openDB()
  • Enabled WAL mode with a PRAGMA SQL query when opening up any database connection
  • Cleaned up comments and error handling a tad

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.

image

Also here's a screenshot of the aprs.fi raw telemetry being sent with this branch faraday-telemetry code.
image

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.
@kb1lqc kb1lqc added this to the ALPHA Buoy milestone Sep 15, 2017
@kb1lqc kb1lqc self-assigned this Sep 15, 2017
@kb1lqc kb1lqc requested a review from reillyeon September 15, 2017 06:12
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.
@kb1lqc
Copy link
Member Author

kb1lqc commented Sep 21, 2017

@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
Copy link
Member Author

kb1lqc commented Sep 28, 2017

Noting that while not currently running on my RPi (bricked with power cycle) I have been running faraday-aprs on my computer for over 2 days and no issues! Lots of network drops on my end since my home modem is starting to fail.

image

@kb1lqd
Copy link
Contributor

kb1lqd commented Sep 28, 2017

@kb1lqc Please add aprslib to pip install's requirements.txt file in the main directory.

@kb1lqc
Copy link
Member Author

kb1lqc commented Sep 28, 2017

@kb1lqd added aprslib to requirements.txt

Copy link
Contributor

@kb1lqd kb1lqd left a 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants