changed relative imports to absolute; renamed TelegramBuffer.put to TelegramBuffer.append;

This commit is contained in:
Nigel Dokter
2017-01-09 20:15:55 +01:00
parent 11672d0512
commit 21334e5a0a
6 changed files with 25 additions and 24 deletions

View File

@@ -3,7 +3,7 @@ import asyncio
import logging
from functools import partial
from .protocol import create_dsmr_reader, create_tcp_dsmr_reader
from dsmr_parser.protocol import create_dsmr_reader, create_tcp_dsmr_reader
def console():

View File

@@ -3,9 +3,9 @@ import re
from PyCRC.CRC16 import CRC16
from .objects import MBusObject, MBusObjectV2_2, CosemObject
from .exceptions import ParseError, InvalidChecksumError
from .obis_references import GAS_METER_READING
from dsmr_parser.objects import MBusObject, MBusObjectV2_2, CosemObject
from dsmr_parser.exceptions import ParseError, InvalidChecksumError
from dsmr_parser.obis_references import GAS_METER_READING
logger = logging.getLogger(__name__)

View File

@@ -6,10 +6,11 @@ from functools import partial
from serial_asyncio import create_serial_connection
from . import telegram_specifications
from .exceptions import ParseError
from .parsers import TelegramParserV2_2, TelegramParserV4
from .serial import (SERIAL_SETTINGS_V2_2, SERIAL_SETTINGS_V4, TelegramBuffer)
from dsmr_parser import telegram_specifications
from dsmr_parser.exceptions import ParseError
from dsmr_parser.parsers import TelegramParserV2_2, TelegramParserV4
from dsmr_parser.serial import (SERIAL_SETTINGS_V2_2, SERIAL_SETTINGS_V4,
TelegramBuffer)
def create_dsmr_protocol(dsmr_version, telegram_callback, loop=None):
@@ -79,7 +80,7 @@ class DSMRProtocol(asyncio.Protocol):
"""Add incoming data to buffer."""
data = data.decode('ascii')
self.log.debug('received data: %s', data)
self.telegram_buffer.put(data)
self.telegram_buffer.append(data)
for telegram in self.telegram_buffer.get_all():
self.handle_telegram(telegram)

View File

@@ -59,7 +59,7 @@ class SerialReader(object):
with serial.Serial(**self.serial_settings) as serial_handle:
while True:
data = serial_handle.readline()
self.telegram_buffer.put(data.decode('ascii'))
self.telegram_buffer.append(data.decode('ascii'))
for telegram in self.telegram_buffer.get_all():
try:
@@ -92,7 +92,7 @@ class AsyncSerialReader(SerialReader):
# Read line if available or give control back to loop until new
# data has arrived.
data = yield from reader.readline()
self.telegram_buffer.put(data.decode('ascii'))
self.telegram_buffer.append(data.decode('ascii'))
for telegram in self.telegram_buffer.get_all():
try:
@@ -122,7 +122,7 @@ class TelegramBuffer(object):
self._remove(telegram)
yield telegram
def put(self, data):
def append(self, data):
"""
Add telegram data to buffer.
:param str data: chars, lines or full telegram strings of telegram data

View File

@@ -1,8 +1,8 @@
from decimal import Decimal
from . import obis_references as obis
from .parsers import CosemParser, ValueParser, MBusParser
from .value_types import timestamp
from dsmr_parser import obis_references as obis
from dsmr_parser.parsers import CosemParser, ValueParser, MBusParser
from dsmr_parser.value_types import timestamp
"""