# Path: FabLabKasse/cashPayment/server/hex.py
# def hex(x):
#     if type(x) in [int, long]:
#         if x < 0:
#             return str(x)
#         else:
#             return '0x%02X' % (x)
#     elif type(x) == list:
#         return "[" + ", ".join([hex(val) for val in x]) + "]"
#     else:
#         return str(x)


import serial
import copy
import time
import traceback
import Crypto.Cipher.AES
import Crypto.Random.random
import logging
import unittest
from crc_algorithms import Crc
from ..hex import hex

        def readUnsigned32BigEndian(self):
            # big-endian version of previous function
            d = self.readUnsigned(numBytes=4, littleEndian=False)
            assert d <= 2 ** 31
            return d

        def readUnsigned24(self):
            # unsigned int24 little-endian
            return self.readUnsigned(numBytes=3, littleEndian=True)

        def readUnsigned24BigEndian(self):
            return self.readUnsigned(numBytes=3, littleEndian=False)

        def readAscii(self, n):
            d = self.readData(n)
            for byte in d:
                # only printable ASCII characters allowed
                assert byte >= 32
                assert byte <= 126
            # ASCII byte-array to string
            return "".join(map(chr, d))

        def assertFinished(self):  # assert that there is no data left - use this at the end of parsing fixed-length replies
            assert not self.hasData()

    #
    # Low-Level Send/Receive
    #
    def send(self, data):

# Path: FabLabKasse/cashPayment/server/hex.py
# def hex(x):
#     if type(x) in [int, long]:
#         if x < 0:
#             return str(x)
#         else:
#             return '0x%02X' % (x)
#     elif type(x) == list:
#         return "[" + ", ".join([hex(val) for val in x]) + "]"
#     else:
#         return str(x)


# Path: FabLabKasse/cashPayment/server/NV11/NV11Device.py
import serial
import copy
import time
import traceback
import Crypto.Cipher.AES
import Crypto.Random.random
import logging
import unittest
from crc_algorithms import Crc
from ..hex import hex


        def readUnsigned32BigEndian(self):
            # big-endian version of previous function
            d = self.readUnsigned(numBytes=4, littleEndian=False)
            assert d <= 2 ** 31
            return d

        def readUnsigned24(self):
            # unsigned int24 little-endian
            return self.readUnsigned(numBytes=3, littleEndian=True)

        def readUnsigned24BigEndian(self):
            return self.readUnsigned(numBytes=3, littleEndian=False)

        def readAscii(self, n):
            d = self.readData(n)
            for byte in d:
                # only printable ASCII characters allowed
                assert byte >= 32
                assert byte <= 126
            # ASCII byte-array to string
            return "".join(map(chr, d))

        def assertFinished(self):  # assert that there is no data left - use this at the end of parsing fixed-length replies
            assert not self.hasData()

    #
    # Low-Level Send/Receive
    #
    def send(self, data):

        self.debug2("encoding packet: " + hex(data))