Main Menu

search

You are here

GMCGUI RS485 software

[last updated: 2024-09-04]
RS485 home page
-----

Communication on RS485 bus has no built-in error correction. All data validation must be done in software.

This is my custom code approach to the problem.
Starting from lots of online resources, notably Nick Gammon's RS485_protocol library, here's what I'll do in this project:

  • Data will be sent in packets. Each packet will be composed of:
    • a start byte ("\2")
      This is ctrl-B, "start-of-text", STX, decimal=2, hex=2
    • a one-byte address of destination node
    • a one-byte address of sender node
    • a one-byte byte-count of how many bytes in the message
      (just the message, ie. not counting start, destination, sender, byte-count, stop, or crc bytes)
    • some number of bytes (248 bytes max?) of actual message
    • one-byte crc (cyclic redundancy check) of just the message itself.
    • stop byte ("\3")
      This is ctrl-C, "end-of-text", ETX, decimal=3, hex=3
  • Receiving nodes listen for start bytes followed by their node ID.
    • If they receive that, they will echo back their node ID.
    • Then as the message progresses, they will echo back every byte received
      • If at any time before the stop byte they happen to receive another start byte, they start over, ie. waiting for their node ID
    • When they receive the stop byte, they will collect one more byte (the crc) from the buffer
    • They will then validate the data byte count and crc.
      If it's correct (or not?), they will respond with [what message?]
    • They will then process the message and act on any instructions it's given them.
  • Transmitting nodes (initially the Master node) will:
    • send the packet, one byte at a time.
      when it sends the start byte, it will not expect a reply.
      however for every byte sent after that, including the stop and crc bytes,
      it will expect to receive an echo/response of the byte it sent.
      If it does not receive the correct echo, it will start over sending the whole packet again.
    • Once the packet is sent, it will go to receive mode, and will listen for acknowledgement of successful receipt of the message
    • if it has asked the remote node to send it some sensor data, eg, it will wait to receive it...

.

.

.

eof