Cereal2nd / velbus-aio

Velbus Asyncio
Apache License 2.0
15 stars 10 forks source link

Fix incomplete channel names #21

Closed DannyDeGaspari closed 2 years ago

DannyDeGaspari commented 2 years ago

Add extra delay after a 'channel name request' command. The command can provoke a lot of answer packets. When the delay is not large enough to let the answer packets arrive, subsequent commands cause loss of answer packets. I added an extra delay of 33 x SLEEP_TIMEOUT, this should be enough of the worst case scenario when VMBGPOD is replying with 33 * 3 answer packets. Maybe other newer modules send even more answer packets ? Not sure. I suspect the answer packets get lost in the modules itself not able to put the packets on the bus while it is flooded with new commands.

After the update, users should clear the velbuscache to renew the readout of all modules.

DannyDeGaspari commented 2 years ago

so this will give a delay of 2 seonds for every channel name request? won't this make the loading a lot slower?

Yes, it will. But it makes the loading fail proof. If one of the name request answers is missing it will result in a 'module not fully loaded' and hence it will not be available. And there is the cache which makes sure it needs to go through this 'slow' loading only once.

Further optimization of the load speed could be to use a variable delay depending on the module.