RTU nModbus Serial and Master -> Function code 0 not supported.

1,202 views
Skip to first unread message

nokPT

unread,
Nov 23, 2010, 12:03:16 PM11/23/10
to NModbus
I'm making a nmodbus RTU master program to communicate with several
RTU slaves (later I'll use TCP/IP also with other slaves), I just want
to read holding register.
On one computer I have nmodbus RTU master,
On another computer I’m programming nmodbus RTU slave,
I’m able to communicate OK with RTU master and mod_RSsim simulator, so
Master is working OK.

On the other hand, slave is giving a error message: “Function code 0
not supported.”
My master source is this:
comPort = New SerialPort("COM1")
comPort.BaudRate = 9600
comPort.DataBits = 8
comPort.StopBits = 1
comPort.Parity = Parity.None
comPort.ReadTimeout = 1000
comPort.WriteTimeout = 1000
comPort.Open()

Dim mbSerialMaster As ModbusSerialMaster =
ModbusSerialMaster.CreateRtu(comPort)
Dim retorno() As UShort = mbSerialMaster.ReadHoldingRegisters(Address,
2, 66)
‘ Address goes from 1 to 53
My Slave Source is this:
For i As Integer = 1 To 53
Dim unitID As Byte = i

' create modbus slave
Dim slave As ModbusSlave = ModbusSerialSlave.CreateRtu(unitID,
comPort)
slave.DataStore = DataStoreFactory.CreateDefaultDataStore
For r As Integer = 2 To 66 Step 2
slave.DataStore.HoldingRegisters(r) = 230
Next
Dim slaveThread As Thread = New Thread(New ThreadStart(AddressOf
slave.Listen))
slaveThread.Start()
Next

What I’m I doing wrong?

David Harris

unread,
Nov 25, 2010, 10:24:45 AM11/25/10
to NModbus
Check a few threads down for my solution to this, and a further
analysis of the real problem:

http://groups.google.com/group/nmodbus-discuss/browse_thread/thread/204339cf8c5d5fa1?hl=en

Enable logging to see if this same thing is happening to you.

nokPT

unread,
Nov 25, 2010, 1:23:41 PM11/25/10
to NModbus
I think I have a different problem.

I’ve sniffed COM1 on both my computer, and I’ve got this result:

Master sends this telegram (I’m reading Holding Register 0..66 from
address 1 to 53):
1, 3, 0, 0, 0, 65, 197, 251

Because my slave doesn’t answer, my master sends the same telegram 4
times:
1, 3, 0, 0, 0, 65, 197, 251
1, 3, 0, 0, 0, 65, 197, 251
1, 3, 0, 0, 0, 65, 197, 251
1, 3, 0, 0, 0, 65, 197, 251

Then I get a Timeout exception, and I pass to my next slave address,
it sends 4 times the same telegram, gets, timeout…

My slave never answers to any request, then after some seconds it get
“Function code 0 not supported” exception.

I’ve made the same test with Modbus simulator, and it works ok, after
1st telegram it relays with all data, then my master passes to next
slave address, slave relays, everything is ok.

I’ve tried with different COM1 configuration (Handshake, RTS (it is
enable on the simulator).

I’ve got always the same result (no nmodbus master-slave RTU
comunication).


On 25 Nov, 15:24, David Harris <davidrosshar...@gmail.com> wrote:
> Check a few threads down for my solution to this, and a further
> analysis of the real problem:
>
> http://groups.google.com/group/nmodbus-discuss/browse_thread/thread/2...

nokPT

unread,
Dec 7, 2010, 5:18:44 AM12/7/10
to NModbus
No body?
Reply all
Reply to author
Forward
0 new messages