ganehag / pyMeterBus

Pure Python implementation of the Meter-Bus (M-Bus EN13757-3) protocol.
BSD 3-Clause "New" or "Revised" License
77 stars 40 forks source link

Load multiple frames at once and universal support for to_JSON in frames #14

Open blagasz opened 5 years ago

blagasz commented 5 years ago

I needed to load multiple frames at once for an mbus project over tcp, so I wanted to add support for it. Hope I found a good way to integrate it with the current code.

I also added to_JSON for all the frame types except for WTelegramSndNr.

If you have any suggestions I am happy to (try to) implement them.

codecov[bot] commented 5 years ago

Codecov Report

Merging #14 into master will decrease coverage by 1.32%. The diff coverage is 50.98%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #14      +/-   ##
==========================================
- Coverage   79.64%   78.32%   -1.33%     
==========================================
  Files          20       20              
  Lines        1538     1578      +40     
==========================================
+ Hits         1225     1236      +11     
- Misses        313      342      +29
Impacted Files Coverage Δ
meterbus/telegram_header.py 100% <ø> (ø) :arrow_up:
meterbus/telegram_body.py 84.3% <100%> (ø) :arrow_up:
meterbus/telegram_short.py 96% <100%> (+0.08%) :arrow_up:
meterbus/telegram_long.py 68.14% <100%> (-0.05%) :arrow_down:
meterbus/__init__.py 69.11% <40%> (-30.89%) :arrow_down:
meterbus/telegram_ack.py 81.81% <60%> (-6.42%) :arrow_down:
meterbus/telegram_control.py 96.55% <60%> (-3.45%) :arrow_down:
meterbus/exceptions.py 93.75% <0%> (-6.25%) :arrow_down:
meterbus/serial.py 97.87% <0%> (-2.13%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update f248942...f6b0585. Read the comment docs.

ganehag commented 5 years ago

I haven't had any time to review it yet. I will do it in the coming days.

blagasz commented 5 years ago

Ok, no worries. I was wondering if a more efficient internal representation of the telegram objects could be implemented with the help of numpy. Based on this https://www.numpy.org/devdocs/reference/arrays.dtypes.html#specifying-and-constructing-data-types I would say it is worth considering.

blagasz commented 5 years ago

Encountered a rare error in parse. If my manufacturer specific TelegramLong message has a certain length, then it is parsed as WTelegramSndNr accidentally when parse tries different types.