Error in modbus-plugin: "serial: timeout"

Hello all,

I have a problem with the telegraf “modbus-plugin” running on windows with an serial connection (com2)… when running the configuration I always will get the error “serial: timeout”.

I’m in contact with the support of the manufacturer of the modbus-device and I got the manual for the modbus connection - so the settings should be correct (slave-ID and the adresses for the holding register). I also checked the serial connection with a ping 127.0.0.1 successfully. but still I got the following errors

  • [agent] Starting service inputs
  • [inputs.modbus] trying to read holding@110[1]…
  • [inputs.modbus] Error in plugin: serial: timeout
  • [agent] Stopping service inputs

what confuse me a little bit, is in the manual from the manufacturer the example for a request from the master to read a register. He added a table for that (see below). I don’t know if that could help me in telegraf or if telegraf in the background will make it in that way.
grafik

Below there is the config I’m using for the modbus-plugin

[[inputs.modbus]]
  ## Connection Configuration
  ## Device name
  name = "heatgenerator"

  ## Slave ID - addresses a MODBUS device on the bus
  ## Range: 0 - 255 [0 = broadcast; 248 - 255 = reserved]
  slave_id = 110

  ## Timeout for each request
  timeout = "2s"

  ## Maximum number of retries and the time to wait between retries when a slave-device is busy.
   busy_retries = 2
   busy_retries_wait = "100ms"


  ## Serial (RS485; RS232)
   controller = 'file:///COM2'
   baud_rate = 9600
   data_bits = 8
   parity = "N"
   stop_bits = 1
   transmission_mode = "RTU"

  holding_registers = [
    { name = "Temperature", byte_order = "AB",   data_type = "FLOAT32", scale= 0.1,  address = [110]},
  ]

  [inputs.modbus.tags]
  influxdb_database="heat"

would be great if someone from the community could support me on that topic

Greetings
Ehninchr

Hi,

This is not what I would have expected for the controller path. I would have expected something like file:///dev/ttyS2 or similar for COM2 serial port.

Can you run ls -l /dev/tty* and see what tty devices show up.

Thanks

Hello Jpowers,

thank you very much for your reply… but I work with Windows and not with Linux operating system. I followed a description I saw in a other topic in the community… may you have other idea?!

Have you tried just using controller = 'COM2'? What happens in that case?

1 Like

Hello popey,

I tried… but there is a failure message called "Error running agent: could not initialize input inputs.modbus: initializing client failed: invalid controller “COM2”

Greetings
Ehninchr

1 Like

Hey,

Had a couple other suggestions come in from folks more familiar with Windows. In addition to popey’s suggestion above can you try first enabling debug_connection = true to get some additional data. Then try some combination of the following controller settings?

controller = 'file://com2'
controller = 'file://COM2'

Assuming you know for sure that it is in fact com2 that you need to use.

Hello Jpowers,

I’m sure that its the com2 (verified also with the mainboard manual). I’m very happy for your ideas what I can test!!

About your last suggestion, I tested both variants and all will bring me the failure message “Error in plugin: The system can’t find the Path” and after that the input is stopped.

Greetings
Ehninchr

Hey,
I also checked the “debug_connection = true” and I received the following information
grafik

comparing the send message with the table above in my first post, telegraf send exactly what is listed there for each single byte.

When I asked the support from the manufacturer of the device, they told me I should ping the device. I wondered if that will work also for a serial connection, but they confirmed me that. Do you have knowledge about that and can you confirm this?

Greetings
Ehninchr

I do not know your device or any information about it. Their comment about needing to ping is not something I understand. You may want to ask for clarification about the ping, if that is required before the device shows up?

Let’s see if it even shows up as a serial connection. In powershell, can you run the following:

[System.IO.Ports.SerialPort]::GetPortNames()

That should print something like: COM1 or some additional devices.

for the power shell request

[System.IO.Ports.SerialPort]::GetPortNames()

I got the following reply
COM1
COM2
COM3

COM3 is an Virtual COM Port I use for a other device. And Com1 is free and COM2 is used for modbus connection

ok excellent to confirm that the device exists :slight_smile:

Can you try one more thing, can you increase the timeout value in your telegraf config to something larger? like 15 seconds?

My other idea was to suggest you try connecting to the device with Putty or some other client to see if it can connect.

I tried to increase the timeout value to 15 sec… but the problem is still there.

I connected with Putty to the device, but see only the empty screen. I tried to type the bytes “6e 03 00 6e 00 01 ec 88” but nothing was visualized in the putty view.
grafik

Hi Ehninchr,

We’re you ever able to fix this issue?

Hello OranMZT,

no I was not able to get it run… my modbus device is an old control and I’m not sure if the failure is on this side. From the telegraf skript I tried everything

Greetings
Ehninchr

HI Ehninchr,

I chased this up on the InfluxDB slack and had my issue request addressed on github. Sven was nice enough to create a fix thats available here :fix(inputs.modbus): Fix Windows COM-port path by srebhan · Pull Request #12339 · influxdata/telegraf · GitHub

Cheers,
Oran

@Ehninchr if you see a problem with the modbus plugin and your device, please open an issue on our GitHub project so we can chase it down. :slight_smile: