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. QtSerial bytesAvailable rejecting 0 in Data bits
Forum Updated to NodeBB v4.3 + New Features

QtSerial bytesAvailable rejecting 0 in Data bits

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.1k 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.
  • D Offline
    D Offline
    Dharmendra
    wrote on last edited by
    #1

    hello Sir,
    I am doing MODBUS based project and i have to manupulate with data contating ' 0 ' but when my program get ' 0 ' it terminates the further inputs ; Function
    @
    char String[11]={0x05,0x04,0x01,0x01,0x01,0x0A,0x71,0x89,0x00,'\0'};

    int avail =port->bytesAvailable(); // is also providing the value upto it contain some value;
    @

    Here the Avail value is 8 but when String Contating 0x00
    @
    char String[11]={0x05,0x04,0x00,0x00,0x00,0x0A,0x71,0x89,0x00,'\0'};
    @
    it terminates at after 5,4 and at output I am getting only 5,4 so please provide some help;

    My Code is :
    @
    void Dialog::onReadyRead()
    {

    if (port->bytesAvailable()) 
    

    {
    int avail=port->bytesAvailable();
    QByteArray data = port->readAll();
    for(int i=0;i<8;i++)
    {
    test[i]=data[i]+48;
    }
    ui->stringOne->setText(test);
    ui->stringTwo->setNum(avail);
    }
    }
    @

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Please don't post multiple threads on the same topic, you are already getting answer in "this one":http://qt-project.org/forums/viewthread/31174/

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      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