LP-311 Remove basic/advanced stabilization tab auto-switch (autotune/txpid lock issues)
[librepilot.git] / ground / gcs / src / experimental / USB_UPLOAD_TOOL / SSP / port.h
blob16cf65579e593d76444a20e8b0c6281d1cd4987b
1 /**
2 ******************************************************************************
4 * @file port.h
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
6 * @addtogroup GCSPlugins GCS Plugins
7 * @{
8 * @addtogroup Uploader Serial and USB Uploader Plugin
9 * @{
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
21 * for more details.
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
27 #ifndef PORT_H
28 #define PORT_H
29 #include <stdint.h>
30 #include <QtSerialPort/QSerialPort>
31 #include <QtSerialPort/QSerialPortInfo>
32 #include <QTime>
33 #include <QDebug>
34 #include "common.h"
36 class port {
37 public:
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;
61 uint16_t SendState;
62 uint16_t crc;
63 uint32_t RxError;
64 uint32_t TxError;
65 uint16_t flags;
66 port(QString name, bool debug);
67 virtual ~port();
68 portstatus status();
69 private:
70 bool debug;
71 QByteArray rxDebugBuff;
72 QByteArray txDebugBuff;
73 portstatus mstatus;
74 QTime timer;
75 QSerialPort *sport;
78 #endif // PORT_H