Results 1 to 7 of 7

Thread: QSerialPort and sending bytes (with value > 127?)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2015
    Posts
    4
    Qt products
    Qt5
    Platforms
    Unix/X11

    Question QSerialPort and sending bytes (with value > 127?)

    I have to communicate with cash-register.
    If i send data without polish diacritic chars - it works, but i have to use CP852 encoding (chars (int) value > 127 ie 0xb1 then it does not work.
    (i become from cash-register's service an example what to send and i send exacly this same)


    QString hex = "0234301c4c49541d4741546f77617220a5a91e42411e43311 e44332c30301e45332c30301e47737a74756b613742413303" ;
    QByteArray test = QByteArray::fromHex(hex.toLatin1());

    serial = new QSerialPort(this);
    serial->setPortName("ttyACM0");
    serial->setBaudRate(QSerialPort::Baud9600);
    serial->setDataBits(QSerialPort:ata8);
    serial->setParity(QSerialPort::NoParity);
    serial->setStopBits(QSerialPort::OneStop);
    serial->setFlowControl(QSerialPort::NoFlowControl);

    if(serial->open(QIODevice::ReadWrite))

    {

    qDebug()<<"Port is open!";
    if(serial->isWritable())
    {
    qDebug()<<"Yes, i can write to port!";
    }
    serial->waitForBytesWritten(-1);
    serial->write(test.data());
    serial->flush(); // Port Error 12 (timed out???)
    serial->close()
    }
    Last edited by blackmoon; 23rd October 2015 at 06:51.

Similar Threads

  1. QserialPort
    By arturs in forum Newbie
    Replies: 0
    Last Post: 13th May 2015, 20:37
  2. qserialport and reading bytes
    By gab74 in forum Newbie
    Replies: 3
    Last Post: 14th February 2014, 20:11
  3. Qt5 cmake and QSerialPort
    By Chris.Burner in forum Newbie
    Replies: 1
    Last Post: 21st April 2013, 16:13
  4. Replies: 4
    Last Post: 23rd October 2012, 08:40
  5. Replies: 7
    Last Post: 12th September 2011, 10:52

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.