Improve startup sequence to be compliant with the spec#20
Improve startup sequence to be compliant with the spec#20emontnemery wants to merge 1 commit intopwitab:masterfrom
Conversation
|
Hi. thanks for the PR. What problem are you intending to solve with this PR? I don't think the baudrate bound solution is the best since this is not reliable when sending over TCP, which is what I do mostly in production. But it could be updated to reflect timings in the standard a bit better. I have never had problems waking a device up though. BATTERY_STARTUP_SEQUENCE_TIME = 2.2
INTER_NULL_CHAR_TIMEOUT = 0.0025
POST_BATTERY_STARTUP_WAIT_TIME = 1.5
duration = 0
start_time = time.time()
logger.info("Sending battery startup sequence")
while duration < BATTERY_STARTUP_SEQUENCE_TME:
out = b"\x00"
self.transport.send(out)
time.sleep(INTER_NULL_CHAR_TIMEOUT)
duration = time.time() - start_time
logger.info("Startup Sequence finished")
self.rest(POST_BATTERY_STARTUP_WAIT_TIME)The I have an idea to rewrite the lib with a sans-io approach to that suff like this is more clearly handled. |
No, that's not the case, the standard specifies a maximum delay of 5 ms: The problem I'm trying to solve is to precisely make the wakeup work reliably over network, my meter failed to wake up reliably with the delays; maybe it honors the 5 ms maximum delay time and other meters accept delays which are orders of magnitude out of spec? In your case:
On the other end of the network, there must be a serial port with a fixed or otherwise known baud rate?
I see, and my meter does not allow initiating communication at other baudrates than 300. |
Improve startup sequence to be compliant with the spec:
NULcharacters in the wakeup message for battery powered devices, and since the wakeup message is sent at 300 baud we can send a predetermined number ofNULcharacters