modbus icon indicating copy to clipboard operation
modbus copied to clipboard

illegal function

Open Zichen0829 opened this issue 3 years ago • 1 comments

modbus: exception '1' (illegal function), function '131' Always inform there is a error. I only used very simple modbus/Tcp example like that. What's wrong with that? I also used modbus slave and choose 03 holding register.

package main

import ( "fmt" "github.com/goburrow/modbus" )

func main() { cli := modbus.TCPClient("127.0.0.1:502") res, err := cli.ReadHoldingRegisters(0, 3) fmt.Println(res) fmt.Println(err)

}

Zichen0829 avatar Oct 23 '20 05:10 Zichen0829

Did you test the device with modpoll? first test the device and be sure that data is coming from tools. then check that the addresses and quantity are right. some time, this error happened when you give wrong address. mot of devics are working with slave 1. and also check the port, maybe our port is 1000 or 1001, you can check it with telnet.

nimahkh avatar Nov 10 '20 07:11 nimahkh