Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ecrterm/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.0.8'
__version__ = '1.0.9'
18 changes: 16 additions & 2 deletions ecrterm/ecr.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
Authorisation, CloseCardSession, Completion, DisplayText, EndOfDay, Initialisation, Packet,
PrintLine, ReadCard, Registration, ReservationBookTotal, ReservationPartialReversal,
ReservationRequest, ResetTerminal, SetTerminalID, StatusEnquiry, StatusInformation, WriteFiles,
OpenReservationsEnquiry)
from ecrterm.packets.types import (ConfigByte, CurrencyCode, ServiceByte)
OpenReservationsEnquiry, Diagnosis)
from ecrterm.packets.tlv import TLVDictionary
from ecrterm.packets.types import (ConfigByte, CurrencyCode, ServiceByte, DiagnosisType)
from ecrterm.transmission._transmission import Transmission
from ecrterm.transmission.signals import ACK, DLE, ETX, NAK, STX, TRANSMIT_OK
from ecrterm.transmission.transport_serial import SerialTransport
Expand Down Expand Up @@ -422,6 +423,19 @@ def initialize(self, listener=None):

return self._send_packet(packet, listener)

def request_diagnosis(self,
diagnosis_type=DiagnosisType.EXTENDED_DIAGNOSIS,
listener=None):
"""
"""
packet = Diagnosis(
tlv={
0x1b: TLVDictionary['zvt'][0x1b].to_bytes(diagnosis_type),
}
)

return self._send_packet(packet, listener)

def _send_packet(self, packet, listener=None):
"""
Generic method to send packets and check for completion status.
Expand Down
4 changes: 4 additions & 0 deletions ecrterm/packets/base_packets.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,10 @@ class Diagnosis(Packet):
CMD_INSTR = 0x70
wait_for_completion = True

ALLOWED_BITMAPS = [
'tlv'
]

def _handle_response(self, response, tm):
if isinstance(response, PrintLine):
print(response._data)
Expand Down
8 changes: 7 additions & 1 deletion ecrterm/packets/fields.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import string
import typing
from enum import Enum
from typing import Any, Union, List, Optional, Tuple

Expand Down Expand Up @@ -177,7 +178,7 @@ def from_bytes(self, v: Union[bytes, List[int]]) -> str:
else CurrentContext.get('character_set', CharacterSet.DEFAULT)
return decode(bytes(v), character_set)

def to_bytes(self, v: str, length: int = None) -> bytes:
def to_bytes(self, v: str, length: typing.Optional[int] = None) -> bytes:
character_set = self._character_set if self._character_set is not None \
else CurrentContext.get('character_set', CharacterSet.DEFAULT)
retval = encode(v, character_set)
Expand Down Expand Up @@ -320,9 +321,14 @@ def __get__(self, instance, objtype=None) -> TLV:
0x15: StringField(name="language_code", character_set=CharacterSet.ASCII_7BIT),
0x23: ContainerType(name='receipt-numbers'),
0x1a: BEIntField(name='max_apdu_length', length=2),
0x1b: BEIntField(name='diagnosis_type', length=1),
0x1d: BEIntField(name='file_id', length=1),
0x1e: BEIntField(name='start_position', length=4),
0x40: BytesField(name='emv_config'),
# variable length -> important IDs can be found in ZvtCardType
0x41: BytesField(name='card_type_id'),
0x42: StringField(name="application_label", character_set=CharacterSet.ASCII_7BIT),
0x43: BytesField(name="application_id"),
0x1f00: BEIntField(name='file_size', length=4),
0x1f10: FlagByteField(name="cardholder_identification", data_type=CardholderIdentification),
0x1f11: FlagByteField(name='online_tag', data_type=OnlineTag),
Expand Down
16 changes: 16 additions & 0 deletions ecrterm/packets/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,19 @@ class FileID(IntEnum):
COMMUNICATION_MODULE_LOG_FILE = 0x04
PIN_PAD_LOG_FILE = 0x05
RECONCILIATION_DATA = 0x06


class DiagnosisType(IntEnum):
LINE_DIAGNOSIS = 1
EXTENDED_DIAGNOSIS = 2
CONFIGURATION_DIAGNOSIS = 3
EMV_CONFIGURATION_DIAGNOSIS = 4
EP2_CONFIGURATION_DIAGNOSIS = 5


class ZvtCardType(IntEnum):
GIROCARD = 5
MASTERCARD = 6
VISA = 10
VPAY = 13
MAESTRO = 46