Skip to content

Commit db34e36

Browse files
authored
Merge pull request #19 from wirelane/feature/support-for-requesting-an-explicit-diagnosis-type
Support for requesting an explicit diagnosis type + Support for (common) card type ids + application label/id
2 parents f179162 + 44878c5 commit db34e36

5 files changed

Lines changed: 44 additions & 4 deletions

File tree

ecrterm/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '1.0.8'
1+
__version__ = '1.0.9'

ecrterm/ecr.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
Authorisation, CloseCardSession, Completion, DisplayText, EndOfDay, Initialisation, Packet,
2020
PrintLine, ReadCard, Registration, ReservationBookTotal, ReservationPartialReversal,
2121
ReservationRequest, ResetTerminal, SetTerminalID, StatusEnquiry, StatusInformation, WriteFiles,
22-
OpenReservationsEnquiry)
23-
from ecrterm.packets.types import (ConfigByte, CurrencyCode, ServiceByte)
22+
OpenReservationsEnquiry, Diagnosis)
23+
from ecrterm.packets.tlv import TLVDictionary
24+
from ecrterm.packets.types import (ConfigByte, CurrencyCode, ServiceByte, DiagnosisType)
2425
from ecrterm.transmission._transmission import Transmission
2526
from ecrterm.transmission.signals import ACK, DLE, ETX, NAK, STX, TRANSMIT_OK
2627
from ecrterm.transmission.transport_serial import SerialTransport
@@ -422,6 +423,19 @@ def initialize(self, listener=None):
422423

423424
return self._send_packet(packet, listener)
424425

426+
def request_diagnosis(self,
427+
diagnosis_type=DiagnosisType.EXTENDED_DIAGNOSIS,
428+
listener=None):
429+
"""
430+
"""
431+
packet = Diagnosis(
432+
tlv={
433+
0x1b: TLVDictionary['zvt'][0x1b].to_bytes(diagnosis_type),
434+
}
435+
)
436+
437+
return self._send_packet(packet, listener)
438+
425439
def _send_packet(self, packet, listener=None):
426440
"""
427441
Generic method to send packets and check for completion status.

ecrterm/packets/base_packets.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,10 @@ class Diagnosis(Packet):
368368
CMD_INSTR = 0x70
369369
wait_for_completion = True
370370

371+
ALLOWED_BITMAPS = [
372+
'tlv'
373+
]
374+
371375
def _handle_response(self, response, tm):
372376
if isinstance(response, PrintLine):
373377
print(response._data)

ecrterm/packets/fields.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import string
2+
import typing
23
from enum import Enum
34
from typing import Any, Union, List, Optional, Tuple
45

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

180-
def to_bytes(self, v: str, length: int = None) -> bytes:
181+
def to_bytes(self, v: str, length: typing.Optional[int] = None) -> bytes:
181182
character_set = self._character_set if self._character_set is not None \
182183
else CurrentContext.get('character_set', CharacterSet.DEFAULT)
183184
retval = encode(v, character_set)
@@ -320,9 +321,14 @@ def __get__(self, instance, objtype=None) -> TLV:
320321
0x15: StringField(name="language_code", character_set=CharacterSet.ASCII_7BIT),
321322
0x23: ContainerType(name='receipt-numbers'),
322323
0x1a: BEIntField(name='max_apdu_length', length=2),
324+
0x1b: BEIntField(name='diagnosis_type', length=1),
323325
0x1d: BEIntField(name='file_id', length=1),
324326
0x1e: BEIntField(name='start_position', length=4),
325327
0x40: BytesField(name='emv_config'),
328+
# variable length -> important IDs can be found in ZvtCardType
329+
0x41: BytesField(name='card_type_id'),
330+
0x42: StringField(name="application_label", character_set=CharacterSet.ASCII_7BIT),
331+
0x43: BytesField(name="application_id"),
326332
0x1f00: BEIntField(name='file_size', length=4),
327333
0x1f10: FlagByteField(name="cardholder_identification", data_type=CardholderIdentification),
328334
0x1f11: FlagByteField(name='online_tag', data_type=OnlineTag),

ecrterm/packets/types.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,19 @@ class FileID(IntEnum):
8181
COMMUNICATION_MODULE_LOG_FILE = 0x04
8282
PIN_PAD_LOG_FILE = 0x05
8383
RECONCILIATION_DATA = 0x06
84+
85+
86+
class DiagnosisType(IntEnum):
87+
LINE_DIAGNOSIS = 1
88+
EXTENDED_DIAGNOSIS = 2
89+
CONFIGURATION_DIAGNOSIS = 3
90+
EMV_CONFIGURATION_DIAGNOSIS = 4
91+
EP2_CONFIGURATION_DIAGNOSIS = 5
92+
93+
94+
class ZvtCardType(IntEnum):
95+
GIROCARD = 5
96+
MASTERCARD = 6
97+
VISA = 10
98+
VPAY = 13
99+
MAESTRO = 46

0 commit comments

Comments
 (0)