From ae779dc2f58d94aec02d8627ce711820e9b007a5 Mon Sep 17 00:00:00 2001 From: Gerolf Ziegenhain Date: Sun, 4 Jan 2015 15:32:43 +0100 Subject: [PATCH] magic numbers --- src/cwprotocol.h | 14 ++++++++------ src/irmc.c | 4 ++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/cwprotocol.h b/src/cwprotocol.h index 8f943bd..a7f4b0b 100644 --- a/src/cwprotocol.h +++ b/src/cwprotocol.h @@ -6,15 +6,19 @@ #define CON 0x0004 // connect #define ACK 0x0005 +#define SIZE_COMMAND_PACKET 4 +#define SIZE_DATA_PACKET 496 +#define SIZE_DATA_PACKET_PAYLOAD 492 // = SIZE_DATA_PACKET - SIZE_COMMAND_PACKET + +#define SIZE_ID 128 +#define SIZE_STATUS 128 +#define SIZE_CODE 51 // This structure will be used to (dis-)connect to KOB servers struct command_packet_format{ unsigned short command; // CON / DIS unsigned short channel; // Channel number }; -#define SIZE_COMMAND_PACKET 4 // This structure will be used for id, rx and tx packets -#define SIZE_ID 128 -#define SIZE_STATUS 128 struct data_packet_format{ unsigned short command; unsigned short length; @@ -24,14 +28,12 @@ struct data_packet_format{ unsigned int a21; unsigned int a22; unsigned int a23; - signed int code[51]; + signed int code[SIZE_CODE]; unsigned int n; char status[SIZE_STATUS]; /* This is called version in MorseKob */ char a4[8]; }; -#define SIZE_DATA_PACKET 496 -#define SIZE_DATA_PACKET_PAYLOAD 492 // = SIZE_DATA_PACKET - SIZE_COMMAND_PACKET // Define the packets used #define DEFAULT_CHANNEL 103 diff --git a/src/irmc.c b/src/irmc.c index f0ba75a..ab56356 100644 --- a/src/irmc.c +++ b/src/irmc.c @@ -163,7 +163,7 @@ txloop (void) if(tx_timeout > TX_TIMEOUT) return; } key_press_t1 = fastclock(); - if(tx_data_packet.n == 50) { + if(tx_data_packet.n == SIZE_CODE) { printf("irmc: warning packet is full.\n"); return; } @@ -348,7 +348,7 @@ int main(int argc, char *argv[]) printf("version: %s\n", rx_data_packet.status); printf("n: %i\n", rx_data_packet.n); printf("code:\n"); - for(i = 0; i < 51; i++)printf("%i ", rx_data_packet.code[i]); printf("\n"); + for(i = 0; i < SIZE_CODE; i++)printf("%i ", rx_data_packet.code[i]); printf("\n"); #endif if(rx_data_packet.n > 0 && rx_sequence != rx_data_packet.sequence){ message(2);