Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Serialport: Check parity problem
Forum Updated to NodeBB v4.3 + New Features

Serialport: Check parity problem

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nicorepetti
    wrote on last edited by
    #1

    Hello,

    I installed qtSerialport (Qt 4.8) in a pc with Ubuntu 12.04 a few days ago.
    I can send and receive commands through a serialport, but I cannot check the parity of the received data.

    Here is my code. Should I check some flag o something else?

    @
    bool configurarPuerto(QString *msg){

    this->serialPort->close();
    this->serialPort->setPort("ttyS3");
    
    *msg="Configuracion del puerto serie: ";
    if (!this->serialPort->open(QIODevice::ReadWrite)) {
        *msg+="Error abriendo el dispositivo";
        return false;
    }
    
    /* 
        I choose the configuration policy
        - SkipPolicy: Ignora los comandos invalidos
        - PassZeroPolicy: Lee 0
        - IgnorePolicy: Ignora el bit de paridad
        - StopReceivingPolicy: Deja de recibir datos
    */
    
    if (!this->serialPort->setDataErrorPolicy(SerialPort::StopReceivingPolicy)){
       qDebug()<<"Configuration error";
    } 
    
    if (!this->serialPort->setParity(SerialPort::EvenParity)) {
        *msg+="Error seteando paridad par";
        return false;
    }
    
    return true;
    

    }

    @

    1 Reply Last reply
    0
    • K Offline
      K Offline
      kuzulis
      Qt Champions 2020
      wrote on last edited by
      #2

      nicorepetti,

      The fact that the on *.nix you can identify the parity error only in the process of reading.

      Therefore, to solve this problem, try while receiving readyRead() call QtSerialPort::error(). This method should return the last error, if it occurred. In your case it will QtSerialPort::ParityError.

      I would also note that the idea of ​​the politicy processing, parity errors catch and etc. has not been fully thought out and implemented.

      So try until this workaround, maybe it is help for you.

      1 Reply Last reply
      0
      • N Offline
        N Offline
        nicorepetti
        wrote on last edited by
        #3

        Thanks for helping me,
        I just test the error function, but doesnt work (always returns 0 [no error])

        1 Reply Last reply
        0
        • K Offline
          K Offline
          kuzulis
          Qt Champions 2020
          wrote on last edited by
          #4

          We made some commits to library.

          Now, please try connect to signal errorChanged(QtSerialPort::PortError).

          In principle, this should help in the event that if we have implemented correctly for catching parity error. But can not work, because no one has tested implementation. :)

          Please update library and check now.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved