Results 1 to 7 of 7

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

  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.

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,530
    Thanked 281 Times in 276 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

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

    What does it mean "does not work" ?

  3. #3
    Join Date
    Oct 2015
    Posts
    4
    Qt products
    Qt5
    Platforms
    Unix/X11

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

    Quote Originally Posted by Lesiok View Post
    What does it mean "does not work" ?
    if i send data without (hex 0xA5, 0xA9) i become proper cash-register answer...in other case - i become nothing

    how to send unsigned char (values 0-255)?
    Last edited by blackmoon; 23rd October 2015 at 07:39.

  4. #4
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,530
    Thanked 281 Times in 276 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

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

    Are you sure thar the sequence is correct (in accordance with the printer protocol) ? QSerial is only a pipe - does not analyze transmitted data.

  5. #5
    Join Date
    Oct 2015
    Posts
    4
    Qt products
    Qt5
    Platforms
    Unix/X11

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

    i am sure i send correctly and exactly that what give me cash-register service (i have succesed send my own data (with proper response) but only if they don't have chars with (int) > 127)
    i thing something is wrong with sending this data (Debian 8.0/64bits)
    1. chars, witch make problem
    2. check sum - correcty calculatedsc_jpg.jpg
    Last edited by blackmoon; 23rd October 2015 at 09:25.

  6. #6
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,530
    Thanked 281 Times in 276 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

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

    Maybe some problem similar to this ? Can You make test on another platform ?

  7. #7
    Join Date
    Oct 2015
    Posts
    4
    Qt products
    Qt5
    Platforms
    Unix/X11

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

    yes, but only on 32 bit platform

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.