Example #1
0
    return _matcher


_is_init_reply = _create_matcher(_INIT_RESPONSE, b'\x01')
_is_keepalive_response = _create_matcher(_KEEPALIVE_RESPONSE, b'\x05')
_is_uknown_message_error = _create_matcher(_UNKNOWN_MESSAGE_RESPONSE, b'\x85')
_is_encryption_missing_error = _create_matcher(_ENCRYPTION_SETUP_RESPONSE,
                                               b'\x15')
_is_encryption_setup_error = _create_matcher(_ENCRYPTION_SETUP_RESPONSE,
                                             b'\x14')

_FREESTYLE_MESSAGE = construct.Struct(
    'hid_report' / construct.Const(0, construct.Byte),
    'message_type' / construct.Byte,
    'command' / construct.Padded(
        63,  # command can only be up to 62 bytes, but one is used for length.
        construct.Prefixed(construct.Byte, construct.GreedyBytes)),
)

_FREESTYLE_ENCRYPTED_MESSAGE = construct.Struct(
    'hid_report' / construct.Const(0, construct.Byte),
    'message_type' / construct.Byte,
    'command' / construct.Padded(
        63,  # command can only be up to 62 bytes, but one is used for length.
        construct.GreedyBytes),
)

_TEXT_COMPLETION_RE = re.compile(b'CMD (?:OK|Fail!)')
_TEXT_REPLY_FORMAT = re.compile(
    b'^(?P<message>.*)CKSM:(?P<checksum>[0-9A-F]{8})\r\n'
    b'CMD (?P<status>OK|Fail!)\r\n$', re.DOTALL)
Example #2
0
import datetime
import logging

import construct
from pyscsi.pyscsi.scsi import SCSI
from pyscsi.pyscsi.scsi_device import SCSIDevice

from glucometerutils import common
from glucometerutils import exceptions
from glucometerutils.support import lifescan
from glucometerutils.support import lifescan_binary_protocol

# This device uses SCSI blocks as registers.
_REGISTER_SIZE = 512

_PACKET = construct.Padded(
    _REGISTER_SIZE, lifescan_binary_protocol.LifeScanPacket(0x03, False))

_QUERY_REQUEST = construct.Struct(
    construct.Const(b'\xe6\x02'),
    'selector' /
    construct.Enum(construct.Byte, serial=0x00, model=0x01, software=0x02),
)

_QUERY_RESPONSE = construct.Struct(
    lifescan_binary_protocol.COMMAND_SUCCESS,
    'value' / construct.CString(encoding='utf-16-le'),
)

_READ_PARAMETER_REQUEST = construct.Struct(
    'selector' / construct.Enum(construct.Byte, unit=0x04), )
Example #3
0
            0x43,
            0x41,
            0x72,
            0x64,
            0x01,
        ]
    )
)

TOKEN_CON = "token" / construct.Const(TOKEN)
RANDOM_TOKEN_CON = "random_token" / construct.Byte[4]

MSC_TRANSPORT_DISABLE_SUSPEND_PACKET = construct.Padded(
    BLOCK_SIZE,
    construct.Struct(
        HEADER_CON,
        TOKEN_CON,
        construct.Const(bytes([0x00, 0x02, 0x53, 0x44, 0x00, 0x00])),
    ),
)

MSC_TRANSPORT_ENABLE_SUSPEND_PACKET = construct.Padded(
    BLOCK_SIZE,
    construct.Struct(
        HEADER_CON,
        TOKEN_CON,
        construct.Const(bytes([0x00, 0x02, 0x53, 0x45, 0x00, 0x00])),
    ),
)

MSC_TRANSPORT_SUSPEND_RESPONSE_PACKET = construct.Padded(
    BLOCK_SIZE,