Am Freitag, 25. November 2016 21:14:12 UTC+1 schrieb Tom Keffer:
>
> Yes, alternatively getConsoleTime could be implemented as:
>
> def getConsoleTime(self):
> return datetime.datetime()
>
>
Does not work!
datetime.datetime() needs valid parameters yr, mon, day, hr...
I tried datetime.now() but got these errors:
Nov 26 15:10:50 raspberrypi weewx[3367]: **** return datetime.now
Nov 26 15:10:50 raspberrypi weewx[3367]: **** AttributeError: 'module'
object has no attribute 'now'
Nov 26 15:10:50 raspberrypi weewx[3367]: **** Exiting.
Here's some code:
def getConsoleTime(self):
"""Return the raw time on the console, uncorrected for DST or
timezone."""
# Try up to max_tries times:
for unused_count in xrange(self.max_tries):
try:
# Wake up the console...
self.port.wakeup_console(max_tries=self.max_tries)
# ... request the time...
self.port.send_data('GETTIME\n')
# ... get the binary data. No prompt, only one try:
_buffer = self.port.get_data_with_crc16(8, max_tries=1)
(sec, minute, hr, day, mon, yr, unused_crc) =
struct.unpack("<bbbbbbH", _buffer)
return datetime.datetime(yr + 1900, mon, day, hr, minute,
sec)
except weewx.WeeWxIOError:
# Caught an error. Keep retrying...
continue
syslog.syslog(syslog.LOG_ERR, "vantage: Max retries exceeded while
getting time")
return datetime.now()
#raise weewx.RetriesExceeded("While getting console time")
When there is no GETTIME answer it ends in syslog.syslog(...) correct?
Then it should return a datetime contruct for the "now" date and time.
Wouldn't that be a solution that covers Davis and 3rd party connectors?
--
You received this message because you are subscribed to the Google Groups
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.