Ymodem ESP32 1.0.0
|
Ymodem utility functions. More...
#include "YmodemUtils.h"
Go to the source code of this file.
Functions | |
void IRAM_ATTR | LED_toggle () |
Toggles the state of an LED. | |
unsigned short | crc16 (const unsigned char *buf, unsigned long count) |
Computes the CRC-16 checksum for a given buffer. | |
int32_t | Receive_Byte (unsigned char *c, uint32_t timeout) |
Receives a byte from a communication interface. | |
void | uart_consume () |
Consumes data from the UART buffer. | |
uint32_t | Send_Byte (char c) |
Sends a single byte of data. | |
void | send_CA () |
Sends the CA (Cancel) signal. | |
void | send_ACK () |
Sends an acknowledgment (ACK) signal. | |
void | send_ACKCRC16 () |
Sends an acknowledgment with CRC16. | |
void | send_NAK () |
Sends a Negative Acknowledgement (NAK) signal. | |
void | send_CRC16 () |
Sends the CRC16 checksum. | |
int32_t | Receive_Packet (uint8_t *data, int *length, uint32_t timeout) |
Receives a packet of data. | |
Ymodem utility functions.
This file contains utility functions used in the Ymodem protocol implementation. These functions provide low-level functionality for sending and receiving data over a serial connection using the Ymodem protocol.
Definition in file YmodemUtils.cpp.
unsigned short crc16 | ( | const unsigned char * | buf, |
unsigned long | count ) |
Computes the CRC-16 checksum for a given buffer.
This function calculates the CRC-16 checksum for the provided buffer using a standard polynomial. The CRC-16 checksum is commonly used for error-checking in data transmission and storage.
buf | Pointer to the buffer containing the data to be checksummed. |
count | The number of bytes in the buffer. |
Definition at line 29 of file YmodemUtils.cpp.
void IRAM_ATTR LED_toggle | ( | ) |
Toggles the state of an LED.
This function is marked with the IRAM_ATTR attribute, indicating that it should be placed in the IRAM (Instruction RAM) for faster execution. This is typically used for functions that need to be executed quickly, such as interrupt service routines.
Note: Ensure that the LED is properly initialized before calling this function.
Definition at line 17 of file YmodemUtils.cpp.
int32_t Receive_Byte | ( | unsigned char * | c, |
uint32_t | timeout ) |
Receives a byte from a communication interface.
This function attempts to receive a single byte from a communication interface within a specified timeout period.
[out] | c | Pointer to an unsigned char where the received byte will be stored. |
[in] | timeout | The maximum time to wait for a byte to be received, in milliseconds. |
Definition at line 47 of file YmodemUtils.cpp.
int32_t Receive_Packet | ( | uint8_t * | data, |
int * | length, | ||
uint32_t | timeout ) |
Receives a packet of data.
This function attempts to receive a packet of data within a specified timeout period.
data | Pointer to the buffer where the received data will be stored. |
length | Pointer to an integer where the length of the received data will be stored. |
timeout | The maximum time to wait for a packet, in milliseconds. |
Definition at line 101 of file YmodemUtils.cpp.
void send_ACK | ( | ) |
Sends an acknowledgment (ACK) signal.
This function is used to send an ACK signal to indicate successful receipt of data or successful completion of a process.
Definition at line 80 of file YmodemUtils.cpp.
void send_ACKCRC16 | ( | ) |
Sends an acknowledgment with CRC16.
This function sends an acknowledgment (ACK) signal with a CRC16 checksum. It is typically used in communication protocols to confirm the successful receipt of data.
Definition at line 85 of file YmodemUtils.cpp.
uint32_t Send_Byte | ( | char | c | ) |
Sends a single byte of data.
This function transmits a single character (byte) over a communication interface.
c | The character to be sent. |
Definition at line 65 of file YmodemUtils.cpp.
void send_CA | ( | ) |
Sends the CA (Cancel) signal.
This function is used to send the CA (Cancel) signal, which is typically used to abort an ongoing operation or communication.
Definition at line 74 of file YmodemUtils.cpp.
void send_CRC16 | ( | ) |
Sends the CRC16 checksum.
This function calculates and sends the CRC16 checksum for data integrity verification. It is typically used in communication protocols to ensure that the transmitted data has not been corrupted.
Definition at line 96 of file YmodemUtils.cpp.
void send_NAK | ( | ) |
Sends a Negative Acknowledgement (NAK) signal.
This function is used to send a NAK signal, typically in communication protocols, to indicate that the received data is not valid or an error has occurred.
Definition at line 91 of file YmodemUtils.cpp.
void uart_consume | ( | ) |
Consumes data from the UART buffer.
This function reads and discards data from the UART buffer. It is typically used to clear the buffer of any unwanted or residual data before starting a new communication session or operation.
Definition at line 58 of file YmodemUtils.cpp.