Modbus TCP over Serial Gateway

Hello, I have a problem configuring a Modbus TCP over Serial Gateway using RS485 between a router and a Modbus server (an electric meter). The issue is that whenever I send a request from my client (running on a PC) through the gateway on the router, I consistently receive an inconsistent response that does not comply with the Modbus protocol.

The way I connected the Modbus server (electric meter) to the router is simple – I connected the meter’s terminal B to D_N and the terminal A to DP on the meter. I did not connect any other terminals. For wiring, I am using two strands from an Ethernet cable.

Using this Go library:

package main

import (
	"fmt"

	"github.com/goburrow/modbus"
)

func main() {
	handler := modbus.NewTCPClientHandler("10.0.0.1:5022")
	handler.SlaveId = 1

	err := handler.Connect()
	if err != nil {
		fmt.Printf("%v\n", err)
	}
	defer handler.Close()
	client := modbus.NewClient(handler)

	results, err := client.ReadHoldingRegisters(50, 2)
	if err != nil {
		fmt.Printf("%v\n", err)
	}
	fmt.Printf("results %v\n", results)
}

I am trying to query my meter for data. Unfortunately, although the router’s graphical interface indicates that the request was successfully converted from TCP to serial and back from serial to TCP, I receive a different response from the router each time.

What I have already tried:
• Connected a different meter to the router – the result was the same.
• Used another Go library – the result was the same.
• Swapped A and B on RS485 – each time I got a timeout.
• Disabled all services in the router’s service list – the result was the same.

Attached are screenshots of the router setting. I cannot send a Wireshark capture containing the communication because new users cannot add attachments. Below, I paste some of the bitwise responses I received back from the router:

000100000003010304
0001000000050103044248
00010000000301a84a

[grid]Processing: Zrzut ekranu 2025-01-14 o 14.00.29.png…




(upload://ntgCks4fMOYLKExpycaEUAL3Sp3.png)
Processing: Zrzut ekranu 2025-01-14 o 14.00.18.png…

[/grid]

@mrrav3n Hello,

Apologies for the delayed response.

I recommend testing with the Modbus Serial Client (RTU) service on the RUT. If you configure it and can successfully read the registers, the issue is unlikely to be on the serial side. However, if you are unable to read the registers, the problem may be related to physical wiring.

For Modbus TCP over Serial, try using tools like QModMaster, ModRSim2, or Modbus Poll. If these applications can read the data successfully, the issue may be related to your code or library.

Kind Regards,

This topic was automatically closed after 60 days. New replies are no longer allowed.