Developer World
Spresense SDK Library v3.3.0-375c679
xmodem.h
1/****************************************************************************
2 * system/include/system/xmodem.h
3 *
4 * Copyright 2019 Sony Semiconductor Solutions Corporation
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 * 3. Neither the name of Sony Semiconductor Solutions Corporation nor
17 * the names of its contributors may be used to endorse or promote
18 * products derived from this software without specific prior written
19 * permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
28 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *
34 ****************************************************************************/
35
36#ifndef __APPS_INCLUDE_SYSTEM_XMODEM_H
37#define __APPS_INCLUDE_SYSTEM_XMODEM_H
38
39/****************************************************************************
40 * Pre-processor Definitions
41 ****************************************************************************/
42
43#define XM_ERR_CANCEL (-1) /* canceld by remote */
44#define XM_ERR_NOSYNC (-2) /* no sync */
45#define XM_ERR_RETRYOUT (-3) /* too many retry error */
46#define XM_ERR_XMIT (-4) /* xmit error */
47#define XM_ERR_XMIT_NOACK (-5) /* no ack xmit error */
48#define XM_ERR_INVAL (-6) /* invalid parameter */
49#define XM_ERR_NOSPC (-7) /* no space left on device */
50
51/****************************************************************************
52 * Public Types
53 ****************************************************************************/
54/* Opaque handles returned by initialization functions */
55
56typedef void *XMHANDLE;
57
58#undef EXTERN
59#if defined(__cplusplus)
60#define EXTERN extern "C"
61extern "C"
62{
63#else
64#define EXTERN extern
65#endif
66
67/****************************************************************************
68 * Public Function Prototypes
69 ****************************************************************************/
70
71/****************************************************************************
72 * Name: xmodemHandleInit
73 *
74 * Description:
75 * Initialize the xmodem handle.
76 *
77 * Input Parameters:
78 * fd - The file descriptor of communication device.
79 *
80 * Returned Value:
81 * If successful, returns a non-NULL value.
82 * Otherwise it will return a NULL value.
83 *
84 ****************************************************************************/
85
86XMHANDLE xmodemHandleInit(int fd);
87
88/****************************************************************************
89 * Name: xmodemHandleRelease
90 *
91 * Description:
92 * Release the xmodem handle.
93 *
94 * Input Parameters:
95 * handle - The handle to use xmodem.
96 *
97 * Returned Value:
98 * If successful, the zero will be returned.
99 * Otherwise it will return a negative value.
100 *
101 ****************************************************************************/
102
103int xmodemHandleRelease(XMHANDLE handle);
104
105/****************************************************************************
106 * Name: xmodemReceive
107 *
108 * Description:
109 * Receive date sent from the remote peer.
110 *
111 * Input Parameters:
112 * handle - The handle to use xmodem.
113 * dest - The destination buffer address to receive.
114 * destsz - The size of destination buffer address.
115 *
116 * Returned Value:
117 * If successful, the received data size will be returned.
118 * Otherwise it will return a negative value.
119 *
120 ****************************************************************************/
121
122int xmodemReceive(XMHANDLE handle, unsigned char *dest, int destsz);
123
124/****************************************************************************
125 * Name: xmodemTransmit
126 *
127 * Description:
128 * Send date to the remote peer.
129 *
130 * Input Parameters:
131 * handle - The handle to use xmodem.
132 * src - The source buffer address to send.
133 * srcsz - The size of source buffer address.
134 *
135 * Returned Value:
136 * If successful, the sent data size will be returned.
137 * Otherwise it will return a negative value.
138 *
139 ****************************************************************************/
140
141int xmodemTransmit(XMHANDLE handle, unsigned char *src, int srcsz);
142
143#undef EXTERN
144#if defined(__cplusplus)
145}
146#endif
147
148#endif /* __APPS_INCLUDE_SYSTEM_XMODEM_H */