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

Pull the most current samples with the READ command? #11

Open
spiff72 opened this issue Jul 26, 2016 · 11 comments
Open

Pull the most current samples with the READ command? #11

spiff72 opened this issue Jul 26, 2016 · 11 comments

Comments

@spiff72
Copy link

spiff72 commented Jul 26, 2016

Hello,

I have your hacklet installed on my Raspberry Pi (running OctoPi for my 3D printer). So far it is very slick!

I just have a question, and I am not sure where to ask...

It appears that the READ command grabs the oldest 20 datapoints for power usage, and to get to the most recent, the command would need to be run many, many times to clear out the buffer of the Modlet. Is there a way to specify that you want the most RECENT data points? Or a way to specify the number of data points you want to pull?

Thanks!

@mcolyer
Copy link
Owner

mcolyer commented Jul 26, 2016 via email

@spiff72
Copy link
Author

spiff72 commented Jul 26, 2016

Actually, this prompts another question.

The way that the USB dongle is being used, it would not be able to be added to the gateways on my "mymodlet" account, correct? I haven't used that account in years, so I would need to poke around to remember how to add a gateway (I had only used the ethernet gateway before), but if it COULD be added, maybe that would keep the data offloaded? Perhaps that functionality was what you stripped away when you created this lightweight client?

@mcolyer
Copy link
Owner

mcolyer commented Jul 26, 2016

I haven't used the gateways either, but I think the short answer is that this client doesn't work with their cloud platform. I think the way that this worked was that their client would upload the data to the cloud and since their client isn't running that wouldn't work with hacklet.

If you want to store the data the best approach is to try running hacklet with cron to continually fetch the data.

@spiff72
Copy link
Author

spiff72 commented Jul 29, 2016

No problem - I have checked the usage, so I have an idea of the max power that the printer is using, and that is good enough.

When I get some more time to play with this, I might take a shot at the cron option. The longer I wait, the bigger the queue gets, though! I recommissioned things yesterday, and I am at 9000-odd records now.

@clintonm9
Copy link

Would love to find a way to clear out the old store samples.

I, [2018-02-05T14:54:59.092249 #28081] INFO -- : 20 returned, 99906 remaining

The only hack way I can figure is to create a loop to run through all the remaining samples. The issue I find is if you run it too fast that the program sometimes hangs.

@mcolyer
Copy link
Owner

mcolyer commented Feb 6, 2018

The only hack way I can figure is to create a loop to run through all the remaining samples.

This is the only way that I found to do it - I'm not sure that there is another way as the original application was designed to poll the outlets frequently and the buffer behavior was only there in case the outlet was disconnected for a period of time.

@spiff72
Copy link
Author

spiff72 commented Jul 15, 2019

Posting on an old comment, but if I get some time I might try playing around with cron and see if i can come up with a simple way to do this. I haven't looked at this in a long time, and I am just reconfiguring a second raspberry pi to use octoprint for a second 3d printer, and this forced me to think about this again.

@mcolyer
Copy link
Owner

mcolyer commented Jul 16, 2019

If I recall, there might be a way to call the command repeatedly until it exhausts it’s buffer and comes back with less than 20 data points. If you come up with a patch for it, I’d consider including it.

@spiff72
Copy link
Author

spiff72 commented Oct 21, 2019

It's been a while, but I have settled (for now) on creating a pair of cron jobs that basically runs the read command for the top outlet on even minutes, and bottom outlet on odd minutes. Since these devices appear to read the power data every 10 seconds, running the read command every 2 minutes effectively keeps the buffers empty. I have the jobs sending their outputs to a log file so I can see the data there, or i can just run the command to read the data manually from a command line (if I get no results, waiting for 10 seconds and re-running will give a new result).

The hardest part right now is "purging" 100000+ entries. I ran a watch command at 1 second intervals and just let it run until it returned a result that showed the buffer was empty. I wish there was a way to just delete the buffer, but this gets the job done - and hopefully the cron jobs keep them clear!

@clintonm9
Copy link

I have had the same issue in the past with the buffer too full. If you can, you can unplug the device and plug it back in and it will clear the buffer. Not sure if that is an option for you or not.

@spiff72
Copy link
Author

spiff72 commented Oct 21, 2019

I wasn't aware that would clear the buffer. If I hadn't just started a 3D print (utilizing the bottom outlet), I would try it right now!

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

No branches or pull requests

3 participants