mirror of
https://github.com/markqvist/OpenModem.git
synced 2025-05-03 15:05:12 -04:00
Updated documentation
This commit is contained in:
parent
85286ad467
commit
9637efd46f
3 changed files with 320 additions and 162 deletions
|
@ -15,15 +15,14 @@
|
|||
#define HDLC_RESET 0x7F
|
||||
#define AX25_ESC 0x1B
|
||||
|
||||
// Some further definitions FIXME:
|
||||
// We also define a few header flags and what
|
||||
// to send as padding if we need to pad a
|
||||
// packet. Due to forward error correction,
|
||||
// packets must have an even number of bytes.
|
||||
#define MP1_PADDING 0x55
|
||||
#define MP1_HEADER_PADDED 0x01
|
||||
#define MP1_HEADER_COMPRESSION 0x02
|
||||
|
||||
// FIXME: describe
|
||||
//static uint8_t compressedData[MP1_MAX_FRAME_LENGTH-0];
|
||||
static uint8_t compressionBuffer[MP1_MAX_FRAME_LENGTH+10];
|
||||
|
||||
// Just a forward declaration that this struct exists
|
||||
struct MP1Packet;
|
||||
|
||||
|
@ -33,22 +32,21 @@ typedef void (*mp1_callback_t)(struct MP1Packet *packet);
|
|||
|
||||
// Struct for a protocol context
|
||||
typedef struct MP1 {
|
||||
uint8_t buffer[MP1_MAX_FRAME_LENGTH]; // A buffer for incoming packets
|
||||
uint8_t fecBuffer[3]; // FEC buffer
|
||||
KFile *modem; // KFile access to the modem
|
||||
size_t packetLength; // Counter for received packet length
|
||||
size_t readLength; // This is the full read length, including parity bytes
|
||||
uint8_t calculatedParity; // Calculated parity for incoming data block
|
||||
mp1_callback_t callback; // The function to call when a packet has been received
|
||||
uint8_t checksum_in; // Rolling checksum for incoming packets
|
||||
uint8_t checksum_out; // Rolling checksum for outgoing packets
|
||||
bool reading; // True when we have seen a HDLC flag
|
||||
bool escape; // We need to know if we are in an escape sequence
|
||||
bool fecEscape; // fec escape
|
||||
long correctionsMade; // correction count
|
||||
uint8_t interleaveCounter; // interleave counter
|
||||
uint8_t interleaveOut[MP1_INTERLEAVE_SIZE];
|
||||
uint8_t interleaveIn[MP1_INTERLEAVE_SIZE];
|
||||
uint8_t buffer[MP1_MAX_FRAME_LENGTH]; // A buffer for incoming packets
|
||||
uint8_t fecBuffer[3]; // FEC buffer
|
||||
KFile *modem; // KFile access to the modem
|
||||
size_t packetLength; // Counter for received packet length
|
||||
size_t readLength; // This is the full read length, including parity bytes
|
||||
uint8_t calculatedParity; // Calculated parity for incoming data block
|
||||
mp1_callback_t callback; // The function to call when a packet has been received
|
||||
uint8_t checksum_in; // Rolling checksum for incoming packets
|
||||
uint8_t checksum_out; // Rolling checksum for outgoing packets
|
||||
bool reading; // True when we have seen a HDLC flag
|
||||
bool escape; // We need to know if we are in an escape sequence
|
||||
long correctionsMade; // A counter for how many corrections were made to a packet
|
||||
uint8_t interleaveCounter; // Keeps track of when we have received an entire interleaved block
|
||||
uint8_t interleaveOut[MP1_INTERLEAVE_SIZE]; // A buffer for interleaving bytes before they are sent
|
||||
uint8_t interleaveIn[MP1_INTERLEAVE_SIZE]; // A buffer for storing interleaved bytes before they are deinterleaved
|
||||
} MP1;
|
||||
|
||||
// A struct encapsulating a network packet
|
||||
|
@ -57,6 +55,7 @@ typedef struct MP1Packet {
|
|||
size_t dataLength; // The length of the received data
|
||||
} MP1Packet;
|
||||
|
||||
// Declarations of functions
|
||||
void mp1Init(MP1 *mp1, KFile *modem, mp1_callback_t callback);
|
||||
void mp1Read(MP1 *mp1, int byte);
|
||||
void mp1Poll(MP1 *mp1);
|
||||
|
@ -65,5 +64,7 @@ void mp1Send(MP1 *mp1, const void *_buffer, size_t length);
|
|||
int freeRam(void);
|
||||
size_t compress(uint8_t *input, size_t length);
|
||||
size_t decompress(uint8_t *input, size_t length);
|
||||
void mp1Deinterleave(MP1 *mp1);
|
||||
void mp1Interleave(MP1 *mp1, uint8_t byte);
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue