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