2 ******************************************************************************
5 * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2017.
6 * The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
7 * @addtogroup GCSPlugins GCS Plugins
9 * @addtogroup Uploader Serial and USB Uploader Plugin
11 * @brief The USB and Serial protocol uploader plugin
12 *****************************************************************************/
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 3 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, write to the Free Software Foundation, Inc.,
26 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
40 class port
: public QObject
{
44 enum portstatus
{ open
, closed
, error
};
46 port(QString name
, bool debug
);
50 virtual int16_t pfSerialRead(void); // function to read a character from the serial input stream
51 virtual void pfSerialWrite(uint8_t); // function to write a byte to be sent out the serial port
52 virtual uint32_t pfGetTime(void);
54 uint8_t retryCount
; // how many times have we tried to transmit the 'send' packet
55 uint8_t maxRetryCount
; // max. times to try to transmit the 'send' packet
56 uint16_t max_retry
; // Maximum number of retrys for a single transmit.
57 int32_t timeoutLen
; // how long to wait for each retry to succeed
58 uint32_t timeout
; // current timeout. when 'time' reaches this point we have timed out
59 uint8_t txSeqNo
; // current 'send' packet sequence number
60 uint16_t rxBufPos
; // current buffer position in the receive packet
61 uint16_t rxBufLen
; // number of 'data' bytes in the buffer
62 uint8_t rxSeqNo
; // current 'receive' packet number
63 uint16_t rxBufSize
; // size of the receive buffer.
64 uint16_t txBufSize
; // size of the transmit buffer.
65 uint8_t *txBuf
; // transmit buffer. REquired to store a copy of packet data in case a retry is needed.
66 uint8_t *rxBuf
; // receive buffer. Used to store data as a packet is received.
67 uint16_t sendSynch
; // flag to indicate that we should send a synchronize packet to the host
68 // this is required when switching from the application to the bootloader
69 // and vice-versa. This fixes the firmware download timeout.
70 // when this flag is set to true, the next time we send a packet we will first
71 // send a synchronize packet.
72 ReceiveState inputState
;
73 DecodeState decodeState
;
86 QByteArray rxDebugBuff
;
87 QByteArray txDebugBuff
;