Changeset - 1132b19725a5
[Not reviewed]
Hasan Yavuz Ă–ZDERYA - 10 years ago 2015-10-06 17:43:57
hy@ozderya.net
implemented ASCII command sending
1 file changed with 18 insertions and 1 deletions:
0 comments (0 inline, 0 general)
commandpanel.cpp
Show inline comments
 
@@ -27,26 +27,43 @@ CommandPanel::CommandPanel(QSerialPort* 
 
    ui(new Ui::CommandPanel)
 
{
 
    serialPort = port;
 

	
 
    ui->setupUi(this);
 
    ui->scrollAreaWidgetContents->setLayout(new QVBoxLayout);
 

	
 
    connect(ui->pbNew, &QPushButton::clicked, this, &CommandPanel::newCommand);
 
}
 

	
 
CommandPanel::~CommandPanel()
 
{
 
    delete ui;
 
}
 

	
 
void CommandPanel::newCommand()
 
{
 
    auto command = new CommandWidget();
 
    ui->scrollAreaWidgetContents->layout()->addWidget(command);
 
    connect(command, &CommandWidget::sendCommand, this, &CommandPanel::sendCommand);
 
}
 

	
 
void CommandPanel::sendCommand(QString command, bool ascii)
 
{
 
    qDebug() << "command:" << command;
 
    if (!serialPort->isOpen())
 
    {
 
        qCritical() << "Port is not open!";
 
        return;
 
}
 

	
 
    if (ascii)
 
    {
 
        qDebug() << "Sending" << command;
 
        if (serialPort->write(command.toLatin1()) < 0)
 
        {
 
            qCritical() << "Send command failed!";
 
        }
 
    }
 
    else
 
    {
 
        qCritical("NYI");
 
    }
 
}
0 comments (0 inline, 0 general)