Browse Source

Merge pull request #2517 from DonLakeFlyer/USBStart

PX4 Firmware no longer requires mavlink USB start
QGC4.4
Don Gagne 9 years ago
parent
commit
996c282c44
  1. 4
      src/comm/LinkInterface.h
  2. 2
      src/comm/LinkManager.cc
  3. 35
      src/comm/MAVLinkProtocol.cc
  4. 4
      src/comm/MAVLinkProtocol.h
  5. 9
      src/comm/SerialLink.cc
  6. 1
      src/comm/SerialLink.h

4
src/comm/LinkInterface.h

@ -131,10 +131,6 @@ public: @@ -131,10 +131,6 @@ public:
/// set into the link when it is added to LinkManager
uint8_t getMavlinkChannel(void) const { Q_ASSERT(_mavlinkChannelSet); return _mavlinkChannel; }
/// @return true: "sh /etc/init.d/rc.usb" must be sent on link to start mavlink
virtual bool requiresUSBMavlinkStart(void) const { return false; }
// These are left unimplemented in order to cause linker errors which indicate incorrect usage of
// connect/disconnect on link directly. All connect/disconnect calls should be made through LinkManager.
bool connect(void);

2
src/comm/LinkManager.cc

@ -189,8 +189,6 @@ void LinkManager::_addLink(LinkInterface* link) @@ -189,8 +189,6 @@ void LinkManager::_addLink(LinkInterface* link)
connect(link, &LinkInterface::communicationError, _app, &QGCApplication::criticalMessageBoxOnMainThread);
connect(link, &LinkInterface::bytesReceived, _mavlinkProtocol, &MAVLinkProtocol::receiveBytes);
connect(link, &LinkInterface::connected, _mavlinkProtocol, &MAVLinkProtocol::linkConnected);
connect(link, &LinkInterface::disconnected, _mavlinkProtocol, &MAVLinkProtocol::linkDisconnected);
_mavlinkProtocol->resetMetadataForLink(link);

35
src/comm/MAVLinkProtocol.cc

@ -173,41 +173,6 @@ void MAVLinkProtocol::resetMetadataForLink(const LinkInterface *link) @@ -173,41 +173,6 @@ void MAVLinkProtocol::resetMetadataForLink(const LinkInterface *link)
currLossCounter[channel] = 0;
}
void MAVLinkProtocol::linkConnected(void)
{
LinkInterface* link = qobject_cast<LinkInterface*>(QObject::sender());
Q_ASSERT(link);
_linkStatusChanged(link, true);
}
void MAVLinkProtocol::linkDisconnected(void)
{
LinkInterface* link = qobject_cast<LinkInterface*>(QObject::sender());
Q_ASSERT(link);
_linkStatusChanged(link, false);
}
void MAVLinkProtocol::_linkStatusChanged(LinkInterface* link, bool connected)
{
qCDebug(MAVLinkProtocolLog) << "_linkStatusChanged" << QString("%1").arg((long)link, 0, 16) << connected;
Q_ASSERT(link);
if (connected) {
if (link->requiresUSBMavlinkStart()) {
// Send command to start MAVLink
// XXX hacky but safe
// Start NSH
const char init[] = {0x0d, 0x0d, 0x0d, 0x0d};
link->writeBytes(init, sizeof(init));
const char* cmd = "sh /etc/init.d/rc.usb\n";
link->writeBytes(cmd, strlen(cmd));
link->writeBytes(init, 4);
}
}
}
/**
* This method parses all incoming bytes and constructs a MAVLink packet.
* It can handle multiple links in parallel, as each link has it's own buffer/

4
src/comm/MAVLinkProtocol.h

@ -155,9 +155,6 @@ public slots: @@ -155,9 +155,6 @@ public slots:
/** @brief Receive bytes from a communication interface */
void receiveBytes(LinkInterface* link, QByteArray b);
void linkConnected(void);
void linkDisconnected(void);
/** @brief Set the rate at which heartbeats are emitted */
void setHeartbeatRate(int rate);
/** @brief Set the system id of this application */
@ -285,7 +282,6 @@ private slots: @@ -285,7 +282,6 @@ private slots:
void _vehicleCountChanged(int count);
private:
void _linkStatusChanged(LinkInterface* link, bool connected);
void _sendMessage(mavlink_message_t message);
void _sendMessage(LinkInterface* link, mavlink_message_t message);
void _sendMessage(LinkInterface* link, mavlink_message_t message, quint8 systemid, quint8 componentid);

9
src/comm/SerialLink.cc

@ -377,15 +377,6 @@ LinkConfiguration* SerialLink::getLinkConfiguration() @@ -377,15 +377,6 @@ LinkConfiguration* SerialLink::getLinkConfiguration()
return _config;
}
bool SerialLink::requiresUSBMavlinkStart(void) const
{
if (_port) {
return QGCSerialPortInfo(*_port).boardTypePixhawk();
} else {
return false;
}
}
//--------------------------------------------------------------------------
//-- SerialConfiguration

1
src/comm/SerialLink.h

@ -146,7 +146,6 @@ public: @@ -146,7 +146,6 @@ public:
void requestReset();
bool isConnected() const;
qint64 getConnectionSpeed() const;
bool requiresUSBMavlinkStart(void) const;
// These are left unimplemented in order to cause linker errors which indicate incorrect usage of
// connect/disconnect on link directly. All connect/disconnect calls should be made through LinkManager.

Loading…
Cancel
Save