#62 Periodic serial port acquisition

v1.0 (example)
pending
Chris Liechti
None
5
2014-07-31
2014-01-17
fabads
No

Hello,

I did not find any forum to discuss this great module, so let's try here.
I am using this module to monitor my electricity production and consumption.
I capture data coming from my meter every 10 minutes.
What is the best practice:
- open, read then close every 10 minutes ?
- open at the beginning of my daemon then simply read and let the port open ?

For the moment, I put my code in a scheduler task that open, read then close.

Thanks for your advices and congratulation for this module!

Fabrice

Discussion

  • Chris Liechti
    Chris Liechti
    2014-07-31

    • status: open --> pending
    • assigned_to: Chris Liechti
     
  • Chris Liechti
    Chris Liechti
    2014-07-31

    that's tricky. there are drivers on some OS that may get into trouble after a number of open/close operations while others may work better by opening and closing the port...

    generally, leaving the port open should work well. In case you want to handle cases where the serial port may fail (e.g. USB-serial adapters that get un- and re-plugged), reopening the port after an SerialException may be a good solution.

    Apart from the port handling itself you may need to make the same considerations also for the application layer. Do you need to initialize the device? is such an initialization needed every time the port open/closes or also after a timeout? maybe it's only needed after a power outage?