Browse Source

Fix to make Baud and PortName update when changed

QGC4.4
Bill Bonney 12 years ago
parent
commit
bc2ce1ab47
  1. 9
      qml/ApmToolBar.qml
  2. 22
      src/comm/SerialLink.cc
  3. 3
      src/comm/SerialLink.h
  4. 2
      src/ui/apmtoolbar.cpp

9
qml/ApmToolBar.qml

@ -10,7 +10,7 @@ Rectangle { @@ -10,7 +10,7 @@ Rectangle {
property alias baudrateLabel: baudrate.label
property bool connected: false
width: 1024 < parent.width ? 1024 : parent.width
width: toolbar.width
height: 72
color: "black"
border.color: "black"
@ -19,9 +19,11 @@ Rectangle { @@ -19,9 +19,11 @@ Rectangle {
if (connected){
console.log("APM Tool BAR QML: connected")
connectButton.image = "./resources/apmplanner/toolbar/disconnect.png"
connectButton.label = "CONNECT"
} else {
console.log("APM Tool BAR QML: disconnected")
connectButton.image = "./resources/apmplanner/toolbar/connect.png"
connectButton.label = "DISCONNECT"
}
}
@ -83,7 +85,7 @@ Rectangle { @@ -83,7 +85,7 @@ Rectangle {
}
Button {
id: simualtionView
id: simulationView
label: "SIMULATION"
image: "./resources/apmplanner/toolbar/simulation.png"
onClicked: globalObj.triggerSimulationView()
@ -102,6 +104,8 @@ Rectangle { @@ -102,6 +104,8 @@ Rectangle {
color: "black"
}
// [BB] Commented out ToolBar Status info work.
// WIP: To be fixed later
// DigitalDisplay { // Information Pane
// title:"Mode"
// textValue: "Stabilize"
@ -169,7 +173,6 @@ Rectangle { @@ -169,7 +173,6 @@ Rectangle {
}
Rectangle { // Spacer
anchors.right: parent.right
width: 5
height: parent.height
color: "black"

22
src/comm/SerialLink.cc

@ -97,7 +97,14 @@ QVector<QString>* SerialLink::getCurrentPorts() @@ -97,7 +97,14 @@ QVector<QString>* SerialLink::getCurrentPorts()
m_ports->clear();
// Example use QSerialPortInfo
// [TODO] make this thread safe
foreach (const QSerialPortInfo &info, QSerialPortInfo::availablePorts())
QList<QSerialPortInfo> portList = QSerialPortInfo::availablePorts();
if( portList.count() == 0){
qDebug() << "No Ports Found" << m_ports;
}
foreach (const QSerialPortInfo &info, portList)
{
// qDebug() << "PortName : " << info.portName()
// << "Description : " << info.description();
@ -706,6 +713,7 @@ bool SerialLink::setPortName(QString portName) @@ -706,6 +713,7 @@ bool SerialLink::setPortName(QString portName)
m_port->setPortName(portName);
emit nameChanged(m_portName); // [TODO] maybe we can eliminate this
emit updateLink(this);
return accepted;
}
return false;
@ -716,12 +724,15 @@ bool SerialLink::setBaudRateType(int rateIndex) @@ -716,12 +724,15 @@ bool SerialLink::setBaudRateType(int rateIndex)
{
Q_ASSERT_X(m_port != NULL, "setBaudRateType", "m_port is NULL");
// These minimum and maximum baud rates were based on those enumerated in qserialport.h
bool result;
const int minBaud = (int)QSerialPort::Baud1200;
const int maxBaud = (int)QSerialPort::Baud115200;
if (m_port && (rateIndex >= minBaud && rateIndex <= maxBaud))
{
return m_port->setBaudRate(static_cast<QSerialPort::BaudRate>(rateIndex));
result = m_port->setBaudRate(static_cast<QSerialPort::BaudRate>(rateIndex));
emit updateLink(this);
return result;
}
return false;
@ -743,6 +754,7 @@ bool SerialLink::setBaudRate(int rate) @@ -743,6 +754,7 @@ bool SerialLink::setBaudRate(int rate)
accepted = true;
if (m_port)
accepted = m_port->setBaudRate(rate);
emit updateLink(this);
}
return accepted;
}
@ -755,6 +767,7 @@ bool SerialLink::setFlowType(int flow) @@ -755,6 +767,7 @@ bool SerialLink::setFlowType(int flow)
accepted = true;
if (m_port)
accepted = m_port->setFlowControl(static_cast<QSerialPort::FlowControl>(flow));
emit updateLink(this);
}
return accepted;
}
@ -784,6 +797,7 @@ bool SerialLink::setParityType(int parity) @@ -784,6 +797,7 @@ bool SerialLink::setParityType(int parity)
accepted = false;
break;
}
emit updateLink(this);
}
}
return accepted;
@ -798,6 +812,7 @@ bool SerialLink::setDataBits(int dataBits) @@ -798,6 +812,7 @@ bool SerialLink::setDataBits(int dataBits)
accepted = true;
if (m_port)
accepted = m_port->setDataBits(static_cast<QSerialPort::DataBits>(dataBits));
emit updateLink(this);
}
return accepted;
}
@ -811,6 +826,7 @@ bool SerialLink::setStopBits(int stopBits) @@ -811,6 +826,7 @@ bool SerialLink::setStopBits(int stopBits)
accepted = true;
if (m_port)
accepted = m_port->setStopBits(static_cast<QSerialPort::StopBits>(stopBits));
emit updateLink(this);
}
return accepted;
}
@ -823,6 +839,7 @@ bool SerialLink::setDataBitsType(int dataBits) @@ -823,6 +839,7 @@ bool SerialLink::setDataBitsType(int dataBits)
accepted = true;
if (m_port)
accepted = m_port->setDataBits(static_cast<QSerialPort::DataBits>(dataBits));
emit updateLink(this);
}
return accepted;
}
@ -835,6 +852,7 @@ bool SerialLink::setStopBitsType(int stopBits) @@ -835,6 +852,7 @@ bool SerialLink::setStopBitsType(int stopBits)
accepted = true;
if (m_port)
accepted = m_port->setStopBits(static_cast<QSerialPort::StopBits>(stopBits));
emit updateLink(this);
}
return accepted;
}

3
src/comm/SerialLink.h

@ -112,6 +112,9 @@ public: @@ -112,6 +112,9 @@ public:
bool isFullDuplex();
int getId();
signals: //[TODO] Refactor to Linkinterface
void updateLink(LinkInterface*);
public slots:
bool setPortName(QString portName);
bool setBaudRate(int rate);

2
src/ui/apmtoolbar.cpp

@ -143,6 +143,8 @@ void APMToolBar::showConnectionDialog() @@ -143,6 +143,8 @@ void APMToolBar::showConnectionDialog()
if (link && LinkManager::instance()->getLinks().count() >= 3)
{
// Serial Link so prompt to config it
connect(link, SIGNAL(updateLink(LinkInterface*)),
this, SLOT(updateLinkDisplay(LinkInterface*)));
result = MainWindow::instance()->configLink(link);
if (!result)

Loading…
Cancel
Save