S.F.T. XMODEM Library  1.0
xmodem.c File Reference

main source file for S.F.T. XMODEM library More...

#include "xmodem.h"

Go to the source code of this file.

Data Structures

struct  _XMODEM_BUF_
 Structure defining an XMODEM CHECKSUM packet. More...
struct  _XMODEMC_BUF_
 Structure defining an XMODEM CRC packet. More...
struct  _XMODEM_
 Structure that identifies the XMODEM communication state. More...

Defines

#define PACKED   __attribute__((__packed__))
#define _SOH_   1 /* start of packet - note XMODEM-1K uses '2' */
#define _EOT_   4
#define _ENQ_   5
#define _ACK_   6
#define _NAK_   21 /* NAK character */
#define _CAN_   24 /* CAN character CTRL+X */
#define DEBUG_I1   /*normally does nothing*/
#define DEBUG_I2   /*normally does nothing*/
#define DEBUG_I3   /*normally does nothing*/

Typedefs

typedef struct _XMODEM_BUF_ XMODEM_BUF
 Structure defining an XMODEM CHECKSUM packet.
typedef struct _XMODEMC_BUF_ XMODEMC_BUF
 Structure defining an XMODEM CRC packet.
typedef struct _XMODEM_ XMODEM
 Structure that identifies the XMODEM communication state.

Functions

unsigned char CalcCheckSum (const char *lpBuf, short cbBuf)
 Calculate checksum for XMODEM packet.
static unsigned short my_htons (unsigned short sVal)
 Calculate checksum for XMODEM packet.
unsigned short CalcCRC (const char *lpBuf, short cbBuf)
 Calculate 16-bit CRC for XMODEM packet.
unsigned long MyMillis (void)
 Return internal 'milliseconds' value for timing purposes.
void GenerateSEQ (XMODEM_BUF *pBuf, unsigned char bSeq)
 Generate a sequence number pair, place into XMODEM_BUF.
void GenerateSEQC (XMODEMC_BUF *pBuf, unsigned char bSeq)
 Generate a sequence number pair, place into XMODEMC_BUF (the CRC version)
short GetXmodemBlock (SERIAL_TYPE ser, char *pBuf, short cbSize)
 Get an XMODEM block from the serial device.
int WriteXmodemChar (SERIAL_TYPE ser, unsigned char bVal)
 Write a single character to the serial device.
int WriteXmodemBlock (SERIAL_TYPE ser, const void *pBuf, int cbSize)
 Send an XMODEM block via the serial device.
void XModemFlushInput (SERIAL_TYPE ser)
 Read all input from the serial port until there is 1 second of 'silence'.
void XmodemTerminate (XMODEM *pX)
 Terminate the XMODEM connection.
short ValidateSEQ (XMODEM_BUF *pX, unsigned char bSeq)
 Validate the sequence number of a received XMODEM block.
short ValidateSEQC (XMODEMC_BUF *pX, unsigned char bSeq)
 Validate the sequence number of a received XMODEM block (CRC version)
int ReceiveXmodem (XMODEM *pX)
 Generic function to receive a file via XMODEM (CRC or Checksum)
int SendXmodem (XMODEM *pX)
 Generic function to send a file via XMODEM (CRC or Checksum)
int XReceiveSub (XMODEM *pX)
 Calling function for ReceiveXmodem.
int XSendSub (XMODEM *pX)
 Calling function for SendXmodem.
int XReceive (SERIAL_TYPE hSer, const char *szFilename, int nMode)
 Receive a file using XMODEM protocol.
int XSend (SERIAL_TYPE hSer, const char *szFilename)
 Send a file using XMODEM protocol.

Detailed Description

main source file for S.F.T. XMODEM library

S.F.T. XMODEM library

Definition in file xmodem.c.