started separating protocol.

This commit is contained in:
Gerolf Ziegenhain 2015-01-04 15:02:03 +01:00
parent 272d03cbc8
commit 1140c99193
3 changed files with 40 additions and 34 deletions

0
src/cwprotocol.c Normal file
View File

39
src/cwprotocol.h Normal file
View File

@ -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;

View File

@ -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;