1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

OP-214 Start working on port selection within the Uploader widget to enable serial telemetry updates including rescue mode.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2237 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
edouard 2010-12-15 18:39:04 +00:00 committed by edouard
parent 08e888ac8c
commit f7c824cdb8
7 changed files with 291 additions and 295 deletions

View File

@ -0,0 +1,230 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
version="1.1"
width="48"
height="48"
id="svg2474">
<metadata
id="metadata33">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs2476">
<linearGradient
id="linearGradient3533">
<stop
id="stop3535"
style="stop-color:#93b9dd;stop-opacity:1"
offset="0" />
<stop
id="stop3545"
style="stop-color:#6396cd;stop-opacity:1"
offset="1" />
</linearGradient>
<linearGradient
id="linearGradient3266">
<stop
id="stop3268"
style="stop-color:#387ab8;stop-opacity:1"
offset="0" />
<stop
id="stop3270"
style="stop-color:#387ab8;stop-opacity:0"
offset="1" />
</linearGradient>
<linearGradient
id="linearGradient3276">
<stop
id="stop3278"
style="stop-color:#6396cd;stop-opacity:1"
offset="0" />
<stop
id="stop3280"
style="stop-color:#83acd5;stop-opacity:0"
offset="1" />
</linearGradient>
<linearGradient
x1="108.5625"
y1="102.78125"
x2="108.5625"
y2="71.78125"
id="linearGradient5497"
xlink:href="#linearGradient5491"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(-95.99949,-49.00038)" />
<linearGradient
id="linearGradient5491">
<stop
id="stop5493"
style="stop-color:#ffffff;stop-opacity:1"
offset="0" />
<stop
id="stop5495"
style="stop-color:#ffffff;stop-opacity:0"
offset="1" />
</linearGradient>
<linearGradient
x1="102.5625"
y1="49.78125"
x2="103.5625"
y2="72.78125"
id="linearGradient5480"
xlink:href="#linearGradient5474"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(-95.99949,-49.00038)" />
<linearGradient
id="linearGradient5474">
<stop
id="stop5476"
style="stop-color:#ffffff;stop-opacity:1"
offset="0" />
<stop
id="stop5478"
style="stop-color:#ffffff;stop-opacity:0"
offset="1" />
</linearGradient>
<linearGradient
x1="118.47968"
y1="55.060318"
x2="118.47968"
y2="91.941895"
id="linearGradient4593-5-8-1-5-2"
xlink:href="#linearGradient3533"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(-100.99949,-49.00038)" />
<linearGradient
x1="34.980953"
y1="53.837799"
x2="35.996098"
y2="83.57618"
id="linearGradient4593-5-8-1-5-2-3"
xlink:href="#linearGradient3533"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(-5,0)" />
<radialGradient
cx="33.875"
cy="197.29688"
r="4.84375"
fx="33.875"
fy="197.29688"
id="radialGradient5147-5"
xlink:href="#linearGradient6462-6-8-548-9-2-7"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1,0,0,0.33870968,0,130.47051)" />
<linearGradient
id="linearGradient6462-6-8-548-9-2-7">
<stop
id="stop6464-5-9-94-5-4-4"
style="stop-color:#000000;stop-opacity:1"
offset="0" />
<stop
id="stop6466-3-6-1-7-2-8"
style="stop-color:#000000;stop-opacity:0"
offset="1" />
</linearGradient>
<linearGradient
id="linearGradient6462-6-8-548-9-5">
<stop
id="stop6464-5-9-94-5-8"
style="stop-color:#000000;stop-opacity:1"
offset="0" />
<stop
id="stop6466-3-6-1-7-5"
style="stop-color:#000000;stop-opacity:0"
offset="1" />
</linearGradient>
<radialGradient
cx="33.875"
cy="197.29688"
r="4.84375"
fx="33.875"
fy="197.29688"
id="radialGradient6081"
xlink:href="#linearGradient6462-6-8-548-9-5"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1,0,0,0.33870968,0,130.47051)" />
<linearGradient
x1="42.030777"
y1="84.719109"
x2="53.808601"
y2="73.263672"
id="linearGradient4008"
xlink:href="#linearGradient3276"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(-5,0)" />
<linearGradient
x1="39.843277"
y1="83.781609"
x2="50.683601"
y2="75.138672"
id="linearGradient4018"
xlink:href="#linearGradient3266"
gradientUnits="userSpaceOnUse" />
</defs>
<path
d="m 38.71875,197.29687 a 4.84375,1.640625 0 1 1 -9.6875,0 4.84375,1.640625 0 1 1 9.6875,0 z"
transform="matrix(3.3032251,0,0,1.6761866,-89.458749,-288.73764)"
id="path6460-6-4-4-3-3"
style="opacity:0.2;color:#000000;fill:url(#radialGradient5147-5);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:3;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:new" />
<path
d="M 46.405989,78.610714 A 13.125,13.125 0 0 1 33.62701,84.097034"
transform="matrix(1.0666665,0,0,1.0666665,-14.49949,-51.367037)"
id="path4010"
style="color:#000000;fill:none;stroke:url(#linearGradient4018);stroke-width:8.43750095;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:new" />
<path
d="m 38.71875,197.29687 a 4.84375,1.640625 0 1 1 -9.6875,0 4.84375,1.640625 0 1 1 9.6875,0 z"
transform="matrix(4.541935,0,0,1.9809503,-131.42005,-348.86656)"
id="path6460-6-4-4-4"
style="opacity:0.1;color:#000000;fill:url(#radialGradient6081);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:3;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:new" />
<path
d="M 35.542313,84.24974 A 13.125,13.125 0 1 1 47.171703,64.884866"
transform="matrix(1.0666665,0,0,1.0666665,-14.49949,-51.367037)"
id="path4788-6"
style="color:#000000;fill:none;stroke:#387ab8;stroke-width:8.43750095;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:new" />
<path
d="m 38.50051,9.4996196 0,11.0000004 -11,0"
id="path4847"
style="color:#000000;fill:none;stroke:#387ab8;stroke-width:7;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:new" />
<path
d="m 46.386659,78.638476 a 13.125,13.125 0 0 1 -13.412517,5.34104"
transform="matrix(1.0666665,0,0,1.0666665,-14.49949,-51.367037)"
id="path4006"
style="color:#000000;fill:none;stroke:url(#linearGradient4008);stroke-width:6.56250095;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:new" />
<path
d="m 37.320778,84.13999 a 13.125,13.125 0 1 1 9.33779,-20.123155"
transform="matrix(1.0666665,0,0,1.0666665,-14.49949,-51.367037)"
id="path4788"
style="color:#000000;fill:none;stroke:url(#linearGradient4593-5-8-1-5-2-3);stroke-width:6.56250095;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:new" />
<path
d="m 38.50051,9.4996196 0,11.0000004 -11,0"
id="path4847-1"
style="color:#000000;fill:none;stroke:url(#linearGradient4593-5-8-1-5-2);stroke-width:5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:new" />
<path
d="m 29.740794,33.593555 c -3.674085,2.533277 -8.663315,2.652831 -12.552784,-0.06269 -5.010358,-3.498088 -6.216831,-10.333397 -2.718751,-15.34375 3.498091,-5.010353 10.3334,-6.216833 15.343751,-2.71875 1.16116,0.810688 2.10377,1.843969 2.875,3.03125 l -5.1875,0 c -1.056625,-0.01494 -2.028484,0.943269 -2.028484,2 0,1.056731 0.971859,2.014943 2.028484,2 l 11,0 c 1.062499,0.28125 2.062499,-0.71875 2,-2 l 0,-11.0000004 c 0.01671,-1.0680358 -0.963214,-2.0479629 -2.03125,-2.0312505 -0.06245,-0.00293 -0.125046,-0.00293 -0.1875,0 -0.982752,0.107995 -1.802514,1.0428108 -1.78125,2.0312505 l 0,4.0625004 c -0.9534,-1.127853 -2.06667,-2.152011 -3.28125,-3 l -0.09375,-0.0625 c -2.85203,-1.9610889 -6.0733,-2.9220479 -9.312501,-2.9687509 -5.46224,-0.07875 -10.90353,2.4568065 -14.2500005,7.2500009 -5.354351,7.669111 -3.450361,18.3019 4.2187505,23.65625 6.255407,4.367344 14.482569,3.905673 20.208772,-0.574695"
id="path4788-2"
style="font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:normal;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;opacity:0.23999999;color:#000000;fill:none;stroke:#ffffff;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:new;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans" />
<path
d="m 36.50052,13.562118 c -0.9534,-1.127853 -2.06667,-2.152011 -3.28125,-3 l -0.0937,-0.0625 c -2.85203,-1.9610889 -6.0733,-2.9220479 -9.312501,-2.9687509 -5.46224,-0.07875 -10.90354,2.4568065 -14.2500105,7.2500009 -5.354351,7.669111 -3.450361,18.3019 4.2187505,23.65625"
id="path4788-2-3"
style="font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:normal;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;opacity:0.3;color:#000000;fill:none;stroke:url(#linearGradient5480);stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:new;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans" />
<path
d="M 32.53183,30.81212 C 29.03374,35.822473 22.198429,37.028952 17.18808,33.53087 12.177699,30.032787 10.971229,23.197473 14.469309,18.18712 17.96742,13.176767 24.802729,11.970287 29.81308,15.46837"
id="path4788-2-3-4"
style="font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:normal;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;opacity:0.3;color:#000000;fill:none;stroke:url(#linearGradient5497);stroke-width:1;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:new;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans" />
</svg>

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -6,6 +6,8 @@ include(../../plugins/coreplugin/coreplugin.pri)
include(../../plugins/uavobjects/uavobjects.pri)
include(../../plugins/uavtalk/uavtalk.pri)
include(../../plugins/rawhid/rawhid.pri)
INCLUDEPATH += ../../libs/qextserialport/src
HEADERS += uploadergadget.h \
uploadergadgetconfiguration.h \
uploadergadgetfactory.h \

