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. Serial port: timestamping received bytes for splitting modbus communication
Forum Updated to NodeBB v4.3 + New Features

Serial port: timestamping received bytes for splitting modbus communication

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 262 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.
  • C Offline
    C Offline
    Cedric-air
    wrote on last edited by
    #1

    I would like to monitor and log a RS485 communication between a modbus master and a modbus slave. In this setup I can't see what bytes on the bus are from the master and what bytes are from the slave.

    In my application, there's a short pause between the end of the modbus master message, and the start of the modbus answer from the slave, and there's a longer pause between the end of the answer from the slave, and the next message from the master.

    I would like to use this timing information to split the messages, so I can then decode and log them.

    I'm using Qserialport. This works fine, all the characters that were transmitted over the bus are received correctly, but there's no timing information anymore.

    Is there a way to figure out when a serial byte has been received? Is there a mechanism to see the amount of time between the received bytes? Maybe a list of received bytes and timestamps?
    Is there a way to generate a signal after each received byte, so the slot can figure out the elapsed time?

    C 1 Reply Last reply
    0
    • C Cedric-air

      I would like to monitor and log a RS485 communication between a modbus master and a modbus slave. In this setup I can't see what bytes on the bus are from the master and what bytes are from the slave.

      In my application, there's a short pause between the end of the modbus master message, and the start of the modbus answer from the slave, and there's a longer pause between the end of the answer from the slave, and the next message from the master.

      I would like to use this timing information to split the messages, so I can then decode and log them.

      I'm using Qserialport. This works fine, all the characters that were transmitted over the bus are received correctly, but there's no timing information anymore.

      Is there a way to figure out when a serial byte has been received? Is there a mechanism to see the amount of time between the received bytes? Maybe a list of received bytes and timestamps?
      Is there a way to generate a signal after each received byte, so the slot can figure out the elapsed time?

      C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      @Cedric-air Welcome to the forum.

      Unfortunately, the general answer to your question is no. QSerialPort, and QIODevice communication is, in general, asynchronous.

      If this communication is slow enough you may find that you receive a readyRead() signal for every byte or two and that this signal emission time may be adequate to detect a comparatively long break in traffic. This would probably be fragile and depend on not blocking signal processing for any significant length of time. Using the synchronous functions in a polling thread may be another way to get closer to "real" time.

      I do not think that the QtSerialBus functionality has anything to support eavesdropping. Libcpap could probably help with Modbus over Ethernet or TCP but not, I think, over serial.

      C 1 Reply Last reply
      2
      • C ChrisW67

        @Cedric-air Welcome to the forum.

        Unfortunately, the general answer to your question is no. QSerialPort, and QIODevice communication is, in general, asynchronous.

        If this communication is slow enough you may find that you receive a readyRead() signal for every byte or two and that this signal emission time may be adequate to detect a comparatively long break in traffic. This would probably be fragile and depend on not blocking signal processing for any significant length of time. Using the synchronous functions in a polling thread may be another way to get closer to "real" time.

        I do not think that the QtSerialBus functionality has anything to support eavesdropping. Libcpap could probably help with Modbus over Ethernet or TCP but not, I think, over serial.

        C Offline
        C Offline
        Cedric-air
        wrote on last edited by
        #3

        @ChrisW67
        Thank you. I can use a logic analyzer to receive the serial waveform, and then either call sigrok to decode it for me, or do that myself in the Qt program.

        Then I know I have all the timing information I need, and i can store the raw samples of the serial connection if either the serial, or the modbus decoder reports a problem.

        https://hackaday.com/2022/03/02/need-a-logic-analyzer-use-your-pico/

        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