-
Notifications
You must be signed in to change notification settings - Fork 0
/
tk2402_constants.py
56 lines (47 loc) · 3.06 KB
/
tk2402_constants.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import numpy as np
# Initialization constants
PROGRAM = np.array([0x50, 0x52, 0x4f, 0x47, 0x52, 0x41, 0x4d], dtype='uint8') # Hex message character "PROGRAM"
P2402 = np.array([0x50, 0x32, 0x34, 0x30, 0x32, 0x0D, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF], dtype='uint8')
# Encryption constants
CRYPT1 = np.uint8(0x00) # first layer XOR encryption byte (sent to radio)
CRYPT2 = np.uint8(0xbb) # second layer XOR encryption (predetermined fixed)
# Command constants
LISTENING = np.uint8(0x16) # initial response from TK unit
VERSION = np.uint8(0x02) # Version request
R = np.uint8(0x52) # Read from transciever
W = np.uint8(0x57) # Write from transciever
Y = np.uint8(0x59) # Set value in transciever
P = np.uint8(0x50) # byte 'P' to request software version
END = np.uint8(0x45) # End byte 'E'
CONF = np.uint8(0x06) # confirmation
# channel structure constants
# chanEnum = np.array([0xff, 0xff], dtype='uint8') # Channel enumeration bytes for channel numbers #1-8, and #9-16
CHAN_EMPTY = np.array([0xff] * 0x20, dtype='uint8') # empty channel used to delete channel
CHAN_INIT = np.array(
[0xff, # channel number
0xff, # ?
0xff, 0xff, 0xff, 0xff, # Rx reverse order each nibble is a digit
0xff, 0xff, 0xff, 0xff, # Tx reverse order each nibble is a digit
0xff, # RX channel frequency step flag
0xff, # TX channel frequency step flag
0xff, 0xff, # QT Rx byte 1, byte 2 (lookup tables QT_b1, QT_b2)
0xff, 0xff, # QT Tx byte 1, byte 2 (lookup tables QT_b1, QT_b2)
0x18, # Optional Signalling 0x18 = None
0xec, # Power/Scan (HIGH nibble): 0xC(Low/Yes), 0xD (Low/No), 0xE (High/Yes), 0xF (High/No) / Channel Width (LOW nibble): 0xC(Narrow)/0xD(Wide)
0xe6, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0xff, 0xff], # ?? optional settings
dtype='uint8'
)
############################################################
# QT frequency code constants, 1st byte, 2nd byte
QT_MASK = np.array([0.0, 067.0, 069.3, 071.9, 074.4, 077.0, 079.7, 082.5, 085.4, 088.5, 091.5, 094.8, 097.4, 100.0, 103.5, 107.2,
110.9, 114.8, 118.8, 123.0, 127.3, 131.8, 136.5, 141.3, 146.2, 151.4, 156.7, 162.2,
167.9, 173.8, 179.9, 186.2, 192.8, 203.5, 210.7, 218.1, 225.7, 233.6, 241.8, 250.3])
QT_B1 = np.array([0xff, 0x9e, 0xb5, 0xcf, 0xe8, 0x02, 0x1d, 0x39, 0x56, 0x75, 0x93, 0xb4, 0xce, 0xe8, 0x0b, 0x30,
0x55, 0x7c, 0xa4, 0xce, 0xf9, 0x25, 0x55, 0x85, 0xb6, 0xea, 0x1f, 0x56, 0x8f, 0xca, 0x07,
0x46, 0x88, 0xf3, 0x3b, 0x85, 0xd1, 0x20, 0x72, 0xc7], dtype='uint8')
QT_B2 = np.array([0xff, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04,
0x04, 0x04, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, 0x07,
0x07, 0x07, 0x07, 0x08, 0x08, 0x08, 0x09, 0x09, 0x09], dtype='uint8')
#############################################################
# frequency step flag divisors
FREQ_STEPS = np.array([(2, 1250), (1, 500), (0, 750), (3, 250)]) # 0x02, 0x01, 0x00, 0x03