Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
684023d0b6 | ||
|
|
1a886aa03b | ||
|
|
1c7535448e | ||
|
|
2a95d33c02 | ||
|
|
de6725dff8 | ||
|
|
1b1a3f505e | ||
|
|
ebea385753 | ||
|
|
700cf6a2b3 | ||
|
|
7a687a99a6 | ||
|
|
86d665df39 | ||
|
|
ec1d37ea08 | ||
|
|
0427ace079 | ||
|
|
addf9b590e | ||
|
|
51f821a7fc | ||
|
|
5630520771 | ||
|
|
78419f6cc7 |
+1
-1
@@ -2,9 +2,9 @@ language: python
|
||||
|
||||
python:
|
||||
- 2.7
|
||||
- 3.4
|
||||
- 3.5
|
||||
- 3.6
|
||||
- 3.8
|
||||
|
||||
install: pip install tox-travis codecov
|
||||
|
||||
|
||||
@@ -1,5 +1,19 @@
|
||||
Change Log
|
||||
----------
|
||||
|
||||
**0.24** (2020-11-27)
|
||||
- Add Luxembourg equipment identifier (`pull request #62 <https://github.com/ndokter/dsmr_parser/pull/62>`_).
|
||||
|
||||
**0.23** (2020-11-07)
|
||||
- Resolved issue with x-x:24.3.0 where it contains non-integer character (`pull request #61 <https://github.com/ndokter/dsmr_parser/pull/61>`_).
|
||||
- Tests are not installed anymore (`pull request #59 <https://github.com/ndokter/dsmr_parser/pull/59>`_).
|
||||
- Example telegram improvement (`pull request #58 <https://github.com/ndokter/dsmr_parser/pull/58>`_).
|
||||
|
||||
**0.22** (2020-08-23)
|
||||
|
||||
- CRC check speed is improved
|
||||
- Exception info improvement
|
||||
|
||||
**0.21** (2020-05-25)
|
||||
|
||||
- All objects can produce a json serialization of their state.
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@ into a dictionary.
|
||||
|
||||
# String is formatted in separate lines for readability.
|
||||
telegram_str = (
|
||||
'/ISk5\2MT382-1000\r\n'
|
||||
'/ISk5\\2MT382-1000\r\n'
|
||||
'\r\n'
|
||||
'0-0:96.1.1(4B384547303034303436333935353037)\r\n'
|
||||
'1-0:1.8.1(12345.678*kWh)\r\n'
|
||||
|
||||
@@ -29,6 +29,9 @@ def create_dsmr_protocol(dsmr_version, telegram_callback, loop=None):
|
||||
elif dsmr_version == '5B':
|
||||
specification = telegram_specifications.BELGIUM_FLUVIUS
|
||||
serial_settings = SERIAL_SETTINGS_V5
|
||||
elif dsmr_version == "5L":
|
||||
specification = telegram_specifications.LUXEMBOURG_SMARTY
|
||||
serial_settings = SERIAL_SETTINGS_V5
|
||||
else:
|
||||
raise NotImplementedError("No telegram parser found for version: %s",
|
||||
dsmr_version)
|
||||
@@ -95,7 +98,7 @@ class DSMRProtocol(asyncio.Protocol):
|
||||
def connection_lost(self, exc):
|
||||
"""Stop when connection is lost."""
|
||||
if exc:
|
||||
self.log.exception('disconnected due to exception')
|
||||
self.log.exception('disconnected due to exception', exc_info=exc)
|
||||
else:
|
||||
self.log.info('disconnected because of close/abort.')
|
||||
self._closed.set()
|
||||
|
||||
@@ -63,5 +63,6 @@ ELECTRICITY_DELIVERED_TARIFF_ALL = (
|
||||
|
||||
# Alternate codes for foreign countries.
|
||||
BELGIUM_HOURLY_GAS_METER_READING = r'\d-\d:24\.2\.3.+?\r\n' # Different code, same format.
|
||||
LUXEMBOURG_EQUIPMENT_IDENTIFIER = r'\d-\d:42\.0\.0.+?\r\n' # Logical device name
|
||||
LUXEMBOURG_ELECTRICITY_USED_TARIFF_GLOBAL = r'\d-\d:1\.8\.0.+?\r\n' # Total imported energy register (P+)
|
||||
LUXEMBOURG_ELECTRICITY_DELIVERED_TARIFF_GLOBAL = r'\d-\d:2\.8\.0.+?\r\n' # Total exported energy register (P-)
|
||||
|
||||
+17
-11
@@ -11,6 +11,8 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
class TelegramParser(object):
|
||||
|
||||
crc16_tab = []
|
||||
|
||||
def __init__(self, telegram_specification, apply_checksum_validation=True):
|
||||
"""
|
||||
:param telegram_specification: determines how the telegram is parsed
|
||||
@@ -93,24 +95,28 @@ 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))
|
||||
"""
|
||||
Calculate the CRC16 value for the given telegram
|
||||
|
||||
:param str telegram:
|
||||
"""
|
||||
crcValue = 0x0000
|
||||
|
||||
if len(TelegramParser.crc16_tab) == 0:
|
||||
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
|
||||
TelegramParser.crc16_tab.append(hex(crc))
|
||||
|
||||
for c in telegram:
|
||||
d = ord(c)
|
||||
tmp = crcValue ^ d
|
||||
rotated = c_ushort(crcValue >> 8).value
|
||||
crcValue = rotated ^ int(crc16_tab[(tmp & 0x00ff)], 0)
|
||||
crcValue = rotated ^ int(TelegramParser.crc16_tab[(tmp & 0x00ff)], 0)
|
||||
|
||||
return crcValue
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ V2_2 = {
|
||||
obis.VALVE_POSITION_GAS: CosemParser(ValueParser(str)),
|
||||
obis.GAS_METER_READING: MBusParser(
|
||||
ValueParser(timestamp),
|
||||
ValueParser(int),
|
||||
ValueParser(str), # changed to str see issue60
|
||||
ValueParser(int),
|
||||
ValueParser(int),
|
||||
ValueParser(str), # obis ref
|
||||
@@ -152,6 +152,7 @@ BELGIUM_FLUVIUS['objects'].update({
|
||||
|
||||
LUXEMBOURG_SMARTY = deepcopy(V5)
|
||||
LUXEMBOURG_SMARTY['objects'].update({
|
||||
obis.LUXEMBOURG_EQUIPMENT_IDENTIFIER: CosemParser(ValueParser(str)),
|
||||
obis.LUXEMBOURG_ELECTRICITY_USED_TARIFF_GLOBAL: CosemParser(ValueParser(Decimal)),
|
||||
obis.LUXEMBOURG_ELECTRICITY_DELIVERED_TARIFF_GLOBAL: CosemParser(ValueParser(Decimal)),
|
||||
})
|
||||
|
||||
@@ -6,8 +6,8 @@ setup(
|
||||
author='Nigel Dokter',
|
||||
author_email='nigel@nldr.net',
|
||||
url='https://github.com/ndokter/dsmr_parser',
|
||||
version='0.21',
|
||||
packages=find_packages(),
|
||||
version='0.24',
|
||||
packages=find_packages(exclude=('test', 'test.*')),
|
||||
install_requires=[
|
||||
'pyserial>=3,<4',
|
||||
'pyserial-asyncio<1',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
TELEGRAM_V2_2 = (
|
||||
'/ISk5\2MT382-1004\r\n'
|
||||
'/ISk5\\2MT382-1004\r\n'
|
||||
'\r\n'
|
||||
'0-0:96.1.1(00000000000000)\r\n'
|
||||
'1-0:1.8.1(00001.001*kWh)\r\n'
|
||||
@@ -22,7 +22,7 @@ TELEGRAM_V2_2 = (
|
||||
)
|
||||
|
||||
TELEGRAM_V3 = (
|
||||
'/ISk5\2MT382-1000\r\n'
|
||||
'/ISk5\\2MT382-1000\r\n'
|
||||
'\r\n'
|
||||
'0-0:96.1.1(4B384547303034303436333935353037)\r\n'
|
||||
'1-0:1.8.1(12345.678*kWh)\r\n'
|
||||
@@ -87,7 +87,7 @@ TELEGRAM_V4_2 = (
|
||||
)
|
||||
|
||||
TELEGRAM_V5 = (
|
||||
'/ISk5\2MT382-1000\r\n'
|
||||
'/ISk5\\2MT382-1000\r\n'
|
||||
'\r\n'
|
||||
'1-3:0.2.8(50)\r\n'
|
||||
'0-0:1.0.0(170102192002W)\r\n'
|
||||
@@ -126,5 +126,5 @@ TELEGRAM_V5 = (
|
||||
'0-1:24.2.1(170102161005W)(00000.107*m3)\r\n'
|
||||
'0-2:24.1.0(003)\r\n'
|
||||
'0-2:96.1.0()\r\n'
|
||||
'!87B3\r\n'
|
||||
)
|
||||
'!6EEE\r\n'
|
||||
)
|
||||
Reference in New Issue
Block a user