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. Simulate date on serial port

Simulate date on serial port

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 289 Views
  • 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.
  • ZgemboZ Offline
    ZgemboZ Offline
    Zgembo
    wrote on last edited by
    #1

    Hi,

    I am developing desktop application that needs to communicate with hardware device via serial interface. Currently I do not have the hardware device but I have read data sheet and started to develop a test application while waiting for a device. Anyway I have created small test application that opens serial port and connects readyRead signal with slot function that will do the parsing of received data.
    As per specification the device will periodically send data as 24 byte blocks like this:
    //during ablations, source is a string of 24 bytes:

    // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
    //066 128 128 166 128 144 130 128 128 180 131 168 129 248 129 128 128 128 128 128 128 173 233 000

    066 is start of the data block byte and 000 is end od the block byte.

    Because I have started to develop an app before I received the hardware device I would like to simulate the data flow. For that reason I have installed com0com to create two virtually connected serial ports (com5 and com6) and I have installed "Com port data emulator" software to simulate date. In this emulator software in data source section I choose text string and and copy all the above example bytes. But in my test application I receive this data block as 122 bytes block. Maybe I need to setup this emulator software in another way.

    My slot that handles received data is:

    qDebug() << "New data available: " << m_pSerialPort->bytesAvailable();
    QByteArray datas = m_pSerialPort->readAll();
    qDebug() << datas;

    Any suggestions?

    Thanks,
    Zgembo

    aha_1980A 1 Reply Last reply
    0
    • ZgemboZ Zgembo

      Hi,

      I am developing desktop application that needs to communicate with hardware device via serial interface. Currently I do not have the hardware device but I have read data sheet and started to develop a test application while waiting for a device. Anyway I have created small test application that opens serial port and connects readyRead signal with slot function that will do the parsing of received data.
      As per specification the device will periodically send data as 24 byte blocks like this:
      //during ablations, source is a string of 24 bytes:

      // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
      //066 128 128 166 128 144 130 128 128 180 131 168 129 248 129 128 128 128 128 128 128 173 233 000

      066 is start of the data block byte and 000 is end od the block byte.

      Because I have started to develop an app before I received the hardware device I would like to simulate the data flow. For that reason I have installed com0com to create two virtually connected serial ports (com5 and com6) and I have installed "Com port data emulator" software to simulate date. In this emulator software in data source section I choose text string and and copy all the above example bytes. But in my test application I receive this data block as 122 bytes block. Maybe I need to setup this emulator software in another way.

      My slot that handles received data is:

      qDebug() << "New data available: " << m_pSerialPort->bytesAvailable();
      QByteArray datas = m_pSerialPort->readAll();
      qDebug() << datas;

      Any suggestions?

      Thanks,
      Zgembo

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @zgembo

      Maybe I need to setup this emulator software in another way.

      Most likely. I assume you send the characters as string, not as bytes. Can this software send raw bytes?

      Regards

      Qt has to stay free or it will die.

      1 Reply Last reply
      1

      • Login

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