bearing / dosenet-raspberrypi

Raspberry Pi specific software for dosimeters.
MIT License
7 stars 21 forks source link

device reboot at end of counting period #69 #71

Closed tybtab closed 7 years ago

tybtab commented 8 years ago

Here's what I have now. The test device is working like usual. I am not sure how to test it further.

bplimley commented 8 years ago

Can you explain what you're doing with time.altzone? I don't understand how it is relevant...

tybtab commented 8 years ago

time.altzone is the time until UTC0800. If there is less than an interval (default 5 minutes) time remaining, quit_after_interval is made true which will cause manager to takedown safely after an interval after UTC0800.

tybtab commented 7 years ago

Hi I added to this pull request functionality to the plot_spectra.py. Now it requests input from the user to determine what plots it is going to plot. I tested it and it works fine

bplimley commented 7 years ago

There are a couple different aspects of this issue, so let me clarify more.

  1. Device reads return TCP packet from server (probably in Sender). I will have this functioning on a test server instance ASAP and let you know the format. It will include a boolean flag for whether a reboot is needed or not, as well as a string that indicates what branch of the git repo the device should use. Sender tells Manager this info.
  2. Manager waits until the end of an interval and then initiates a device update and reboot. See git-pull-reboot.sh for a Bash version of this, basically. But we want to do this from within Python instead. So it is not a matter of sys.exit(0), but you'll need to actually send a system command to reboot. Plus we want Python and Manager to shut down gracefully too, in case there are still counts in the queue (this should only happen if you get a TCP response from the server, try to flush an existing queue to server, but get a network error so part of the queue stays in memory). Look at the shutdown bash command and you'll have to do some messy testing.
bplimley commented 7 years ago

You can connect by TCP on port 5101 to my dev server version, live now. It returns a string of branch,flag where branch is the branch name, and flag is 0 or 1, 1 means a reboot is needed. (If it is 0 then you don't need to do anything with branch either.)

bplimley commented 7 years ago

The return TCP packet is live on the main server now. So it should be present in every packet (just that it's not being checked for right now). Same format as in my last comment.

tybtab commented 7 years ago

I now have manager.py calling takedown to shut it off gracefully, and then call os.system('sudo shutdown now -r') to reboot the raspberrypi. It works fine. The time.altzone condition will make self.quit.after.interval true which will have manager.py takedown gracefully and then reboot the raspberrypi.

bplimley commented 7 years ago

Great. Try not to add more separate issues onto this branch and pull request. You can branch off of this to build off the updated code base, for a new issue.

tybtab commented 7 years ago

Will go through once more now.

On Mon, Dec 5, 2016 at 3:03 PM, Brian Plimley notifications@github.com wrote:

@bplimley approved this pull request.

Looks good. Have you tested the data_handler.py update with network up and down, queue flushing, new protocol and old protocol?

If you have tested these then I will merge.

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/bearing/dosenet-raspberrypi/pull/71#pullrequestreview-11489708, or mute the thread https://github.com/notifications/unsubscribe-auth/AOPhT5oAVj-J5Yrw4Rd1D_MuGHMZlUfwks5rFJg0gaJpZM4Kgot4 .

tybtab commented 7 years ago

Ok i went through everything. Everything is working.