log checksum errors as warning; dont force full telegram signatures; removed unused code for automatic telegram version detection;
This commit is contained in:
parent
5f1afeb1f8
commit
d6e28db116
@ -1,6 +1,12 @@
|
||||
Change Log
|
||||
----------
|
||||
|
||||
**0.10** (2017-06-05)
|
||||
|
||||
- bugix: don't force full telegram signatures (`pull request #25 <https://github.com/ndokter/dsmr_parser/pull/25>`_)
|
||||
- removed unused code for automatic telegram detection as this needs reworking after the fix mentioned above
|
||||
- InvalidChecksumError's are logged as warning instead of error
|
||||
|
||||
**0.9** (2017-05-12)
|
||||
|
||||
- added DSMR v5 serial settings
|
||||
|
@ -101,6 +101,8 @@ class DSMRProtocol(asyncio.Protocol):
|
||||
|
||||
try:
|
||||
parsed_telegram = self.telegram_parser.parse(telegram)
|
||||
except InvalidChecksumError as e:
|
||||
self.log.warning(str(e))
|
||||
except ParseError:
|
||||
self.log.exception("failed to parse telegram")
|
||||
else:
|
||||
|
@ -36,6 +36,8 @@ class SerialReader(object):
|
||||
for telegram in self.telegram_buffer.get_all():
|
||||
try:
|
||||
yield self.telegram_parser.parse(telegram)
|
||||
except InvalidChecksumError as e:
|
||||
logger.warning(str(e))
|
||||
except ParseError as e:
|
||||
logger.error('Failed to parse telegram: %s', e)
|
||||
|
||||
|
@ -92,31 +92,6 @@ class TelegramParser(object):
|
||||
)
|
||||
|
||||
|
||||
def match_telegram_specification(telegram_data):
|
||||
"""
|
||||
Find telegram specification that matches the telegram data by trying all
|
||||
specifications.
|
||||
|
||||
Could be further optimized to check the actual 0.2.8 OBIS reference which
|
||||
is available for DSMR version 4 and up.
|
||||
|
||||
:param str telegram_data: full telegram from start ('/') to checksum
|
||||
('!ABCD') including line endings in between the telegram's lines
|
||||
:return: telegram specification
|
||||
:rtype: dict
|
||||
"""
|
||||
# Prevent circular import
|
||||
from dsmr_parser import telegram_specifications
|
||||
|
||||
for specification in telegram_specifications.ALL:
|
||||
try:
|
||||
TelegramParser(specification).parse(telegram_data)
|
||||
except ParseError:
|
||||
pass
|
||||
else:
|
||||
return specification
|
||||
|
||||
|
||||
class DSMRObjectParser(object):
|
||||
"""
|
||||
Parses an object (can also be see as a 'line') from a telegram.
|
||||
@ -174,10 +149,11 @@ class CosemParser(DSMRObjectParser):
|
||||
1 23 45
|
||||
|
||||
1) OBIS Reduced ID-code
|
||||
2) Separator “(“, ASCII 28h
|
||||
2) Separator "(", ASCII 28h
|
||||
3) COSEM object attribute value
|
||||
4) Unit of measurement values (Unit of capture objects attribute) – only if applicable
|
||||
5) Separator “)”, ASCII 29h
|
||||
4) Unit of measurement values (Unit of capture objects attribute) - only if
|
||||
applicable
|
||||
5) Separator ")", ASCII 29h
|
||||
"""
|
||||
|
||||
def parse(self, line):
|
||||
|
2
setup.py
2
setup.py
@ -6,7 +6,7 @@ setup(
|
||||
author='Nigel Dokter',
|
||||
author_email='nigeldokter@gmail.com',
|
||||
url='https://github.com/ndokter/dsmr_parser',
|
||||
version='0.9',
|
||||
version='0.10',
|
||||
packages=find_packages(),
|
||||
install_requires=[
|
||||
'pyserial>=3,<4',
|
||||
|
@ -1,24 +0,0 @@
|
||||
import unittest
|
||||
|
||||
from dsmr_parser.parsers import match_telegram_specification
|
||||
from dsmr_parser import telegram_specifications
|
||||
from test import example_telegrams
|
||||
|
||||
|
||||
class MatchTelegramSpecificationTest(unittest.TestCase):
|
||||
|
||||
def test_v2_2(self):
|
||||
assert match_telegram_specification(example_telegrams.TELEGRAM_V2_2) \
|
||||
== telegram_specifications.V2_2
|
||||
|
||||
def test_v3(self):
|
||||
assert match_telegram_specification(example_telegrams.TELEGRAM_V3) \
|
||||
== telegram_specifications.V3
|
||||
|
||||
def test_v4_2(self):
|
||||
assert match_telegram_specification(example_telegrams.TELEGRAM_V4_2) \
|
||||
== telegram_specifications.V4
|
||||
|
||||
def test_v5(self):
|
||||
assert match_telegram_specification(example_telegrams.TELEGRAM_V5) \
|
||||
== telegram_specifications.V5
|
Loading…
Reference in New Issue
Block a user