From 1140c99193d9d73d98b47be646288c26010e82b9 Mon Sep 17 00:00:00 2001 From: Gerolf Ziegenhain Date: Sun, 4 Jan 2015 15:02:03 +0100 Subject: [PATCH] started separating protocol. --- src/cwprotocol.c | 0 src/cwprotocol.h | 39 +++++++++++++++++++++++++++++++++++++++ src/irmc.c | 35 +---------------------------------- 3 files changed, 40 insertions(+), 34 deletions(-) create mode 100644 src/cwprotocol.c create mode 100644 src/cwprotocol.h diff --git a/src/cwprotocol.c b/src/cwprotocol.c new file mode 100644 index 0000000..e69de29 diff --git a/src/cwprotocol.h b/src/cwprotocol.h new file mode 100644 index 0000000..33eaa52 --- /dev/null +++ b/src/cwprotocol.h @@ -0,0 +1,39 @@ +// Structures for the packets: unsigned short command +#define DIS 0x0002 // disconnect +#define DAT 0x0003 +#define CON 0x0004 // connect +#define ACK 0x0005 + +// 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 +struct data_packet_format{ + unsigned short command; + unsigned short length; + char id[128]; + char a1[4]; + unsigned int sequence; + unsigned int a21; + unsigned int a22; + unsigned int a23; + signed int code[51]; + unsigned int n; + char status[128]; /* This is called version in MorseKob */ + char a4[8]; + +}; +#define SIZE_DATA_PACKET 496 + +// Define the packets used +#define DEFAULT_CHANNEL 103 +struct command_packet_format connect_packet = {CON, DEFAULT_CHANNEL}; +struct command_packet_format disconnect_packet = {DIS, 0}; +struct data_packet_format id_packet; +struct data_packet_format rx_data_packet; +struct data_packet_format tx_data_packet; + + diff --git a/src/irmc.c b/src/irmc.c index 0e0f1dc..ca6428d 100644 --- a/src/irmc.c +++ b/src/irmc.c @@ -35,42 +35,9 @@ #define MAXDATASIZE 1024 // max number of bytes we can get at once -// Structures for the packets: unsigned short command -#define DIS 0x0002 // disconnect -#define DAT 0x0003 -#define CON 0x0004 // connect -#define ACK 0x0005 - -// 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 -struct data_packet_format{ - unsigned short command; - unsigned short length; - char id[128]; - char a1[4]; - unsigned int sequence; - unsigned int a21; - unsigned int a22; - unsigned int a23; - signed int code[51]; - unsigned int n; - char status[128]; /* This is called version in MorseKob */ - char a4[8]; - -}; -#define SIZE_DATA_PACKET 496 +#include "cwprotocol.h" -struct command_packet_format connect_packet; -struct command_packet_format disconnect_packet = {DIS, 0}; -struct data_packet_format id_packet; -struct data_packet_format rx_data_packet; -struct data_packet_format tx_data_packet; int serial_status = 0, fd_serial, fd_socket, numbytes; int tx_sequence = 0, rx_sequence;