<div dir="ltr"><span style="color:rgb(36,39,41);font-family:Arial,"Helvetica Neue",Helvetica,sans-serif;font-size:15px">I am interested in finding the generator matrix used for TCH3 channel encoding (GEO-Mobile Radio Interface). I followed the installation steps indicated in OsmocomGMR. There was an example for FACCH3 channel to generate the G matrix. I modified the code for TCH3 (shown below) but the output results does not seems correct. I would really appreciate it if you can tell me what I am doing wrong in the code below.</span> <div><br></div><div> <span style="font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit;white-space:inherit;background-color:rgb(239,240,241);color:rgb(36,39,41);font-size:13px">/* GMR-1 G/g matrix geneation forTCH3 */</span><br></div><pre style="margin-top:0px;margin-bottom:1em;padding:5px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;font-size:13px;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;background-color:rgb(239,240,241);color:rgb(36,39,41)"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;vertical-align:baseline;box-sizing:inherit;white-space:inherit">
/* (C) 2011 by Sylvain Munaut <tnt@246tNt.com>  * All Rights Reserved 
*  * This program is free software; you can redistribute it and/or modify  * it under the terms of the GNU Affero General Public License as published by  * the Free Software Foundation; either version 3 of the License, or  * (at your option) any later version.  *  * This program is distributed in the hope that it will be useful,  * but WITHOUT ANY WARRANTY; without even the implied warranty of  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  * GNU Affero General Public License for more details.  *  * You should have received a copy of the GNU Affero General Public License  * along with this program.  If not, see <<a href="http://www.gnu.org/licenses/">http://www.gnu.org/licenses/</a>>.  */

#include <errno.h>
#include <stdio.h>
#include <string.h>

#include <osmocom/core/bits.h>
#include <osmocom/core/utils.h>



#include <osmocom/gmr1/l1/tch3.h>



static void copy_bits(ubit_t *dst, int r, ubit_t *bits_e) {     int i, j
= 0;    for(i=0;i<212;i++){         if (i<52 || i > 55){            dst[(208*r)+j] = bits_e[i];             j++;        }   }

}



static int pbm_save_bits(const char *filename, ubit_t *m, int x, int y) {   FILE *fh;   int i, j;

    fh = fopen(filename, "w");  if (!fh)        return -EPERM;

    fprintf(fh, "P1\n%d %d\n", x, y);

    for (i=0; i<y; i++)         for (j=0; j<x; j++)             fprintf(fh, "%d%c", m[(i*x)+j], j==x-1 ? '\n' : ' ');

    fclose(fh);

    return 0; }

int main(int argc, char *argv[]) {

     ubit_t mat_G[208*160]; /* 208 lines of 160 pixels */   ubit_t mat_g[208];  /* 208 lines of 1 pixel */

    ubit_t bits_e[212];     ubit_t bits_u1[160];    ubit_t bits_s[4];   uint8_t l1[10];     uint8_t l2[10];

    int i;  int j;  int m = 0;



    memset(mat_G, 0x00, sizeof(mat_G));     memset(mat_g, 0x00, sizeof(mat_g));

    memset(bits_s, 0x00, sizeof(bits_s));   memset(l1, 0x00, sizeof(l1));   memset(l2, 0x00, sizeof(l2));

    gmr1_tch3_encode(bits_e, l1, l2, bits_s, NULL,m);   copy_bits(mat_g, 0, bits_e);

            for (i=0; i<160; i++) {             memset(l1, 0x00, sizeof(l1));           memset(l2, 0x00, sizeof(l2));           memset(bits_u1, 0, sizeof(bits_u1));            bits_u1[i] = 1;

            osmo_ubit2pbit_ext(l1, 0, bits_u1, 0, 80, 1);           osmo_ubit2pbit_ext(l2, 0, bits_u1, 80, 80, 1);
                        gmr1_tch3_encode(bits_e, l1, l2, bits_s, NULL,m);           copy_bits(mat_G, i, bits_e);


        }       for (i=0; i<160; i++) {         for (j=0; j<208; j++) {             mat_G[(i*208)+j] ^= mat_g[j];       }   }

    pbm_save_bits("mat_G.pbm", mat_G, 160, 208);    pbm_save_bits("mat_g.pbm", mat_g,  1, 208);     printf("\n"); }</code></pre></div>