[op25-dev] My OP25 Development - need assistance from the group

Joseph Cardani jcardani@verizon.net [op25-dev] op25-dev at yahoogroups.com
Sat Nov 14 00:58:49 UTC 2015


Hi All,

I sent this email to Max last week but currently he does not have time right now to devote to helping so I am asking for your assistance.  

I started making changes to the modules that Max had suggested to me a few weeks ago and I am making some progress. However I am having some difficulty with a few things. 

My objectives summary:

1. Display the silence bytes from the voice frames VC1 and VC2 (currently all the voice frames are displayed). The silence frames must be from a subscriber unit and they are located in the first LDU1 just after the  HD.

2. Display the MI that’s located in the HD 

3. Display the Source (Radio ID) in the LDU1 and TDU w/LC (this is important to tell if the call was initiated from a console or subscriber unit)    


Objective #1

I made the code changes below (all my changes are prefixed by my initials JAC). First I displayed the raw hex bytes then formatted them adjacent. 

My issue is that I am getting 04 0C FD 7B FB 7D 79 36 CF 33 44 for silence instead of the correct 04 0C FD 7B FB 7D F2 7B 3D 9E 44
So it’s OK for the first 6 bytes then wrong for the next 4 then OK for the last. 
Please check my code and let me know what I am doing wrong here.   Thanks!



void
software_imbe_decoder::decode(const voice_codeword& cw)
{
	// process input 144-bit IMBE frame - converts to 88-bit frame
	unsigned int u0 = 0;
	unsigned int u1,u2,u3,u4,u5,u6,u7;
	unsigned int E0 = 0;
	unsigned int ET = 0;
	unsigned char O[12];
	unsigned int f0,f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15,f16,f17,f18,f19,f20,f21;  
	// PN/Hamming/Golay - etc.
	
	imbe_header_decode(cw, u0, u1, u2, u3, u4, u5, u6, u7, E0, ET) ;

	// JAC - display unformatted first (this needs work - results not expected)	
	printf("%03X %03X %03X %03X %03X %03X %03X %03x * ", u0, u1, u2, u3, u4, u5, u6, u7>>1);

	// JAC - Then display formatted (this needs work after above is fixed)	
	// A clear frame should be 04 0C FD 7B FB 7D F2 7B 3D 9E 44 or 45 alternating
	// I am getting            04 0C FD 7B FB 7D 79 36 CF 33 44 or 45 alternating 

	f0 = (u0 >> 8);				// first nibble   clear = 0
	printf("%X", f0);
	f1 = (u0 >> 4); f1 = (f1 & 0x0F);	// second nibbble clear = 4
	printf("%X", f1);
	
	
	f2 = (u0 & 0x00F);			// first nibble   clear = 0  
	printf(" %X", f2);
	f3 = (u1 >> 8);				// second nibble  clear = C
	printf("%X", f3);
	
	f4 = (u1 >> 4); f4 = (f4 & 0x0F);	// first nibbble  clear = F
	printf(" %X", f4);	
	f5 = (u1 & 0x00F);			// second nibble  clear = D	
	printf("%X", f5);
	
	f6 = (u2 >> 8);				// first nibble  clear = 7
	printf(" %X", f6);	
	f7 = (u2 >> 4); f7 = (f7 & 0x0F);	// second nibbble  clear = B
	printf("%X", f7);
	
	f8 = (u2 & 0x00F);			// first nibble  clear = F	
	printf(" %X", f8);	
	f9 = (u3 >> 8);				// second nibble  clear = B
	printf("%X", f9);
	
	f10 = (u3 >> 4); f10 = (f10 & 0x0F);	// first nibbble  clear = 7
	printf(" %X", f10);
	f11 = (u3 & 0x00F);			// second nibble  clear = D
	printf("%X", f11);
	
	f12 = (u4 >> 8);			// first nibble  clear = F
	printf(" %X", f12);
	f13 = (u4 >> 4); f13 = (f13 & 0x0F);	// second nibbble  clear = 2
	printf("%X", f13);
	
	f14 = (u4 & 0x00F);			// second nibble  clear = 7
	printf(" %X", f14);
	f15 = (u5 >> 8);			// second nibble  clear = B
	printf("%X", f15);	

	f16 = (u5 >> 4); f16 = (f16 & 0x0F);	// first nibbble  clear = 3
	printf(" %X", f16);
	f17 = (u5 & 0x00F);			// second nibble  clear = D
	printf("%X", f17);

	f18 = (u6 >> 8);			// first nibble  clear = 9
	printf(" %X", f18);	
	f19 = (u6 >> 4); f19 = (f19 & 0x0F);	// second nibbble  clear = E
	printf("%X", f19);
	

	u7 = (u7 >> 1);				// Done in original code 
	f20 = (u7 >> 4); f20 = (f20 & 0x00F);	// first nibble  clear = 4
	printf(" %X", f20);	
	f21 = (u7 & 0x00F);			// second nibble  clear = 4
	printf("%X \n", f21);	
	
	//replace the sync bit(LSB of u7) with the BOT flag
	u7 = u7 | 0x01; //ECC procedure called above always returns u7 LSB = 0
        
        O[0] = (((u0 / 16) & 240) + (u1 / 256));
	O[1] = (((u2 / 16) & 240) + (u3 / 256));
	O[2] = (((u4 / 8) & 224) + ((u5 / 64) & 28) + (u6 / 512));
	O[3] = (((u6 / 2) & 128) + u7);
	O[4] = (u0 & 255);
	O[5] = (u1 & 255);
	O[6] = (u2 & 255);
	O[7] = (u3 & 255);
	O[8] = (u4 & 255);
	O[9] = (u5 & 255);
	O[10] = (u6 & 255);
	O[11] = E0 + 4 * ET;
	
	decode_audio(O); // process 88-bit frame
}

