send a file from tera term pro(XMODEM-CRC) and received it in stm32f429zi board
i try to send a .txt file(1KB) from tera term pro(transfer>xmodem>send>select file with CRC) and i want to received the file on stm32f429zi controller. but , tera term monitor was blank and i check with stm-side also in live expression but no values received ....i will attach the and photos. please check
((void process_xmodem_packet(uint8_t *packet, uint16_t packet_size) {
// Assuming you have implemented xmodem_verify_packet and xmodem_calculate_crc functions
if (xmodem_verify_packet(packet, packet_size)) {
} else {
// Packet is invalid, handle error (e.g., request packet retransmission)
// ...
}
}
void send_ack(void) {
HAL_UART_Transmit(&huart2, (uint8_t *)"\x06", 1, HAL_MAX_DELAY);
}
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) {
static xmodem_packet_t xmodem_packet;
static uint16_t packet_index = 0;
// Process Xmodem packet
if (rx_buffer[0] == SOH) {
// Start of Header, begin a new packet
packet_index = 0;
} else if (rx_buffer[0] == EOT) {
// End of Transmission, file transfer complete
// Add your file handling logic here, e.g., save the received data to a file
// Send an ACK to acknowledge the EOT
send_ack();
} else {
// Regular data byte, add to the packet buffer
xmodem_packet.data[packet_index++] = rx_buffer[0];
// Check if the packet is complete
if (packet_index == XMODEM_BLOCK_SIZE) {
// Process the complete packet
xmodem_calculate_crc(xmodem_packet.data, XMODEM_BLOCK_SIZE, &xmodem_packet.crc);
// Verify the packet
if (xmodem_verify_packet(&xmodem_packet, XMODEM_BLOCK_SIZE)) {
// Packet is valid, process it as needed
// ...
} else {
// Packet is invalid, handle error (e.g., request packet retransmission)
// ...
}
// Send an ACK to acknowledge the packet
send_ack();
// Start a new packet
packet_index = 0;
}
}
// Resume receiving data
HAL_UART_Receive_IT(&huart2, rx_buffer, 1);
}))