View File

@ -2,5 +2,6 @@
<qresource prefix="/uploader">
<file>images/deviceID-1.svg</file>
<file>images/deviceID-69.svg</file>
<file>images/view-refresh.svg</file>
</qresource>
</RCC>

View File

@ -87,7 +87,21 @@ recover a system which does not boot.</string>
</spacer>
</item>
<item>
<widget class="QComboBox" name="telemetryLink"/>
<widget class="QComboBox" name="telemetryLink">
<property name="toolTip">
<string>When telemetry is not connected, select the communication method using this combo box.</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="refreshPorts">
<property name="toolTip">
<string>Refresh the list of serial ports</string>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="boardStatus">

View File

@ -42,300 +42,14 @@ UploaderGadgetOptionsPage::UploaderGadgetOptionsPage(UploaderGadgetConfiguration
IOptionsPage(parent),
m_config(config)
{
//the begining of some ugly code
//diferent OS's have diferent serial port capabilities
#ifdef Q_OS_WIN
//load windows port capabilities
BaudRateTypeString
<<"BAUD110"
<<"BAUD300"
<<"BAUD600"
<<"BAUD1200"
<<"BAUD2400"
<<"BAUD4800"
<<"BAUD9600"
<<"BAUD14400"
<<"BAUD19200"
<<"BAUD38400"
<<"BAUD56000"
<<"BAUD57600"
<<"BAUD115200"
<<"BAUD128000"
<<"BAUD256000";
DataBitsTypeString
<<"DATA_5"
<<"DATA_6"
<<"DATA_7"
<<"DATA_8";
ParityTypeString
<<"PAR_NONE"
<<"PAR_ODD"
<<"PAR_EVEN"
<<"PAR_MARK" //WINDOWS ONLY
<<"PAR_SPACE";
StopBitsTypeString
<<"STOP_1"
<<"STOP_1_5" //WINDOWS ONLY
<<"STOP_2";
#else
//load POSIX port capabilities
BaudRateTypeString
<<"BAUD50" //POSIX ONLY
<<"BAUD75" //POSIX ONLY
<<"BAUD110"
<<"BAUD134" //POSIX ONLY
<<"BAUD150" //POSIX ONLY
<<"BAUD200" //POSIX ONLY
<<"BAUD300"
<<"BAUD600"
<<"BAUD1200"
<<"BAUD1800" //POSIX ONLY
<<"BAUD2400"
<<"BAUD4800"
<<"BAUD9600"
<<"BAUD19200"
<<"BAUD38400"
<<"BAUD57600"
<<"BAUD76800" //POSIX ONLY
<<"BAUD115200";
DataBitsTypeString
<<"DATA_5"
<<"DATA_6"
<<"DATA_7"
<<"DATA_8";
ParityTypeString
<<"PAR_NONE"
<<"PAR_ODD"
<<"PAR_EVEN"
<<"PAR_SPACE";
StopBitsTypeString
<<"STOP_1"
<<"STOP_2";
#endif
//load all OS's capabilities
BaudRateTypeStringALL
<<"BAUD50" //POSIX ONLY
<<"BAUD75" //POSIX ONLY
<<"BAUD110"
<<"BAUD134" //POSIX ONLY
<<"BAUD150" //POSIX ONLY
<<"BAUD200" //POSIX ONLY
<<"BAUD300"
<<"BAUD600"
<<"BAUD1200"
<<"BAUD1800" //POSIX ONLY
<<"BAUD2400"
<<"BAUD4800"
<<"BAUD9600"
<<"BAUD14400"
<<"BAUD19200"
<<"BAUD38400"
<<"BAUD56000"
<<"BAUD57600"
<<"BAUD76800" //POSIX ONLY
<<"BAUD115200"
<<"BAUD128000"
<<"BAUD256000";
DataBitsTypeStringALL
<<"DATA_5"
<<"DATA_6"
<<"DATA_7"
<<"DATA_8";
ParityTypeStringALL
<<"PAR_NONE"
<<"PAR_ODD"
<<"PAR_EVEN"
<<"PAR_MARK" //WINDOWS ONLY
<<"PAR_SPACE";
StopBitsTypeStringALL
<<"STOP_1"
<<"STOP_1_5" //WINDOWS ONLY
<<"STOP_2";
FlowTypeString
<<"FLOW_OFF"
<<"FLOW_HARDWARE"
<<"FLOW_XONXOFF";
}
bool sortPorts(QextPortInfo const& s1,QextPortInfo const& s2)
{
return s1.portName<s2.portName;
}
//creates options page widget
QWidget *UploaderGadgetOptionsPage::createPage(QWidget *parent)
{
//main widget
QWidget *widget = new QWidget;
//main layout
QVBoxLayout *vl = new QVBoxLayout();
widget->setLayout(vl);
//port layout and widget
QHBoxLayout *portLayout = new QHBoxLayout();
QWidget *x = new QWidget;
x->setLayout(portLayout);
QWidget *label = new QLabel("Port:");
m_portCB = new QComboBox(parent);
m_portCB->setMinimumSize(200,22);
portLayout->addWidget(label);
portLayout->addWidget(m_portCB);
//port speed layout and widget
QHBoxLayout *speedLayout = new QHBoxLayout();
QWidget *y = new QWidget;
y->setLayout(speedLayout);
label = new QLabel("Port Speed:");
m_speedCB = new QComboBox();
m_speedCB->setMinimumSize(200,22);
speedLayout->addWidget(label);
speedLayout->addWidget(m_speedCB);
//flow control layout and widget
QHBoxLayout *flowLayout = new QHBoxLayout();
QWidget *z = new QWidget;
z->setLayout(flowLayout);
label = new QLabel("Flow Control:");
m_flowCB = new QComboBox();
m_flowCB->setMinimumSize(200,22);
flowLayout->addWidget(label);
flowLayout->addWidget(m_flowCB);
//databits layout and widget
QHBoxLayout *databitsLayout = new QHBoxLayout();
QWidget *a = new QWidget;
a->setLayout(databitsLayout);
label = new QLabel("Data Bits:");
m_databitsCB = new QComboBox();
m_databitsCB->setMinimumSize(200,22);
databitsLayout->addWidget(label);
databitsLayout->addWidget(m_databitsCB);
//stopbits layout and widget
QHBoxLayout *stopbitsLayout = new QHBoxLayout();
QWidget *b = new QWidget;
b->setLayout(stopbitsLayout);
label = new QLabel("Stop Bits:");
m_stopbitsCB = new QComboBox();
m_stopbitsCB->setMinimumSize(200,22);
stopbitsLayout->addWidget(label);
stopbitsLayout->addWidget(m_stopbitsCB);
//parity layout and widget
QHBoxLayout *parityLayout = new QHBoxLayout();
QWidget *c = new QWidget;
c->setLayout(parityLayout);
label = new QLabel("Parity:");
m_parityCB = new QComboBox();
m_parityCB->setMinimumSize(200,22);
parityLayout->addWidget(label);
parityLayout->addWidget(m_parityCB);
//timeout layout and widget
QHBoxLayout *timeoutLayout = new QHBoxLayout();
QWidget *d = new QWidget;
d->setLayout(timeoutLayout);
label = new QLabel("TimeOut(ms):");
m_timeoutSpin = new QSpinBox();
m_timeoutSpin->setMaximum(100000);
m_timeoutSpin->setMinimumSize(200,22);
timeoutLayout->addWidget(label);
timeoutLayout->addWidget(m_timeoutSpin);
QSpacerItem *spacer = new QSpacerItem(100, 100, QSizePolicy::Expanding, QSizePolicy::Expanding);
//add partial widget to main widget
vl->addWidget(x);
vl->addWidget(y);
vl->addWidget(z);
vl->addWidget(a);
vl->addWidget(b);
vl->addWidget(c);
vl->addWidget(d);
vl->addSpacerItem(spacer);
//clears comboboxes, if not every time the user enters options page the lists
//duplicate
m_portCB->clear();
m_speedCB->clear();
m_databitsCB->clear();
m_flowCB->clear();
m_parityCB->clear();
m_stopbitsCB->clear();
//gets available serial ports
QList<QextPortInfo> ports =QextSerialEnumerator ::getPorts();
qSort(ports.begin(), ports.end(),sortPorts);
qDebug() << "List of ports:";
for (int i = 0; i < ports.size(); i++) {
qDebug() << "port name:" << ports.at(i).portName;
qDebug() << "friendly name:" << ports.at(i).friendName;
qDebug() << "physical name:" << ports.at(i).physName;
qDebug() << "enumerator name:" << ports.at(i).enumName;
qDebug() << "vendor ID:" << QString::number(ports.at(i).vendorID, 16);
qDebug() << "product ID:" << QString::number(ports.at(i).productID, 16);
qDebug() << "===================================";
}
#ifdef Q_OS_WIN
//on windows populate ports combobox with ports name
for (int i = 0; i < ports.size(); i++) {
m_portCB->addItem((QString)ports.at(i).portName.toLocal8Bit().constData());
}
#else
//on other OS's populate ports combobox with ports physical name
for (int i = 0; i < ports.size(); i++) {
m_portCB->addItem((QString)ports.at(i).physName.toLocal8Bit().constData());
}
#endif
//The next selections of comboboxe's saved value are ugly as hell
//There must be a better wat for doing this.
//select saved port
if(m_portCB->findText(m_config->Port())!=-1){
m_portCB->setCurrentIndex(m_portCB->findText(m_config->Port()));
}
//populate serial speed combobox
for (int i=0;i<BaudRateTypeString.size();i++){
m_speedCB->addItem(BaudRateTypeString.at(i).toLocal8Bit().constData() );
}
//select saved speed
if(m_speedCB->findText(BaudRateTypeStringALL.at((int)m_config->Speed()).toLocal8Bit().constData())!=-1){
m_speedCB->setCurrentIndex(m_speedCB->findText(BaudRateTypeStringALL.at((int)m_config->Speed()).toLocal8Bit().constData()));
}
//populate databits combobox
for (int i=0;i<DataBitsTypeString.size();i++){
m_databitsCB->addItem(DataBitsTypeString.at(i).toLocal8Bit().constData() );
}
//select saved databits
if(m_databitsCB->findText(DataBitsTypeStringALL.at((int)m_config->DataBits()).toLocal8Bit().constData())!=-1){
m_databitsCB->setCurrentIndex(m_databitsCB->findText(DataBitsTypeStringALL.at((int)m_config->DataBits()).toLocal8Bit().constData()));
}
//populate parity combobox
for (int i=0;i<ParityTypeString.size();i++){
m_parityCB->addItem(ParityTypeString.at(i).toLocal8Bit().constData() );
}
//select saved parity
if(m_parityCB->findText(ParityTypeStringALL.at((int)m_config->Parity()).toLocal8Bit().constData())!=-1){
m_parityCB->setCurrentIndex(m_parityCB->findText(ParityTypeStringALL.at((int)m_config->Parity()).toLocal8Bit().constData()));
}
//populate stopbits combobox
for (int i=0;i<StopBitsTypeString.size();i++){
m_stopbitsCB->addItem(StopBitsTypeString.at(i).toLocal8Bit().constData() );
}
//select saved stopbits
if(m_stopbitsCB->findText(StopBitsTypeStringALL.at((int)m_config->StopBits()).toLocal8Bit().constData())!=-1){
m_stopbitsCB->setCurrentIndex(m_stopbitsCB->findText(StopBitsTypeStringALL.at((int)m_config->StopBits()).toLocal8Bit().constData()));
}
//populate flow control combobox
for (int i=0;i<FlowTypeString.size();i++){
m_flowCB->addItem(FlowTypeString.at(i).toLocal8Bit().constData() );
}
//select saved flow control
if(m_flowCB->findText(FlowTypeString.at((int)m_config->Flow()).toLocal8Bit().constData())!=-1){
m_flowCB->setCurrentIndex(m_flowCB->findText(FlowTypeString.at((int)m_config->Flow()).toLocal8Bit().constData()));
}
//fill time out spinbox with saved value
m_timeoutSpin->setValue(m_config->TimeOut());
return widget;
}
/**
@ -346,13 +60,6 @@ QWidget *UploaderGadgetOptionsPage::createPage(QWidget *parent)
*/
void UploaderGadgetOptionsPage::apply()
{
m_config->setPort(m_portCB->currentText());
m_config->setSpeed((BaudRateType)BaudRateTypeStringALL.indexOf(m_speedCB->currentText()));
m_config->setDataBits((DataBitsType)DataBitsTypeStringALL.indexOf(m_databitsCB->currentText()));
m_config->setStopBits((StopBitsType)StopBitsTypeStringALL.indexOf(m_stopbitsCB->currentText()));
m_config->setParity((ParityType)ParityTypeStringALL.indexOf(m_parityCB->currentText()));
m_config->setFlow((FlowType)FlowTypeString.indexOf(m_flowCB->currentText()));
m_config->setTimeOut( m_timeoutSpin->value());
}

View File

@ -51,8 +51,45 @@ UploaderGadgetWidget::UploaderGadgetWidget(QWidget *parent) : QWidget(parent)
connect(m_config->bootButton, SIGNAL(clicked()), this, SLOT(systemBoot()));
connect(m_config->rescueButton, SIGNAL(clicked()), this, SLOT(systemRescue()));
getSerialPorts();
QIcon rbi;
rbi.addFile(QString(":uploader/images/view-refresh.svg"));
m_config->refreshPorts->setIcon(rbi);
connect(m_config->refreshPorts, SIGNAL(clicked()), this, SLOT(getSerialPorts()));
}
bool sortPorts(const QextPortInfo &s1,const QextPortInfo &s2)
{
return s1.portName<s2.portName;
}
/**
Gets the list of serial ports
*/
void UploaderGadgetWidget::getSerialPorts()
{
QStringList list;
// Populate the telemetry combo box:
m_config->telemetryLink->clear();
list.append(QString("USB"));
QList<QextPortInfo> ports = QextSerialEnumerator::getPorts();
//sort the list by port number (nice idea from PT_Dreamer :))
qSort(ports.begin(), ports.end(),sortPorts);
foreach( QextPortInfo port, ports ) {
list.append(port.friendName);
}
m_config->telemetryLink->addItems(list);
}
/**
Enables widget buttons if autopilot connected
*/

View File

@ -32,6 +32,9 @@
#include "delay.h"
#include "devicewidget.h"
#include "op_dfu.h"
#include <qextserialport.h>
#include <qextserialenumerator.h>
#include "uavtalk/telemetrymanager.h"
#include "extensionsystem/pluginmanager.h"
@ -81,6 +84,8 @@ private slots:
void systemReset();
void systemBoot();
void systemRescue();
void getSerialPorts();
};
#endif // UPLOADERGADGETWIDGET_H