Objective #2

I made the code changes below in ProcHDU (all my changes are prefixed by my initials JAC). I added the MI at the end of the fprintf statement below and added the for statement under that. This appears to be working since clear transmissions are always zero just like the MI that’s in the LDU2. However I can’t test encrypted MI since it’s variable. Can you please check my code again to see if it’s consistent with the code that is used to display the MI in the LDU2? Thanks!  



void ProcHDU(const_bit_vector A) {
int i, j, k, ec;
uint8_t HB[63];   // "hexbit" array

//header code word is 324 dibits (padded by 5 trailing zero dibits)
// 324 dibits = 648 bits = 36 18-bit Golay codewords

//do (18,6,8) shortened Golay decode - make 36 hexbits for rs dec
for (i = 0; i <= 26; i++) {
  HB[i] = 0;
}
k = 0;
for (i = 0; i < 36; i ++) { // 36 codewords
  uint32_t CW = 0;
  for (j = 0; j < 18; j++) {  // 18 bits / cw
    CW = (CW << 1) + A [ hdu_codeword_bits[k++] ];
  }
  HB[27 + i] = gly24128Dec(CW) & 63;
}

//do (36,20,17) RS decode
ec = rsDec(16, 27, HB);
//120 info bits = 20 hexbits:   (27..46)
  //72 bits MI: (27..38)
  // 8 bits MFID
  // 8 bits ALGID
  //16 bits KID
  //16 bits TGID

uint32_t MFID = HB[39] * 4 + (HB[40] >> 4);
uint32_t ALGID = (HB[40] & 15) * 16 + (HB[41] >> 2);
uint32_t KID = (HB[41] & 3) * 16384 + HB[42] * 256 + HB[43] * 4 + (HB[44] >> 4);
uint32_t TGID = (HB[44] & 15) * 4096 + HB[45] * 64 + HB[46];

fprintf (stderr, " HDU: rc %d mfid %X alg %X kid %X tgid %d MI ", ec, MFID, ALGID, KID, TGID); // Added JAC - added MI label at the end

// Added JAC - New code to display the MI that's in the header
for (int i = 27; i <= 38; i++) {
		fprintf(stderr, "%02X ", HB[ i ]);
}
}

