This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

About uart communication...

My project is using QT program and nRF52DK borad.

I want to UART communication with QT and nRF52DK.

#1. If i write "hello" in qt program like below...

==========================================================================================

[QT Program]

QString value = "Hello";
    QByteArray writeData = value.toUtf8();
    const qint64 bytesWritten = port->write(writeData);

    if(bytesWritten == -1) {
        standardOutput << QObject::tr("Failed to write the data to port %1, error: %2")
                                  .arg(ui->comboBox->currentText()).arg(port->errorString()) << endl;
    } else if (bytesWritten != writeData.size()) {
        standardOutput << QObject::tr("Failed to write all the data to port %1, error: %2")
                          .arg(ui->comboBox->currentText()).arg(port->errorString()) << endl;
    } else if (!port->waitForBytesWritten(5000)) {
        standardOutput << QObject::tr("Operation timed out or an error "
                                      "occurred for port %1, error: %2")
                          .arg(ui->comboBox->currentText()).arg(port->errorString()) << endl;
    }

    standardOutput << QObject::tr("Data successfully sent to port %1 about %2")
                      .arg(ui->comboBox->currentText()).arg(writeData.data()) << endl;


[nRF52DK]
while(true) {
//if(app_uart_get(&cr) != NRF_SUCCESS) break;
while (app_uart_get(&cr) != NRF_SUCCESS);
uint8_t cr_int = strtol(&cr, NULL, 16);
}
==========================================================================================
Receive data is success in nRF52DK.

#2. If i write "Helloooooooooooooo" in qt program like below...
==========================================================================================
QString value = "Helloooooooooooooo";
    QByteArray writeData = value.toUtf8();
    const qint64 bytesWritten = port->write(writeData);

    if(bytesWritten == -1) {
        standardOutput << QObject::tr("Failed to write the data to port %1, error: %2")
                                  .arg(ui->comboBox->currentText()).arg(port->errorString()) << endl;
    } else if (bytesWritten != writeData.size()) {
        standardOutput << QObject::tr("Failed to write all the data to port %1, error: %2")
                          .arg(ui->comboBox->currentText()).arg(port->errorString()) << endl;
    } else if (!port->waitForBytesWritten(5000)) {
        standardOutput << QObject::tr("Operation timed out or an error "
                                      "occurred for port %1, error: %2")
                          .arg(ui->comboBox->currentText()).arg(port->errorString()) << endl;
    }

    standardOutput << QObject::tr("Data successfully sent to port %1 about %2")
                      .arg(ui->comboBox->currentText()).arg(writeData.data()) << endl;


[nRF52DK] is same
==========================================================================================
In this case error occured.
Error message is "ERROR 1 [NRF_ERROR_SVC_HANDLER_MISSING] at main.c:557"

main.c 557 line is below..
void uart_error_handle(app_uart_evt_t * p_event)
{
if (p_event->evt_type == APP_UART_COMMUNICATION_ERROR)
{
APP_ERROR_HANDLER(p_event->data.error_communication);
}
else if (p_event->evt_type == APP_UART_FIFO_ERROR)
{
APP_ERROR_HANDLER(p_event->data.error_code);
}
}


I don't understand what's different with #1 and #2.
How can I solved this problem??
Related