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. Hardware Emulation and Delayed Function Calls
Forum Updated to NodeBB v4.3 + New Features

Hardware Emulation and Delayed Function Calls

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 773 Views 2 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.
  • webzoidW Offline
    webzoidW Offline
    webzoid
    wrote on last edited by
    #1

    I'm wanting to emulate a serial port-based piece of hardware.

    What I'm looking for, is a nice way of repeatedly executing a function (in a non-blocking fashion) with varying time-delays, simulating the varying response times of my hardware device. The response times I'm aiming for will be anywhere between 100ms and 1000ms depending on the command sent to the hardware.

    In a live system where physical hardware is connected, the communication flow is something like this:

    send command to hardware -> hardware processes command -> hardware sends data to computer
    

    In the emulated environment:

    send command to emulator -> emulator thinks for a while -> emulator passes pseudo data out via signal
    

    The key to this is that the system is non-blocking.

    Could anyone please suggest a nice Qt mechanism which could help me here?

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

      Hi
      Will the commands be overlapping ?
      I mean, it might get a few commands and need to answer them over time or is it just
      one command pr cycle ? And the data reply just need to have various respond times
      pr command. One at a time ?

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

        Hi,

        Since QSerialPort is a QIODevice, you can create a subclass of it that you will use in place of your QSerialPort when you need to emulate the hardware.

        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
        2
        • webzoidW Offline
          webzoidW Offline
          webzoid
          wrote on last edited by
          #4

          @mrjj The commands won't be overlapping - the commands work in a synchronous nature with the device only replying with data when a command is issued to it.

          There is "heartbeat" data sent from the hardware periodically but this is handled elsewhere.

          @SGaist I've already got a heirarchy in place which looks something like this:

          QObject -> BaseDevice -> SerialDevice           -> GpsDevice
                                                          -> SensorDevice
                                                          -> ...
                                -> EthernetDevice         -> NetworkSensorDevice
                                -> EmulatorDevice         -> EmulatedSensorDevice
          
          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