2023-03-03 13:06:45 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* apps/system/ymodem/ymodem.h
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __APPS_SYSTEM_YMODEM_YMODEM_H
|
|
|
|
#define __APPS_SYSTEM_YMODEM_YMODEM_H
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
2023-04-20 05:53:44 +02:00
|
|
|
#include <stddef.h>
|
2023-03-03 13:06:45 +01:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Pre-processor Definitions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#define YMODEM_PACKET_SIZE 128
|
|
|
|
#define YMODEM_PACKET_1K_SIZE 1024
|
|
|
|
|
2023-04-20 05:53:44 +02:00
|
|
|
#define YMODEM_FILENAME_PACKET 0
|
|
|
|
#define YMODEM_DATA_PACKET 1
|
2023-03-03 13:06:45 +01:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Types
|
|
|
|
****************************************************************************/
|
|
|
|
|
2023-04-20 05:53:44 +02:00
|
|
|
struct ymodem_ctx_s
|
2023-03-03 13:06:45 +01:00
|
|
|
{
|
2023-04-20 05:53:44 +02:00
|
|
|
/* User need initialization */
|
|
|
|
|
2023-03-03 13:06:45 +01:00
|
|
|
int recvfd;
|
|
|
|
int sendfd;
|
2023-04-20 05:53:44 +02:00
|
|
|
CODE int (*packet_handler)(FAR struct ymodem_ctx_s *ctx);
|
2023-03-15 15:29:35 +01:00
|
|
|
size_t custom_size;
|
2023-03-03 13:06:45 +01:00
|
|
|
FAR void *priv;
|
2023-04-20 05:53:44 +02:00
|
|
|
|
|
|
|
/* Public data */
|
|
|
|
|
|
|
|
FAR uint8_t *data;
|
|
|
|
size_t packet_size;
|
|
|
|
int packet_type;
|
|
|
|
char file_name[PATH_MAX];
|
|
|
|
size_t file_length;
|
|
|
|
|
|
|
|
/* Private data */
|
|
|
|
|
|
|
|
FAR uint8_t *header;
|
|
|
|
#ifdef CONFIG_SYSTEM_YMODEM_DEBUG_FILEPATH
|
2023-03-03 13:06:45 +01:00
|
|
|
int debug_fd;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Function Prototypes
|
|
|
|
****************************************************************************/
|
|
|
|
|
2023-04-20 05:53:44 +02:00
|
|
|
int ymodem_recv(FAR struct ymodem_ctx_s *ctx);
|
|
|
|
int ymodem_send(FAR struct ymodem_ctx_s *ctx);
|
2023-03-03 13:06:45 +01:00
|
|
|
|
|
|
|
#endif /* __APPS_SYSTEM_YMODEM_YMODEM_H */
|