MAX_MSG_SIZE = 255

TMR_TAG_PROTOCOL_NONE              = 0x00
TMR_TAG_PROTOCOL_ISO180006B        = 0x03
TMR_TAG_PROTOCOL_GEN2              = 0x05
TMR_TAG_PROTOCOL_ISO180006B_UCODE  = 0x06
TMR_TAG_PROTOCOL_IPX64             = 0x07
TMR_TAG_PROTOCOL_IPX256            = 0x08
TMR_TAG_PROTOCOL_ATA               = 0x1D

TMR_SR_OPCODE_VERSION = 0x03
TMR_SR_OPCODE_SET_BAUD_RATE = 0x06
TMR_SR_OPCODE_READ_TAG_ID_SINGLE = 0x21
TMR_SR_OPCODE_READ_TAG_ID_MULTIPLE = 0x22
TMR_SR_OPCODE_WRITE_TAG_ID = 0x23
TMR_SR_OPCODE_WRITE_TAG_DATA = 0x24
TMR_SR_OPCODE_KILL_TAG = 0x26
TMR_SR_OPCODE_READ_TAG_DATA = 0x28
TMR_SR_OPCODE_CLEAR_TAG_ID_BUFFER = 0x2A
TMR_SR_OPCODE_MULTI_PROTOCOL_TAG_OP = 0x2F
TMR_SR_OPCODE_GET_READ_TX_POWER = 0x62
TMR_SR_OPCODE_GET_WRITE_TX_POWER = 0x64
TMR_SR_OPCODE_GET_POWER_MODE = 0x68
TMR_SR_OPCODE_GET_READER_OPTIONAL_PARAMS = 0x6A
TMR_SR_OPCODE_GET_PROTOCOL_PARAM = 0x6B
TMR_SR_OPCODE_SET_ANTENNA_PORT = 0x91
TMR_SR_OPCODE_SET_TAG_PROTOCOL = 0x93
TMR_SR_OPCODE_SET_READ_TX_POWER = 0x92
TMR_SR_OPCODE_SET_WRITE_TX_POWER = 0x94
TMR_SR_OPCODE_SET_REGION = 0x97
TMR_SR_OPCODE_SET_READER_OPTIONAL_PARAMS = 0x9A
TMR_SR_OPCODE_SET_PROTOCOL_PARAM = 0x9B

COMMAND_TIME_OUT = 2000 #Number of ms before stop waiting for response from module

#Define all the ways functions can return
ALL_GOOD = 0
ERROR_COMMAND_RESPONSE_TIMEOUT = 1
ERROR_CORRUPT_RESPONSE = 2
ERROR_WRONG_OPCODE_RESPONSE = 3
ERROR_UNKNOWN_OPCODE = 4
RESPONSE_IS_TEMPERATURE = 5
RESPONSE_IS_KEEPALIVE = 6
RESPONSE_IS_TEMPTHROTTLE = 7
RESPONSE_IS_TAGFOUND = 8
RESPONSE_IS_NOTAGFOUND = 9
RESPONSE_IS_UNKNOWN = 10
RESPONSE_SUCCESS = 11
RESPONSE_FAIL = 12

#Define the allowed regions - these set the internal freq of the module
REGION_INDIA = 0x04
REGION_JAPAN = 0x05
REGION_CHINA = 0x06
REGION_EUROPE = 0x08
REGION_KOREA = 0x09
REGION_AUSTRALIA = 0x0B
REGION_NEWZEALAND = 0x0C
REGION_NORTHAMERICA = 0x0D
REGION_OPEN = 0xFF

REGION_IN = 0x04
REGION_JP = 0x05
REGION_PRC = 0x06
REGION_EU3 = 0x08
REGION_KR2 = 0x09 
REGION_AU = 0x0B 
REGION_NZ = 0x0C 
REGION_NAS2 = 0x0D # NAS2 (North America)
REGION_OPEN = 0xFF 


crctable = [       
    0x0000,
    0x1021,
    0x2042,
    0x3063,
    0x4084,
    0x50a5,
    0x60c6,
    0x70e7,
    0x8108,
    0x9129,
    0xa14a,
    0xb16b,
    0xc18c,
    0xd1ad,
    0xe1ce,
    0xf1ef,
]

