-
Notifications
You must be signed in to change notification settings - Fork 58
/
ermes.cpp
864 lines (735 loc) · 18.6 KB
/
ermes.cpp
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
//
// ERMES.CPP
//
//
#ifndef STRICT
#define STRICT 1
#endif
#include <windows.h>
#include <commctrl.h>
#include <mmsystem.h>
#include <stdio.h>
#include <commdlg.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include "headers\pdw.h"
#include "headers\initapp.h"
#include "headers\gfx.h"
#include "headers\decode.h"
#include "headers\misc.h"
#include "headers\acars.h"
#include "headers\mobitex.h"
#include "headers\ermes.h"
#include "headers\helper_funcs.h"
#define min(a,b) (((a) < (b)) ? (a) : (b))
#define max(a,b) (((a) > (b)) ? (a) : (b))
#define APT 0x09C461C9l // address field terminating word.
#define MDEL 0x3777E7ABl // message delimiter.
#define SYNC32 0x2288282a // 32 bit sync (30bit sync word + 2 LSB preamble bits)
// display raw none interleaved or interleaved codewords?
//#define DEBUG_NONE_INTERLEAVED 1
//#define DEBUG_INTERLEAVED 1
//#define EM_DEBUG 1
//#define DB_MESSAGE_HEADER 1
//#define DB_LOG_RAWDATA 1
ERMES em;
// error detection / correction matrix
int gmat[18]={ 0xF08, 0x784, 0x3C2, 0x1E1, 0xD96, 0x6CB, 0xE03, 0xA67, 0x855,
0x94C, 0x4A6, 0x253, 0xC4F, 0xB41, 0x8C6, 0x463, 0xF57, 0xACD };
char numformat[17]={"0123456789/ U-.%"}; // contains numeric paging data format
char alpformat[33]={"@£$¥èéùìòÇ Øø Åå ÆæßÉ"}; // contains alphanumeric paging data format
// Default ERMES settings
ERMES::ERMES(void)
{
// timer runs as long as we receive data.
timer = 0;
// Paging category - default, 0=tone,1=numeric,2=Alpha,3=transparent data
pcat = 0;
// Additional information indicator.
// 0 = no additional information
// 1 = additional information has been sent.
aii = 0;
// Number of codewords per batch.
batch_len = 17;
// Endof message indicator.
done = 0;
// setup error correction code.
setupecc();
// Local address.
local_addr = 0;
// Bit position in message header.
header_pos = 0;
}
ERMES::~ERMES(void)
{
}
// Return codeword with "nbits" reversed. (starting from LSB).
// Bits not reversed are set to 0.
long int ERMES::reverse_cw(long int cw, int nbits)
{
long int rwr, rcw = 0L;
for (int i=0; i<nbits; i++)
{
if (cw & 0x01) rcw |= 1;
rwr = rcw;
rcw <<= 1;
cw >>= 1;
}
return(rwr);
}
/*
int ERMES::nOnes(int k)
{
for (int i=0, kt=0; i<=15; i++)
{
if ((k & 0x0001) != 0) kt++;
k = k >> 1;
}
return(kt);
}
*/
int ERMES::lOnes(long int k)
{
int kt;
for (int i=0, kt=0; i<32; i++)
{
if ((k & 0x0001l) != 0l) kt++;
k = k >> 1;
}
return(kt);
}
// this routine takes a raw codeword passed to it as parameter
// col; does error correction & detection; and returns the bit
// reversed data portion of the codeword as a long int.
// The first 18 bits are the actual data; the second MSB is set
// to indicate that the codeword contains uncorrectable errors.
long int ERMES::checkecc(long int col)
{
int i, ecc=0, nbb, tabe, bb, ts, ts2, synd=0;
long int acw = 0x00000l;
for (i=0; i<18; i++)
{
acw = acw << 1;
if ((col & 0x01l) == 1)
{
ecc ^= gmat[i];
acw = acw + 0x0001l;
}
col = col >> 1;
}
// build up syndrome...
int nb = 0;
for (i=18; i<30; i++)
{
if ((ecc & 0x800) != 0) ts = 1; else ts = 0;
if ((col & 0x01l) == 1) ts2 = 1; else ts2 = 0;
ecc = ecc << 1;
col = col >> 1;
synd = synd << 1;
if (ts != ts2)
{
nb++;
synd += 0x0001;
}
}
synd = synd & 0x3fff;
CountBiterrors(0);
// quick check - if no errors then we can return at once
if (synd == 0x0000)
{
return (acw);
}
// try to identify, correct errors
tabe = syndlup[synd];
nbb = (tabe >> 14) & 0x03;
if (nbb == 3) // uncorrectable errors are marked, kissed goodbye
{
acw += 0x40000000l;
return(acw);
}
CountBiterrors(nbb);
// at this point we have correctable errors somewhere in code word
nbb = (tabe >> 12) & 0x03; // get number of correctable errors in data
// check if nothing to correct (all errors in syndrome)
if (nbb == 0) return (acw);
// at this point - we have at least one error in data, so correct it
bb = tabe & 0x003f;
if (bb < 18)
{
acw = acw ^ (0x01l << bb);
}
else
{
// we should never ever reach this point unless there is a
// serious problem somewhere...
}
// we're finished if only one error in data needed to be corrected
if (nbb == 1) return (acw);
// Allright - so we have a second error in the data to correct
bb = (tabe >> 6) & 0x3f;
if (bb < 18)
{
acw = acw ^ (0x01l << bb);
}
else
{
// once again - should never reach this point
}
// two data errors corrected, no more processing to be done
return(acw);
}
// This routine displays the message information. Each message has a 36 bit header
// giving pager type (alpha / numeric / tone only), message type (message fragment number,
// address reassignment, etcetera), external operator identity, et cetera.
void ERMES::showme(long int l, int c)
{
extern unsigned long hourly_stat[NUM_STAT][2];
extern unsigned long hourly_char[NUM_STAT][2];
extern unsigned long daily_stat[NUM_STAT][2];
extern unsigned long daily_char[NUM_STAT][2];
static long int nb=43, sl=0, ii;
if (c == -1)
{
nb = 43; // initial holdoff 36 bits plus one 7 bit word
}
else
{
// #ifdef EM_DEBUG // debug - mark each codeword we use
// char temp[10];
// sprintf(temp, "<CW%i>", nb);
// display_color(&Pane2, COLOR_NUMERIC);
// display_show_strV2(&Pane2, temp);
// #endif
// run through each data bit in the codeword
for (int i=0; i<18; i++)
{
// update shift register sl
sl = sl << 1;
if ((l & 0x20000l) != 0l)
{
sl += 1;
}
l = l << 1;
// hex dump 36 bit header
if ((nb > 7) && (nb < 42))
{
ii = nb >> 2;
ii = ii << 2;
if (ii == nb)
{
sl = sl & 0x0f;
#ifdef DB_MESSAGE_HEADER
sprintf(db_buf,"%x", sl);
display_color(&Pane2, COLOR_BITERRORS);
display_show_strV2(&Pane2, db_buf);
#endif
local_addr |= sl;
sl = 0;
header_pos++;
// Get local address & paging category.
// Paging categories:
// 00 (0) - tone
// 01 (1) - numeric
// 10 (2) - alphanumeric
// 11 (3) - transparent data
if (header_pos == 8)
{
shown++;
aii = (local_addr >> 3) & 0x01;
// if additional info sent then variable information field
// has changed so switch to alpha message as default for now.
if (aii == 0) pcat = (local_addr & 0x03); // get paging category
else pcat = 2;
local_addr >>= 10; // get local address
sprintf(Current_MSG[MSG_CAPCODE],"%07d", (local_addr & 0x3FFFFF));
// Show numeric/tone only messages?
if ((pcat < 2) && (!Profile.shownumeric)) shown=0;
local_addr = 0; // reset
/* Show Capcode */
messageitems_colors[1] = COLOR_ADDRESS;
/* Show Time/Date */
Get_Date_Time();
strcpy(Current_MSG[MSG_TIME], szCurrentTime);
strcpy(Current_MSG[MSG_DATE], szCurrentDate);
messageitems_colors[2] = COLOR_TIMESTAMP;
messageitems_colors[3] = COLOR_TIMESTAMP;
sprintf(Current_MSG[MSG_MODE], "ERMES-%d", pcat);
messageitems_colors[4] = COLOR_MODETYPEBIT;
if (pcat < 2)
{
strcpy(Current_MSG[MSG_TYPE], pcat ? "NUMERIC" : " TONE ");
hourly_stat[STAT_ERMES][STAT_NUMERIC]++;
daily_stat[STAT_ERMES][STAT_NUMERIC]++;
}
else
{
strcpy(Current_MSG[MSG_TYPE], (pcat==2) ? " ALPHA " : "TRANSP ");
hourly_stat[STAT_ERMES][STAT_ALPHA]++;
daily_stat[STAT_ERMES][STAT_ALPHA]++;
}
messageitems_colors[5] = COLOR_MODETYPEBIT;
strcpy(Current_MSG[MSG_BITRATE], "6250"); // Add Bit Rate.
messageitems_colors[6] = COLOR_MODETYPEBIT;
if (pcat == 0) // tone only?
{
display_color(&Pane1, COLOR_NUMERIC);
display_show_str(&Pane1, "TONE ONLY");
done = 1; // stop message incase garbage follows
}
}
local_addr <<= 4;
}
}
#ifdef DB_MESSAGE_HEADER
if (nb == 8) display_show_strV2(&Pane2, " ");
#endif
nb--;
// Display message based on paging category.
if (nb == 0)
{
if (pcat == 1) // numeric data?
{
hourly_char[STAT_ERMES][STAT_NUMERIC]++;
daily_char[STAT_ERMES][STAT_NUMERIC]++;
nb = 4;
sl = sl & 0x0F;
display_color(&Pane1, COLOR_NUMERIC);
display_show_char(&Pane1, (char)numformat[sl]);
}
else // if here - alpha or transparent data.
{
hourly_char[STAT_ERMES][STAT_ALPHA]++;
daily_char[STAT_ERMES][STAT_ALPHA]++;
nb = 7;
sl = sl & 0x7f;
if (pcat == 2) // alpha?
{
display_color(&Pane1, err_cw ? COLOR_BITERRORS : COLOR_MESSAGE);
}
else // or transparent data.
{
display_color(&Pane1, COLOR_MISC);
}
if (sl > 31) display_show_char(&Pane1, (char)sl);
else display_show_char(&Pane1, (char)alpformat[sl]);
}
}
} // endof main for loop.
}
}
// this routine processes the raw stream of codewords, and it tries to
// pick out address & message information
void ERMES::docw(long int col, int blkc)
{
long int ecol;
short int cycle, frame, batch;
static short int nadd=0, mess=0, lwd=0, ncbc=0;
static int last_shown=0;
extern bool bEmpty_Frame; // Set if FLEX-Frame=EMTPY / ERMES-Batch=0
extern char szWindowText[6][1000]; // PH: Additional info in titlebar
// if blkc is zero we must have gone on to a new batch
if (blkc == 0)
{
#ifdef EM_DEBUG // debug - mark start/end of block
display_color(&Pane2, COLOR_NUMERIC);
display_show_strV2(&Pane2, "<B0>");
#endif
nadd = 0;
mess = 0;
done = 0;
lwd = 0;
ncbc = 0;
}
ecol = checkecc(col);
// code words 0 to 2 have misc information
if (blkc < 3)
{
// if (blkc == 0) // PH: unused????
// {
// if (ecol < 0x40000000l)
// {
// opco = (int) ((ecol >> 8) & 0x07l);
// coco = (int) ((ecol >> 11) & 0x7fl);
// }
// }
// else if (blkc == 1)
if (blkc == 1)
{
if (ecol > 0x3fffffffl)
{
cycle = 666;
frame = 666;
batch = 666;
batch_len = 17;
}
else
{
cycle = (int) ((ecol >> 7) & 0x3fl);
frame = (int) ((ecol >> 4) & 0x07l);
batch = (int) (ecol & 0x0fl);
if (Profile.show_cfs)
{
sprintf(szWindowText[3], "Cycle:%02i Frame:%i Batch:%c", cycle, frame, char('A'+batch));
}
display_showmo(MODE_ERMES);
if (batch == 0x0F)
{
batch_len = 21; // set correct batch length!
bEmpty_Frame=true;
}
else
{
batch_len = 17;
bEmpty_Frame=false;
}
}
}
}
else // address and message fields code words come here
{
if (mess)
{
if (ecol > 0x3fffffffl)
{
ncbc++; // keep count of consequitive bad codewords
err_cw = 1; // indicate current codeword has errors.
}
else
{
err_cw = 0;
ncbc = 0;
}
//******* not sure this is required? J.P
// if this exceeds 7 assume we've lost sync
if (ncbc > 7)
{
if(shown)
{
ShowMessage(); // Display Message.
shown=0;
}
done = 1;
}
//******************/
if (!done && (blkc > 7)) // process message fields
{
if (lOnes(col ^ MDEL) < 3)
{
#ifdef EM_DEBUG // debug - mark start/end of message
display_color(&Pane2, COLOR_NUMERIC);
display_show_strV2(&Pane2, "<MD>");
#endif
// found message delimeter
if (lwd)
{
done = 1;
}
else if (shown && (shown != last_shown)) // PH : Fix ???
{
shown=0;
header_pos=0;
last_shown=shown;
ShowMessage(); // Display Message.
}
lwd = 1;
showme(ecol,-1);
}
else
{
lwd = 0;
showme(ecol,0);
}
if (shown && done)
{
ShowMessage(); // Display Message.
shown=0;
}
}
} // endof "if mess == 1"
else
{
if (lOnes(col ^ APT) < 4)
{
#ifdef EM_DEBUG // debug - mark start/end of message
display_color(&Pane2, COLOR_NUMERIC);
display_show_strV2(&Pane2, "<APT>");
#endif
// we found address field delimeter
mess = 1;
// This code was removed as it stopped many messages from being shown.
// check for no addresses
if (!nadd || blkc == 3)
{
done = 1;
}
if (nadd == 0)
{
done = 1;
}
ncbc = 0;
}
else
{
// we're in address field; we haven't found apt yet
if (ecol > 0x3fffffffl)
{
ncbc++;
}
else // show first inititial address.
{
// shown=0; // don't show initial addr anymore-just reset
header_pos=0;
ncbc = 0;
if (ecol != 0x00l) nadd++;
}
}
// if two consequitive bad address blocks... give up on this frame
if (ncbc >= 2)
{
mess = 0;
}
}
}
}
// this routine processes the raw bit stream. Its output is a
// steady stream of error corrected code words that are sent on for
// further processing to routine docw. It is synchronized by passing
// -1 to the routine upon sync detection.
//
// Processing: first 240 bits (8 codewords) are not interleaved...
// Afterwards codewords are interleaved in blocks of 9
// J.P. Now know that this is not correct as the initial
// address field can upto 140 codewords in length.
// (will fix later)
void ERMES::rawbit(int bit)
{
static short int rbc=0, blkc=0, iblk=0, ifin=0;
static long int col=0;
if (bit == -1) // reset routine
{
ifin = 0;
rbc = 0;
iblk = 0;
blkc = 0;
#ifdef EM_DEBUG
display_line(&Pane2); // Ensure last line is displayed.
#endif
}
else
{
if (blkc >= 8)
{
// collect, process interleaved code words
if (rbc < batch_len) // last batch is 190 codewords -
{ // all other batches are 154 codewords.
fin[ifin++] = bit;
if (ifin >= 270) // process 9-codeword blocks
{
for (int ii=0; ii<9; ii++)
{
for (int ij=0, il=0; ij<30; ij++)
{
il = (ij*9) + ii;
col = col >> 1;
if (fin[il] == 1) col += 0x20000000l;
}
#ifdef DEBUG_INTERLEAVED
// display interleaved codewords in hex format.
sprintf(db_buf,"%x ", reverse_cw(col, 30));
misc_debug_msg(db_buf);
if (db_index++ == 7)
{
display_line(&Pane2);
db_index = 0;
}
#endif
docw(col,blkc);
blkc++;
}
ifin = 0;
rbc++;
}
}
} // endof "if (blkc >= 8)"
else
{
// process first eight non-interleaved code words
col = col >> 1;
if (bit == 1) col += 0x20000000l;
iblk++;
if (iblk >= 30)
{
// process the completed code word
docw(col,blkc);
iblk = 0;
blkc++;
#ifdef DEBUG_NONE_INTERLEAVED
// display none interleaved codewords in hex format.
display_color(&Pane2, COLOR_EM_CAPCODE);
sprintf(db_buf,"%x ", reverse_cw(col, 30));
display_show_strV2(&Pane2, db_buf);
if (blkc == 8) display_line(&Pane2);
#endif
}
}
}
}
// Set up syndrome lookup table for error detection/correction
//
// each entry in syndlup[] is structured as follows:
// bits 15,14 give number of errors (3 = uncorrectable)
// bits 13,12 give number of data bits to correct
// bits 6-11 gives location of second error in data
// bits 0-5 gives location of first error in data
// if there are less than 2 bad bits in the data then 31
// is placed in bits 6-11 (and 0-5 if needed)
//
// Note: bit numbers are reversed because the codeword is bit
// reversed in the checkecc routine (don't ask).
void ERMES::setupecc(void)
{
short int i,j,k,l;
// first mark every possible syndrome as an uncorrectable error
for (i=0; i<4096; i++) syndlup[i] = (short int)0xCFFF;
// now mark first syndrome (0x000) as having no errors
syndlup[0] = 0x0fff;
// mark single bit errors in data
for (i=0; i<18; i++)
{
k = 0x5FC0 + (17-i); // indicates 1 error in data at bit i
l = gmat[i];
syndlup[l] = k;
}
// mark single bit errors in syndrome
for (i=0; i<12; i++)
{
k = 0x4FFF; // indicates 1 error, none in data
l = (0x01 << i);
syndlup[l] = k;
}
// mark double bit errors in data
for (i=0; i<18; i++)
{
for (j=0; j<18; j++)
{
if (i != j)
{
// two errors total; two correctable in data
k = 0xA000 + (17-i) + ((17-j) << 6);
l = gmat[i] ^ gmat[j];
syndlup[l] = k;
}
}
}
// mark double errors in syndrome
for (i=0; i<12; i++)
{
for (j=0; j<12; j++)
{
if (i != j)
{
k = (short int)0x8FFF; // two errors total; none in data
l = (0x01 << i) ^ (0x01 << j);
syndlup[l] = k;
}
}
}
// Finally: mark one error in syndrome; one error in data
for (i=0; i<18; i++)
{
for (j=0; j<12; j++)
{
k = 0x9FC0 + (17-i); // two errors total; one in data
l = gmat[i] ^ (0x01 << j);
syndlup[l] = k;
}
}
}
// frame_ermes looks for 15 bit ermes sync; then sends the raw bit
// stream to routine rawbit for further processing.
void ERMES::frame(int gin)
{
static short int ts=0, st=0, inverted=0;
static int sync=0;
short int nh;
/*
// sync sequence is 15 bits long
ts = ts << 1;
if ((gin & 0x02) != 0) ts += 1;
ts = ts & 0x7fff;
*/
sync = sync << 1;
if (gin > 1) sync++;
sync = sync << 1;
if ((gin == 1) || (gin == 2)) sync++;
sync = sync & 0xFFFFFFFF;
if (gin == -1) // Reset - used when changing mode!
{
st = 0;
return;
}
if (st == 0)
{
// find number of mismatched bits
// nh = nOnes(ts ^ SYNC);
nh = lOnes(sync ^ SYNC32);
// PH: We allow max 1 error on syncup
if (nh < 2)
{
if (timer < 10) timer = 20; // Display title bar msg for 3.0 seconds
// reset raw bit processing routine that
rawbit(-1);
// found sync, so now we'll try to process a raw batch
// each batch is 3/4 of a second long or a little over 2300 symbols long
st = 2300;
inverted = 0;
display_color(&Pane2, COLOR_NUMERIC);
display_show_strV2(&Pane2, "<SYNC>");
}
else if (nh == 15)
{
// if we find inverted sync 5 times in a row then flip receive polarity
if (inverted++ > 4)
{
inverted = 0;
InvertData(); // Invert receive polarity
}
}
}
else
{
// dump raw receive data - gin holds number of lines that are high;
// this can be converted into two data bits (using a gray code).
// gin == 0 => 00
// gin == 1 => 01
// gin == 2 => 11
// gin == 3 => 10
if (gin > 1) gin = gin ^ 0x01;
// gin == 0 => 00
// gin == 1 => 01
// gin == 2 => 10
// gin == 3 => 11
rawbit((gin & 0x02) ? 1 : 0);
rawbit((gin & 0x01) ? 1 : 0);
// if (gin > 1) rawbit(1);
// else rawbit(0);
//
// if ((gin == 1) || (gin == 2)) rawbit(1);
// else rawbit(0);
st--;
}
}
/*
the Preamble word (PRE):
00 10 00 10 00 10 00 10 00 10 00 10 00 10 00
the Synchronisation Word (SW):
10 00 10 10 00 10 00 00 10 10 00 00 10 10 10
100010100010000010100000101010
the Address Partition Terminator (APT):
10 01 00 11 10 00 01 10 00 10 00 11 10 01 00
and the Message Delimiter (MD):
11 01 01 01 11 10 01 11 11 10 11 10 11 10 11
010101010101010
101101001100111
*/