Skip to content

Commit 19596fa

Browse files
committed
Add CRC calculation for IL2P
1 parent 486b3cf commit 19596fa

File tree

9 files changed

+218
-30
lines changed

9 files changed

+218
-30
lines changed

src/audio.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ struct audio_s {
208208
int il2p_max_fec; // 1 for max FEC length, 0 for automatic based on size.
209209

210210
int il2p_invert_polarity; // 1 means invert on transmit. Receive handles either automatically.
211+
enum il2p_use_crc_t { IL2P_NOCRC = 0, IL2P_USECRC } il2p_use_crc;
211212

212213
enum v26_e { V26_UNSPECIFIED=0, V26_A, V26_B } v26_alternative;
213214

src/config.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,7 @@ void config_init (char *fname, struct audio_s *p_audio_config,
791791
p_audio_config->achan[channel].layer2_xmit = LAYER2_AX25;
792792
p_audio_config->achan[channel].il2p_max_fec = 1;
793793
p_audio_config->achan[channel].il2p_invert_polarity = 0;
794+
p_audio_config->achan[channel].il2p_use_crc = IL2P_USECRC;
794795

795796
p_audio_config->achan[channel].fix_bits = DEFAULT_FIX_BITS;
796797
p_audio_config->achan[channel].sanity_test = SANITY_APRS;
@@ -2625,13 +2626,15 @@ void config_init (char *fname, struct audio_s *p_audio_config,
26252626
}
26262627

26272628
/*
2628-
* IL2PTX [ + - ] [ 0 1 ] - Enable IL2P transmission. Default off.
2629+
* IL2PTX [ + - ] [ 0 1 ] [ C ] - Enable IL2P transmission. Default off.
26292630
* "+" means normal polarity. Redundant since it is the default.
26302631
* (command line -I for first channel)
26312632
* "-" means inverted polarity. Do not use for 1200 bps.
26322633
* (command line -i for first channel)
26332634
* "0" means weak FEC. Not recommended.
26342635
* "1" means stronger FEC. "Max FEC." Default if not specified.
2636+
* "C" means check CRC. Default is not to check CRC.
2637+
* Note, that it'll always generate CRC for the frame.
26352638
*/
26362639

26372640
else if (strcasecmp(t, "IL2PTX") == 0) {
@@ -2644,6 +2647,7 @@ void config_init (char *fname, struct audio_s *p_audio_config,
26442647
p_audio_config->achan[channel].layer2_xmit = LAYER2_IL2P;
26452648
p_audio_config->achan[channel].il2p_max_fec = 1;
26462649
p_audio_config->achan[channel].il2p_invert_polarity = 0;
2650+
p_audio_config->achan[channel].il2p_use_crc = IL2P_NOCRC; // Default is no CRC.
26472651

26482652
while ((t = split(NULL,0)) != NULL) {
26492653
for (char *c = t; *c != '\0'; c++) {
@@ -2659,6 +2663,11 @@ void config_init (char *fname, struct audio_s *p_audio_config,
26592663
break;
26602664
case '1':
26612665
p_audio_config->achan[channel].il2p_max_fec = 1;
2666+
break;
2667+
case 'C':
2668+
case 'c':
2669+
p_audio_config->achan[channel].il2p_use_crc = IL2P_USECRC;
2670+
dw_printf ("Line %d: IL2P transmission will use CRC.\n", line);
26622671
break;
26632672
default:
26642673
text_color_set(DW_COLOR_ERROR);

src/hdlc_rec.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ void hdlc_rec_bit_new (int chan, int subchan, int slice, int raw, int is_scrambl
504504

505505
if (g_audio_p->achan[chan].modem_type != MODEM_AIS) {
506506
fx25_rec_bit (chan, subchan, slice, dbit);
507-
il2p_rec_bit (chan, subchan, slice, raw); // Note: skip NRZI.
507+
il2p_rec_bit (chan, subchan, slice, raw, g_audio_p->achan[chan].il2p_use_crc); // Note: skip NRZI.
508508
}
509509

510510
/*

src/il2p.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#define IL2P_MAX_PACKET_SIZE (IL2P_SYNC_WORD_SIZE + IL2P_HEADER_SIZE + IL2P_HEADER_PARITY + IL2P_MAX_ENCODED_PAYLOAD_SIZE)
2121

22+
#define IL2P_CODED_CRC_LENGTH 4
2223

2324
///////////////////////////////////////////////////////////////////////////////
2425
//
@@ -52,7 +53,7 @@ extern void il2p_set_debug(int debug);
5253

5354
// Receives a bit stream from demodulator.
5455

55-
extern void il2p_rec_bit (int chan, int subchan, int slice, int dbit);
56+
extern void il2p_rec_bit (int chan, int subchan, int slice, int dbit, int use_crc);
5657

5758

5859

@@ -81,9 +82,9 @@ int il2p_send_frame (int chan, packet_t pp, int max_fec, int polarity);
8182

8283
extern int il2p_encode_frame (packet_t pp, int max_fec, unsigned char *iout);
8384

84-
packet_t il2p_decode_frame (unsigned char *irec);
85+
packet_t il2p_decode_frame (unsigned char *irec, int use_crc);
8586

86-
packet_t il2p_decode_header_payload (unsigned char* uhdr, unsigned char *epayload, int *symbols_corrected);
87+
packet_t il2p_decode_header_payload (unsigned char* uhdr, unsigned char *epayload, int *symbols_corrected, int use_crc);
8788

8889

8990

@@ -138,7 +139,7 @@ extern int il2p_payload_compute (il2p_payload_properties_t *p, int payload_size,
138139

139140
extern int il2p_encode_payload (unsigned char *payload, int payload_size, int max_fec, unsigned char *enc);
140141

141-
extern int il2p_decode_payload (unsigned char *received, int payload_size, int max_fec, unsigned char *payload_out, int *symbols_corrected);
142+
extern int il2p_decode_payload (unsigned char *received, int payload_size, int max_fec, unsigned char *payload_out, int *symbols_corrected, unsigned char **next_hdr);
142143

143144
extern int il2p_get_header_attributes (unsigned char *hdr, int *hdr_type, int *max_fec);
144145

0 commit comments

Comments
 (0)