2018-01-03 14:18:06 +01:00
|
|
|
/*
|
2018-02-28 14:46:02 +01:00
|
|
|
* This file is part of the MicroPython ESP32 project, https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo
|
2018-01-03 14:18:06 +01:00
|
|
|
*
|
|
|
|
|
* The MIT License (MIT)
|
|
|
|
|
*
|
2018-02-28 14:46:02 +01:00
|
|
|
* Copyright (c) 2018 LoBo (https://github.com/loboris)
|
2018-01-03 14:18:06 +01:00
|
|
|
*
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
|
*
|
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
|
* THE SOFTWARE.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* MicroPython-ESP32 YModem driver/Module
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2017 Boris Lovosevic (https://github.com/loboris)
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef __MODYMODEM_H__
|
|
|
|
|
#define __MODYMODEM_H__
|
|
|
|
|
|
|
|
|
|
#include "sdkconfig.h"
|
|
|
|
|
|
|
|
|
|
#if CONFIG_MICROPY_RX_BUFFER_SIZE > 1079
|
|
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
|
|
// === UART DEFINES ====
|
|
|
|
|
#define BUF_SIZE (1080)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ==== Y-MODEM defines ====
|
|
|
|
|
#define PACKET_SEQNO_INDEX (1)
|
|
|
|
|
#define PACKET_SEQNO_COMP_INDEX (2)
|
|
|
|
|
|
|
|
|
|
#define PACKET_HEADER (3)
|
|
|
|
|
#define PACKET_TRAILER (2)
|
|
|
|
|
#define PACKET_OVERHEAD (PACKET_HEADER + PACKET_TRAILER)
|
|
|
|
|
#define PACKET_SIZE (128)
|
|
|
|
|
#define PACKET_1K_SIZE (1024)
|
|
|
|
|
|
|
|
|
|
#define FILE_SIZE_LENGTH (16)
|
|
|
|
|
|
|
|
|
|
#define SOH (0x01) /* start of 128-byte data packet */
|
|
|
|
|
#define STX (0x02) /* start of 1024-byte data packet */
|
|
|
|
|
#define EOT (0x04) /* end of transmission */
|
|
|
|
|
#define ACK (0x06) /* acknowledge */
|
|
|
|
|
#define NAK (0x15) /* negative acknowledge */
|
|
|
|
|
#define CA (0x18) /* two of these in succession aborts transfer */
|
|
|
|
|
#define CRC16 (0x43) /* 'C' == 0x43, request 16-bit CRC */
|
|
|
|
|
|
|
|
|
|
#define ABORT1 (0x41) /* 'A' == 0x41, abort by user */
|
|
|
|
|
#define ABORT2 (0x61) /* 'a' == 0x61, abort by user */
|
|
|
|
|
|
|
|
|
|
#define NAK_TIMEOUT (1000)
|
|
|
|
|
#define MAX_ERRORS (45)
|
|
|
|
|
|
|
|
|
|
#define YM_MAX_FILESIZE (10*1024*1024)
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif
|