Home > Software design >  Qt c Issue receiving data weighing scale Ohaus aviator 7000
Qt c Issue receiving data weighing scale Ohaus aviator 7000

Time:12-19

I am trying to establisch a serial port connection to my Aviator 7000 weighing scale using Qt c . The expected result would be a succesfull communication through the use of a byte command. Sadly I don't receive any bytes back from the scale. below you can find what I tried so far:

    const int Max_attempts = 5;
    const int Max_sleep = 125;

    int attemps;
    attemps = 0;
    while (true)
    {

        int enq {5};
        QByteArray bytes;
        bytes.setNum(enq);
        m_serial->write(bytes);

        m_serial->waitForReadyRead(Max_sleep);

        if (m_serial->bytesAvailable() !=0)
        {
            qDebug() << m_serial->bytesAvailable() ;
            qDebug() << "connected" << m_serial->readAll();
            break;
        }

        attemps  = 1;

        if (attemps == Max_attempts)
        {
            qDebug() << "no connection established";
            break;
        }
    }

Kind regards, Tibo

CodePudding user response:

According to this manual you are supposed to send a byte 0x05 but you are sending 0x35 (the character "5").

Use

bytes.append('\X05');
  •  Tags:  
  • c qt
  • Related