void ProcLLDU(const_bit_vector A, uint8_t HB[]) {
int i, j, k;
for (i = 0; i <= 38; i++) {
  HB[i] = 0;
}
k = 0;
for (i = 0; i < 24; i ++) { // 24 10-bit codewords
  uint32_t CW = 0;
  for (j = 0; j < 10; j++) {  // 10 bits / cw
    CW = (CW << 1) + A [ imbe_ldu_ls_data_bits[k++] ];
  }
  HB[39 + i] = hmg1063Dec( CW >> 4, CW & 0xF );
}

}

void ProcLC(uint8_t HB[]) {
	int ec = rsDec(12, 39, HB);
	int pb = HB[39] >> 5;
	int sf = (HB[39] & 16) >> 4;
	int lco = (HB[39] & 15) * 4 + (HB[40] >> 4);
	//fprintf(stderr, " LC: rc %d pb %d sf %d lco %d", ec, pb, sf, lco);  // JAC - not displayed 
	
	
}


Objective #3

I made the code changes below in ProcLDU1 and ProcTDU (all my changes are prefixed by my initials JAC). Added the 3 lines to compute the source (Radio ID) - did this in both ProcLDU1 and ProcTDU. 
I took a guess here how to do this but obviously I failed. Maybe you can help me here correctly calculate the source. I may be getting it from the wrong position in the HB array or using the wrong calculation to add it up. Please help!  




void ProcLDU1(const_bit_vector A) {
	uint8_t HB[63];   // "hexbit" array

	ProcLLDU(A, HB);

	// Added JAC - This just displays the LDU1: label	
	fprintf(stderr, " LDU1: ");	
	
	// Added JAC FIX THIS!!! - Calculate the Source (Radio ID) in the LDU1  	
	uint32_t src = ((HB[51] * 262144) + (HB[52] * 4096) + (HB[53] * 64) + (HB[54]));
	
	//Added JAC - Display the Radio ID
	fprintf(stderr, " SRC %u", src);
	
ProcLC(HB);
	
}

void ProcLDU2(const_bit_vector A) {
	uint8_t HB[63];   // "hexbit" array

	ProcLLDU(A, HB);
	int ec = rsDec(8, 39, HB);

	uint32_t ALGID = HB[51] * 4 + (HB[52] >> 4);
	uint32_t KID = (HB[52] & 15) * 4096 + HB[53] * 64 + HB[54];

	fprintf(stderr, " LDU2: rc %d ALGID %X KID %X MI ", ec, ALGID, KID);
	for (int i = 39; i <= 50; i++) {
		fprintf(stderr, "%02X ", HB[ i ]);
	}
	// fprintf(stderr, "\n");
}

void ProcTDU(const_bit_vector A) {
uint8_t HB[63];   // "hexbit" array

int i, j, k;
for (i = 0; i <= 38; i++) {
  HB[i] = 0;
}
k = 0;
for (i = 0; i <= 22; i += 2) {
  uint32_t CW = 0;
  for (j = 0; j < 12; j++) {   // 12 24-bit codewords
    CW = (CW << 1) + A [ hdu_codeword_bits[k++] ];
    CW = (CW << 1) + A [ hdu_codeword_bits[k++] ];
  }
  uint32_t D = gly24128Dec(CW);
  HB[39 + i] = D >> 6;
  HB[40 + i] = D & 63;
}

// Added JAC - This just displays the TDU w/LC label	
fprintf(stderr, " TDU: ");

// Added JAC FIX THIS!!! - Calculate the Source (Radio ID) in the TDU	
uint32_t src = ((HB[51] * 262144) + (HB[52] * 4096) + (HB[53] * 64) + (HB[54]));
	
//Added JAC - Display the Radio ID
fprintf(stderr, " SRC %u", src);

ProcLC(HB);



}

Hopefully you guys can help fix these issued and then I can submit them to Max to include them in the master branch after they are tested.

thanks!

Joe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/op25-dev/attachments/20151113/4f1618d0/attachment.html>


More information about the op25-dev mailing list