![]() |
BSB Developer Docs
|
Minimal send-only Kermit file-transfer sender. More...
#include <stdbool.h>#include <stdint.h>#include <stddef.h>Go to the source code of this file.
Data Structures | |
| struct | KermitIo |
| I/O interface used by the Kermit sender to read the source file and transmit data over the communication channel. More... | |
Typedefs | |
| typedef struct Kermit | Kermit |
| Opaque Kermit session handle. | |
Functions | |
| Kermit * | kermit_alloc (const KermitIo *io, void *context) |
| Allocate a new Kermit session in the idle state. | |
| void | kermit_free (Kermit *kermit) |
| Free a Kermit session and release any pending receive buffer. | |
| bool | kermit_start (Kermit *kermit, const uint8_t timeout_seconds) |
| Start a file transfer by transmitting the Send-Init (S) packet. | |
| bool | kermit_is_active (Kermit *kermit) |
| Check whether the transfer has completed. | |
| bool | kermit_feed_serial_data (Kermit *kermit, const uint8_t *data, size_t length) |
| Feed received serial data into the session state machine. | |
| void | kermit_reset_state (Kermit *kermit) |
| Reset the session back to the idle state. | |
Minimal send-only Kermit file-transfer sender.
Implements the sender side of the Kermit protocol used to push firmware images to a device bootloader over a byte-oriented link (UART). File data is transmitted and the receiver's ACK/NAK packets are consumed; no file data is ever received. The protocol logic is fully decoupled from hardware through the KermitIo interface.
Kermit protocol reference: https://www.kermitproject.org/kpackets.html
Allocate a new Kermit session in the idle state.
| [in] | io | I/O interface used by the sender. Must not be NULL. |
| [in] | context | User-provided context passed back to every I/O callback. |
| bool kermit_feed_serial_data | ( | Kermit * | kermit, |
| const uint8_t * | data, | ||
| size_t | length ) |
Feed received serial data into the session state machine.
Typically carries the receiver's ACK/NAK packets. Non-Kermit bytes are skipped until a packet mark is seen, so interleaved bootloader text is tolerated.
| [in] | kermit | Session handle. |
| [in] | data | Received bytes. Must not be NULL. |
| [in] | length | Number of bytes. Must be greater than 0. |
| void kermit_free | ( | Kermit * | kermit | ) |
Free a Kermit session and release any pending receive buffer.
| [in] | kermit | Session handle. Must not be NULL. |
| bool kermit_is_active | ( | Kermit * | kermit | ) |
Check whether the transfer has completed.
| [in] | kermit | Session handle. |
| void kermit_reset_state | ( | Kermit * | kermit | ) |
Reset the session back to the idle state.
Resets the sequence counter, frees any in-progress receive buffer, and moves the file-transfer state machine to idle. Safe to call at any time.
| [in] | kermit | Session handle. |
| bool kermit_start | ( | Kermit * | kermit, |
| const uint8_t | timeout_seconds ) |
Start a file transfer by transmitting the Send-Init (S) packet.
Must be called while the session is idle. The transfer is then driven by feeding the receiver's responses with kermit_feed_serial_data().
| [in] | kermit | Session handle. |
| [in] | timeout_seconds | Per-packet timeout advertised to the receiver (Kermit TIMO field), in seconds. |