merged upstream 0.18 version and resolved conflict
This commit is contained in:
parent
0675a6e2e7
commit
fee3f696c4
@ -1,6 +1,14 @@
|
|||||||
Change Log
|
Change Log
|
||||||
----------
|
----------
|
||||||
|
|
||||||
|
**0.18** (2020-01-28)
|
||||||
|
|
||||||
|
- PyCRC replacement (`pull request #48 <https://github.com/ndokter/dsmr_parser/pull/48>`_).
|
||||||
|
|
||||||
|
**0.17** (2019-12-21)
|
||||||
|
|
||||||
|
- Add a true telegram object (`pull request #40 <https://github.com/ndokter/dsmr_parser/pull/40>`_).
|
||||||
|
|
||||||
**0.16** (2019-12-21)
|
**0.16** (2019-12-21)
|
||||||
|
|
||||||
- Add support for Belgian and Smarty meters (`pull request #44 <https://github.com/ndokter/dsmr_parser/pull/44>`_).
|
- Add support for Belgian and Smarty meters (`pull request #44 <https://github.com/ndokter/dsmr_parser/pull/44>`_).
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from PyCRC.CRC16 import CRC16
|
from ctypes import c_ushort
|
||||||
|
|
||||||
from dsmr_parser.objects import MBusObject, CosemObject, Telegram
|
from dsmr_parser.objects import MBusObject, CosemObject, Telegram
|
||||||
from dsmr_parser.exceptions import ParseError, InvalidChecksumError
|
from dsmr_parser.exceptions import ParseError, InvalidChecksumError
|
||||||
@ -79,7 +79,7 @@ class TelegramParser(object):
|
|||||||
'incomplete. The checksum and/or content values are missing.'
|
'incomplete. The checksum and/or content values are missing.'
|
||||||
)
|
)
|
||||||
|
|
||||||
calculated_crc = CRC16().calculate(checksum_contents.group(0))
|
calculated_crc = TelegramParser.crc16(checksum_contents.group(0))
|
||||||
expected_crc = int(checksum_hex.group(0), base=16)
|
expected_crc = int(checksum_hex.group(0), base=16)
|
||||||
|
|
||||||
if calculated_crc != expected_crc:
|
if calculated_crc != expected_crc:
|
||||||
@ -91,6 +91,29 @@ class TelegramParser(object):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def crc16(telegram):
|
||||||
|
crc16_tab = []
|
||||||
|
|
||||||
|
for i in range(0, 256):
|
||||||
|
crc = c_ushort(i).value
|
||||||
|
for j in range(0, 8):
|
||||||
|
if (crc & 0x0001):
|
||||||
|
crc = c_ushort(crc >> 1).value ^ 0xA001
|
||||||
|
else:
|
||||||
|
crc = c_ushort(crc >> 1).value
|
||||||
|
crc16_tab.append(hex(crc))
|
||||||
|
|
||||||
|
crcValue = 0x0000
|
||||||
|
|
||||||
|
for c in telegram:
|
||||||
|
d = ord(c)
|
||||||
|
tmp = crcValue ^ d
|
||||||
|
rotated = c_ushort(crcValue >> 8).value
|
||||||
|
crcValue = rotated ^ int(crc16_tab[(tmp & 0x00ff)], 0)
|
||||||
|
|
||||||
|
return crcValue
|
||||||
|
|
||||||
|
|
||||||
class DSMRObjectParser(object):
|
class DSMRObjectParser(object):
|
||||||
"""
|
"""
|
||||||
|
3
setup.py
3
setup.py
@ -6,13 +6,12 @@ setup(
|
|||||||
author='Nigel Dokter',
|
author='Nigel Dokter',
|
||||||
author_email='nigel@nldr.net',
|
author_email='nigel@nldr.net',
|
||||||
url='https://github.com/ndokter/dsmr_parser',
|
url='https://github.com/ndokter/dsmr_parser',
|
||||||
version='0.17',
|
version='0.19',
|
||||||
packages=find_packages(),
|
packages=find_packages(),
|
||||||
install_requires=[
|
install_requires=[
|
||||||
'pyserial>=3,<4',
|
'pyserial>=3,<4',
|
||||||
'pyserial-asyncio<1',
|
'pyserial-asyncio<1',
|
||||||
'pytz',
|
'pytz',
|
||||||
'PyCRC>=1.2,<2',
|
|
||||||
'Tailer==0.4.1'
|
'Tailer==0.4.1'
|
||||||
],
|
],
|
||||||
entry_points={
|
entry_points={
|
||||||
|
Loading…
Reference in New Issue
Block a user