p25craft.py python3 updates

master
Max 11 months ago
parent 8b77120005
commit 8a948a3bee
  1. 161
      op25/gr-op25_repeater/apps/tx/p25craft.py

@ -52,7 +52,7 @@ quiet = False
outfile = ""
flip = 0x000
quiet = True
outfile = open('p25.out', 'w')
outfile = open('p25.out', 'wb')
#####################
@ -99,7 +99,10 @@ def print_spec(data):
byte = 0
for j in range(4):
byte |= data[i+j] << (6 - j*2)
outfile.write(struct.pack('B1', (byte ^ flip & 0xff)))
s=chr(byte ^ flip & 0xff)
if sys.version[0] != '2' and type(s) is str:
s = s.encode('latin1')
outfile.write(s)
# Split an integer into list of bytes.
def split_bytes(data, len):
@ -194,26 +197,26 @@ def gf6mult(a, b):
# returns an integer
def rs_36_20_17_encode(data):
matrix = (
(1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,074,037,034,006,002,007,044,064,026,014,026,044,054,013,077,005),
(0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,004,017,050,024,011,005,030,057,033,003,002,002,015,016,025,026),
(0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,007,023,037,046,056,075,043,045,055,021,050,031,045,027,071,062),
(0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,026,005,007,063,063,027,063,040,006,004,040,045,047,030,075,007),
(0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,023,073,073,041,072,034,021,051,067,016,031,074,011,021,012,021),
(0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,024,051,025,023,022,041,074,066,074,065,070,036,067,045,064,001),
(0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,052,033,014,002,020,006,014,025,052,023,035,074,075,075,043,027),
(0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,055,062,056,025,073,060,015,030,013,017,020,002,070,055,014,047),
(0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,054,051,032,065,077,012,054,013,035,032,056,012,075,001,072,063),
(0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,074,041,030,041,043,022,051,006,064,033,003,047,027,012,055,047),
(0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,054,070,011,003,013,022,016,057,003,045,072,031,030,056,035,022),
(0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,051,007,072,030,065,054,006,021,036,063,050,061,064,052,001,060),
(0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,001,065,032,070,013,044,073,024,012,052,021,055,012,035,014,072),
(0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,011,070,005,010,065,024,015,077,022,024,024,074,007,044,007,046),
(0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,006,002,065,011,041,020,045,042,046,054,035,012,040,064,065,033),
(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,034,031,001,015,044,064,016,024,052,016,006,062,020,013,055,057),
(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,063,043,025,044,077,063,017,017,064,014,040,074,031,072,054,006),
(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,071,021,070,044,056,004,030,074,004,023,071,070,063,045,056,043),
(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,002,001,053,074,002,014,052,074,012,057,024,063,015,042,052,033),
(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,034,035,002,023,021,027,022,033,064,042,005,073,051,046,073,060))
(1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0o74,0o37,0o34,0o06,0o02,0o07,0o44,0o64,0o26,0o14,0o26,0o44,0o54,0o13,0o77,0o05),
(0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0o04,0o17,0o50,0o24,0o11,0o05,0o30,0o57,0o33,0o03,0o02,0o02,0o15,0o16,0o25,0o26),
(0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0o07,0o23,0o37,0o46,0o56,0o75,0o43,0o45,0o55,0o21,0o50,0o31,0o45,0o27,0o71,0o62),
(0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0o26,0o05,0o07,0o63,0o63,0o27,0o63,0o40,0o06,0o04,0o40,0o45,0o47,0o30,0o75,0o07),
(0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0o23,0o73,0o73,0o41,0o72,0o34,0o21,0o51,0o67,0o16,0o31,0o74,0o11,0o21,0o12,0o21),
(0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0o24,0o51,0o25,0o23,0o22,0o41,0o74,0o66,0o74,0o65,0o70,0o36,0o67,0o45,0o64,0o01),
(0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0o52,0o33,0o14,0o02,0o20,0o06,0o14,0o25,0o52,0o23,0o35,0o74,0o75,0o75,0o43,0o27),
(0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0o55,0o62,0o56,0o25,0o73,0o60,0o15,0o30,0o13,0o17,0o20,0o02,0o70,0o55,0o14,0o47),
(0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0o54,0o51,0o32,0o65,0o77,0o12,0o54,0o13,0o35,0o32,0o56,0o12,0o75,0o01,0o72,0o63),
(0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0o74,0o41,0o30,0o41,0o43,0o22,0o51,0o06,0o64,0o33,0o03,0o47,0o27,0o12,0o55,0o47),
(0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0o54,0o70,0o11,0o03,0o13,0o22,0o16,0o57,0o03,0o45,0o72,0o31,0o30,0o56,0o35,0o22),
(0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0o51,0o07,0o72,0o30,0o65,0o54,0o06,0o21,0o36,0o63,0o50,0o61,0o64,0o52,0o01,0o60),
(0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0o01,0o65,0o32,0o70,0o13,0o44,0o73,0o24,0o12,0o52,0o21,0o55,0o12,0o35,0o14,0o72),
(0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0o11,0o70,0o05,0o10,0o65,0o24,0o15,0o77,0o22,0o24,0o24,0o74,0o07,0o44,0o07,0o46),
(0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0o06,0o02,0o65,0o11,0o41,0o20,0o45,0o42,0o46,0o54,0o35,0o12,0o40,0o64,0o65,0o33),
(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0o34,0o31,0o01,0o15,0o44,0o64,0o16,0o24,0o52,0o16,0o06,0o62,0o20,0o13,0o55,0o57),
(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0o63,0o43,0o25,0o44,0o77,0o63,0o17,0o17,0o64,0o14,0o40,0o74,0o31,0o72,0o54,0o06),
(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0o71,0o21,0o70,0o44,0o56,0o04,0o30,0o74,0o04,0o23,0o71,0o70,0o63,0o45,0o56,0o43),
(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0o02,0o01,0o53,0o74,0o02,0o14,0o52,0o74,0o12,0o57,0o24,0o63,0o15,0o42,0o52,0o33),
(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0o34,0o35,0o02,0o23,0o21,0o27,0o22,0o33,0o64,0o42,0o05,0o73,0o51,0o46,0o73,0o60))
assert data < 2**120
codeword = [0,] * 36
for i in range(36):
@ -227,18 +230,18 @@ def rs_36_20_17_encode(data):
# returns an integer
def rs_24_12_13_encode(data):
matrix = (
(1,0,0,0,0,0,0,0,0,0,0,0,062,044,003,025,014,016,027,003,053,004,036,047),
(0,1,0,0,0,0,0,0,0,0,0,0,011,012,011,011,016,064,067,055,001,076,026,073),
(0,0,1,0,0,0,0,0,0,0,0,0,003,001,005,075,014,006,020,044,066,006,070,066),
(0,0,0,1,0,0,0,0,0,0,0,0,021,070,027,045,016,067,023,064,073,033,044,021),
(0,0,0,0,1,0,0,0,0,0,0,0,030,022,003,075,015,015,033,015,051,003,053,050),
(0,0,0,0,0,1,0,0,0,0,0,0,001,041,027,056,076,064,021,053,004,025,001,012),
(0,0,0,0,0,0,1,0,0,0,0,0,061,076,021,055,076,001,063,035,030,013,064,070),
(0,0,0,0,0,0,0,1,0,0,0,0,024,022,071,056,021,035,073,042,057,074,043,076),
(0,0,0,0,0,0,0,0,1,0,0,0,072,042,005,020,043,047,033,056,001,016,013,076),
(0,0,0,0,0,0,0,0,0,1,0,0,072,014,065,054,035,025,041,016,015,040,071,026),
(0,0,0,0,0,0,0,0,0,0,1,0,073,065,036,061,042,022,017,004,044,020,025,005),
(0,0,0,0,0,0,0,0,0,0,0,1,071,005,055,003,071,034,060,011,074,002,041,050))
(1,0,0,0,0,0,0,0,0,0,0,0,0o62,0o44,0o03,0o25,0o14,0o16,0o27,0o03,0o53,0o04,0o36,0o47),
(0,1,0,0,0,0,0,0,0,0,0,0,0o11,0o12,0o11,0o11,0o16,0o64,0o67,0o55,0o01,0o76,0o26,0o73),
(0,0,1,0,0,0,0,0,0,0,0,0,0o03,0o01,0o05,0o75,0o14,0o06,0o20,0o44,0o66,0o06,0o70,0o66),
(0,0,0,1,0,0,0,0,0,0,0,0,0o21,0o70,0o27,0o45,0o16,0o67,0o23,0o64,0o73,0o33,0o44,0o21),
(0,0,0,0,1,0,0,0,0,0,0,0,0o30,0o22,0o03,0o75,0o15,0o15,0o33,0o15,0o51,0o03,0o53,0o50),
(0,0,0,0,0,1,0,0,0,0,0,0,0o01,0o41,0o27,0o56,0o76,0o64,0o21,0o53,0o04,0o25,0o01,0o12),
(0,0,0,0,0,0,1,0,0,0,0,0,0o61,0o76,0o21,0o55,0o76,0o01,0o63,0o35,0o30,0o13,0o64,0o70),
(0,0,0,0,0,0,0,1,0,0,0,0,0o24,0o22,0o71,0o56,0o21,0o35,0o73,0o42,0o57,0o74,0o43,0o76),
(0,0,0,0,0,0,0,0,1,0,0,0,0o72,0o42,0o05,0o20,0o43,0o47,0o33,0o56,0o01,0o16,0o13,0o76),
(0,0,0,0,0,0,0,0,0,1,0,0,0o72,0o14,0o65,0o54,0o35,0o25,0o41,0o16,0o15,0o40,0o71,0o26),
(0,0,0,0,0,0,0,0,0,0,1,0,0o73,0o65,0o36,0o61,0o42,0o22,0o17,0o04,0o44,0o20,0o25,0o05),
(0,0,0,0,0,0,0,0,0,0,0,1,0o71,0o05,0o55,0o03,0o71,0o34,0o60,0o11,0o74,0o02,0o41,0o50))
assert data < 2**72
codeword = [0,] * 24
for i in range(24):
@ -252,22 +255,22 @@ def rs_24_12_13_encode(data):
# returns an integer
def rs_24_16_9_encode(data):
matrix = (
(1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,051,045,067,015,064,067,052,012),
(0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,057,025,063,073,071,022,040,015),
(0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,005,001,031,004,016,054,025,076),
(0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,073,007,047,014,041,077,047,011),
(0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,075,015,051,051,017,067,017,057),
(0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,020,032,014,042,075,042,070,054),
(0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,002,075,043,005,001,040,012,064),
(0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,024,074,015,072,024,026,074,061),
(0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,042,064,007,022,061,020,040,065),
(0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,032,032,055,041,057,066,021,077),
(0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,065,036,025,007,050,016,040,051),
(0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,064,006,054,032,076,046,014,036),
(0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,062,063,074,070,005,027,037,046),
(0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,055,043,034,071,057,076,050,064),
(0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,024,023,023,005,050,070,042,023),
(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,067,075,045,060,057,024,006,026))
(1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0o51,0o45,0o67,0o15,0o64,0o67,0o52,0o12),
(0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0o57,0o25,0o63,0o73,0o71,0o22,0o40,0o15),
(0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0o05,0o01,0o31,0o04,0o16,0o54,0o25,0o76),
(0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0o73,0o07,0o47,0o14,0o41,0o77,0o47,0o11),
(0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0o75,0o15,0o51,0o51,0o17,0o67,0o17,0o57),
(0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0o20,0o32,0o14,0o42,0o75,0o42,0o70,0o54),
(0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0o02,0o75,0o43,0o05,0o01,0o40,0o12,0o64),
(0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0o24,0o74,0o15,0o72,0o24,0o26,0o74,0o61),
(0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0o42,0o64,0o07,0o22,0o61,0o20,0o40,0o65),
(0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0o32,0o32,0o55,0o41,0o57,0o66,0o21,0o77),
(0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0o65,0o36,0o25,0o07,0o50,0o16,0o40,0o51),
(0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0o64,0o06,0o54,0o32,0o76,0o46,0o14,0o36),
(0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0o62,0o63,0o74,0o70,0o05,0o27,0o37,0o46),
(0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0o55,0o43,0o34,0o71,0o57,0o76,0o50,0o64),
(0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0o24,0o23,0o23,0o05,0o50,0o70,0o42,0o23),
(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0o67,0o75,0o45,0o60,0o57,0o24,0o06,0o26))
assert data < 2**96
codeword = [0,] * 24
for i in range(24):
@ -280,12 +283,12 @@ def rs_24_16_9_encode(data):
# argument is an integer
# returns an integer
def golay_24_12_8_encode(data):
matrix = (040006165, 020003073, 010007550, 04003664, 02001732,
01006631, 0403315, 0201547, 0106706, 045227, 024476, 014353)
matrix = (0o40006165, 0o20003073, 0o10007550, 0o4003664, 0o2001732,
0o1006631, 0o403315, 0o201547, 0o106706, 0o45227, 0o24476, 0o14353)
assert data < 2**12
codeword = 0
for i in range(12):
if data & (04000 >> i):
if data & (0o4000 >> i):
codeword ^= matrix[i]
return codeword
@ -461,7 +464,7 @@ def trellis_3_4_encode(input):
# returns an integer
def crc_ccitt(data):
assert data >= 0
assert data <= 0xffffffffffffffffffffL
assert data <= 0xffffffffffffffffffff
g = (1 << 12) | (1 << 5) | 1
crc = 0;
for i in range(79, -1, -1):
@ -495,7 +498,7 @@ def crc_9(serial, data):
assert serial >= 0
assert serial <= 0x7f
assert data >= 0
assert data <= 0xffffffffffffffffffffffffffffffffL
assert data <= 0xffffffffffffffffffffffffffffffff
data |= (serial << 128)
g = (1 << 6) | (1 << 4) | (1 << 3) | 1
crc = 0;
@ -623,7 +626,7 @@ def construct_lc(lco, mfid, svcopt, s, tgid, dst, src):
def construct_es(mi, algid, kid):
text_out("\tEncryption Sync Word:\n")
assert mi <= 0xffffffffffffffffffL
assert mi <= 0xffffffffffffffffff
assert algid <= 0xff
assert kid <= 0xffff
@ -646,7 +649,7 @@ def construct_tsbk(lb, p, opcode, mfid, arg):
assert p <= 0x1
assert opcode <= 0x3f
assert mfid <= 0xff
assert arg <= 0xffffffffffffffffL
assert arg <= 0xffffffffffffffff
tsbk = lb << 95
tsbk |= p << 94
@ -879,7 +882,7 @@ def construct_hdu(nac, ss, mi, mfid, algid, kid, tgid):
assert nac <= 0xfff
assert ss <= 0x3
assert mi <= 0xffffffffffffffffffL
assert mi <= 0xffffffffffffffffff
assert algid <= 0xff
assert kid <= 0xffff
assert tgid <= 0xffff
@ -918,7 +921,7 @@ def construct_ldu1(nac, ss, imbe, lsd, lco, mfid, svcopt, s, tgid, dst, src):
assert nac <= 0xfff
assert ss <= 0x3
assert imbe <= 0xffffffffffffffffffffffffffffffffffffL
assert imbe <= 0xffffffffffffffffffffffffffffffffffff
assert lsd <= 0xffffffff
assert lco <= 0xff
assert mfid <= 0xff
@ -975,9 +978,9 @@ def construct_ldu2(nac, ss, imbe, lsd, mi, algid, kid):
assert nac <= 0xfff
assert ss <= 0x3
assert imbe <= 0xffffffffffffffffffffffffffffffffffffL
assert imbe <= 0xffffffffffffffffffffffffffffffffffff
assert lsd <= 0xffffffff
assert mi <= 0xffffffffffffffffffL
assert mi <= 0xffffffffffffffffff
assert algid <= 0xff
assert kid <= 0xffff
@ -1087,11 +1090,11 @@ def construct_tsdu(nac, ss, blocks, mfid, opcode, arg):
assert blocks <= 0x3
assert mfid <= 0xff
assert opcode <= 0x3f
assert arg <= 0xffffffffffffffffL
assert arg <= 0xffffffffffffffff
duid = 0x7
numss = (56 + (blocks * 98) + 34) / 35
numss = (56 + (blocks * 98) + 34) // 35
ssyms = (ss,) * numss
text_out("\tDUID = %01x\n" % duid)
@ -1133,11 +1136,11 @@ def construct_tsdu3(nac, ss, blocks, mfid, opcodes, args):
for opcode in opcodes:
assert opcode <= 0x3f
for arg in args:
assert arg <= 0xffffffffffffffffL
assert arg <= 0xffffffffffffffff
duid = 0x7
numss = (56 + (blocks * 98) + 34) / 35
numss = (56 + (blocks * 98) + 34) // 35
ssyms = (ss,) * numss
text_out("\tDUID = %01x\n" % duid)
@ -1197,7 +1200,7 @@ def construct_cpdu(nac, ss, data, length, an, io, sapid,
data <<= (4 * 8)
data |= packet_crc
numss = (56 + ((blocks + 1) * 98) + 34) / 35
numss = (56 + ((blocks + 1) * 98) + 34) // 35
ssyms = (ss,) * numss
text_out("\tDUID = %01x\n" % duid)
@ -1222,7 +1225,7 @@ def construct_cpdu(nac, ss, data, length, an, io, sapid,
for i in range(blocks):
text_out("\tConfirmed Packet Data Unit Block:\n")
cpdu_block = (data >> (16 * 8 *
(blocks - i - 1))) & 0xffffffffffffffffffffffffffffffffL
(blocks - i - 1))) & 0xffffffffffffffffffffffffffffffff
# More sophisticated serial number generation required
# for retransmissions.
@ -1279,7 +1282,7 @@ def construct_rpdu(nac, ss, data, length, io, rclass, rtype,
else:
blocks = 0
numss = (56 + ((blocks + 1) * 98) + 34) / 35
numss = (56 + ((blocks + 1) * 98) + 34) // 35
ssyms = (ss,) * numss
text_out("\tDUID = %01x\n" % duid)
@ -1301,7 +1304,7 @@ def construct_rpdu(nac, ss, data, length, io, rclass, rtype,
for i in range(blocks):
text_out("\tResponse Packet Data Unit Block:\n")
rpdu_block = (data >> (12 * 8 *
(blocks - i - 1))) & 0xffffffffffffffffffffffffL
(blocks - i - 1))) & 0xffffffffffffffffffffffff
text_out("\t\tData = %024x\n" % rpdu_block)
# I'm assuming 1/2 rate trellis encoding based on the length
@ -1345,7 +1348,7 @@ def construct_updu(nac, ss, data, length, io, sapid, mfid, llid, dho):
data <<= (4 * 8)
data |= packet_crc
numss = (56 + ((blocks + 1) * 98) + 34) / 35
numss = (56 + ((blocks + 1) * 98) + 34) // 35
ssyms = (ss,) * numss
text_out("\tDUID = %01x\n" % duid)
@ -1365,7 +1368,7 @@ def construct_updu(nac, ss, data, length, io, sapid, mfid, llid, dho):
for i in range(blocks):
text_out("\tUnconfirmed Packet Data Unit Block:\n")
updu_block = (data >> (12 * 8 *
(blocks - i - 1))) & 0xffffffffffffffffffffffffL
(blocks - i - 1))) & 0xffffffffffffffffffffffff
text_out("\t\tData = %024x\n" % updu_block)
symbols.extend(data_interleave(trellis_1_2_encode(
split_dibits(updu_block, 48))))
@ -1408,7 +1411,7 @@ def construct_ambt(nac, ss, data, length, io, sapid, mfid, llid, opcode, dbtm):
data <<= (4 * 8)
data |= packet_crc
numss = (56 + ((blocks + 1) * 98) + 34) / 35
numss = (56 + ((blocks + 1) * 98) + 34) // 35
ssyms = (ss,) * numss
text_out("\tDUID = %01x\n" % duid)
@ -1428,7 +1431,7 @@ def construct_ambt(nac, ss, data, length, io, sapid, mfid, llid, opcode, dbtm):
for i in range(blocks):
text_out("\tMultiple Block Trunking Block:\n")
ambt_block = (data >> (12 * 8 *
(blocks - i - 1))) & 0xffffffffffffffffffffffffL
(blocks - i - 1))) & 0xffffffffffffffffffffffff
text_out("\t\tData = %024x\n" % ambt_block)
symbols.extend(data_interleave(trellis_1_2_encode(
split_dibits(ambt_block, 48))))
@ -1723,7 +1726,7 @@ def make_fakecc_tsdu(params):
mfid = 0
construct_tsdu3(nac, ss, blocks, mfid, opcodes, args)
ga = 666
ch = (params['vc_freq'] - 902012500) / 12500
ch = (params['vc_freq'] - params['iden_up_frequency']) // params['iden_up_spacing']
opcode, args = format_group_voice_channel_grant_update(ch, ga, ch, ga)
construct_tsdu (nac, ss, blocks, mfid, opcode, args)
@ -1849,7 +1852,7 @@ if __name__ == "__main__":
assert options.nac <= 0xfff
assert options.ss <= 0b11
assert options.mi <= 0xffffffffffffffffffL
assert options.mi <= 0xffffffffffffffffff
assert options.mfid <= 0xff
assert options.algid <= 0xff
assert options.kid <= 0xffff
@ -1858,10 +1861,10 @@ if __name__ == "__main__":
assert options.src <= 0xffffff
assert options.dst <= 0xffffff
assert options.lsd <= 0xffffffff
assert options.lsd1 <= 0xffff
assert options.lsd2 <= 0xffff
assert options.lsd1 is None or options.lsd1 <= 0xffff
assert options.lsd2 is None or options.lsd2 <= 0xffff
assert options.pri <= 0x7
assert options.svcopt <= 0xff
assert options.svcopt is None or options.svcopt <= 0xff
assert options.ntsbk >= 1
assert options.ntsbk <= 3
assert options.sapid <= 0x3f
@ -1872,7 +1875,7 @@ if __name__ == "__main__":
assert options.rtype <= 0x7
assert options.rstatus <= 0x7
assert options.ns <= 0x7
assert options.arg <= 0xffffffffffffffffL
assert options.arg <= 0xffffffffffffffff
if options.quiet:
quiet = True

Loading…
Cancel
Save