2

I have a PyModbus running on a Raspberry PI 3b. I have the IF96015 Ethernet Interface for the Nemo 96HD Digital Multimeter. When I try to connect to it over ModbusTCP with the PyModbus console I can ask if it is connected and it says "true" but I cannot read any data from it.

According to the manuals the first used address is 301 and when I try to read the .Coil() I get:

"original_function_code": "1 (0x1)", 
"error": "[Input/Output] No Response received from the remote unit/Unable to decode response"

Open the Console:

pymodbus.console tcp --host 192.168.178.200 --port 502

Check for connection:

client.connect

Try to read a Coil:

client.read_coils address 301 count 1

Output:

"original_function_code": "1 (0x1)", 
"error": "[Input/Output] Modbus Error: [Invalid Message] Incomplete message received, expected at least 8 bytes (0 received)"

[NOTE]:

Manuals of the IF96015:

Manual_1

Manual_2

DJCheeky
  • 23
  • 1
  • 8

3 Answers3

1

Each Modbus slave/server has a unit_ID, so you need to add this on .read_coil() method.

In many cases unit argument is equal to 1 as default in Modbus slave side.


Here is an example (Modbus client):

pymodbus.console tcp --host 192.168.178.200 --port 502
client.connect
client.read_coils address=301 count=1 unit=1

Here is another example with multiple reading with .read_holding_registers() and its decoder:

client.read_holding_registers count=4 address=9 unit=1
{
    "registers": [
        60497,
        47134,
        34091,
        15424
    ]
}


result.raw
{
    "registers": [
        15626,
        55203,
        28733,
        18368
    ]
}

result.decode word_order=little byte_order=little formatters=float64
28.17

[NOTE]:

  • read_coil() read/write digital values (1 bit)
  • read_holding_registers() read/write analog values (16 bits)
  • Some address are hexadecimal (maybe 0x301 instead 301)
  • Don't forget = after each argument like this (count=1 instead of count 1)
Benyamin Jafari
  • 27,880
  • 26
  • 135
  • 150
  • Could you determiniert in the Manual 2 wheiter 301 is a Register or a coil? – DJCheeky Oct 21 '18 at 09:40
  • When I try client.read_holding_registers I get this > client.read_holding_registers address=301 count=1 unit=1 { "original_function_code": "3 (0x3)", "error": "[Input/Output] Modbus Error: [Invalid Message] Incomplete message received, expected at least 8 bytes (0 received)" } > – DJCheeky Oct 21 '18 at 09:52
  • And with 0x301 I get: > client.read_holding_registers address=0x301 count=1 unit=1 ValueError("invalid literal for int() with base 10: '0x301'",) – DJCheeky Oct 21 '18 at 09:53
  • It is the same as with the registers – DJCheeky Oct 21 '18 at 10:15
  • Is your example with the Multiple Registers for this Device? – DJCheeky Oct 21 '18 at 10:16
  • So your problem may be in the address, I'll read the manual_2 – Benyamin Jafari Oct 21 '18 at 10:20
  • No, I tested it with a Delta_PLC and Delta_gateway, that these are Modbus TCP, but I know about that registers address and read count and unit_ID – Benyamin Jafari Oct 21 '18 at 10:21
  • Ah ok so I should be a Address mistake? – DJCheeky Oct 21 '18 at 11:45
  • I think it maybe yes. – Benyamin Jafari Oct 21 '18 at 11:50
  • I have tried > client.read_device_information { "original_function_code": "43 (0x2b)", "error": "[Input/Output] No Response received from the remote unit/Unable to decode response" } > so there is no address wich could be wrong but I get the error to – DJCheeky Oct 21 '18 at 12:20
  • try with the `--verbose` option and share the logs. – Sanju Oct 24 '18 at 03:40
  • It could be that you are using the wrong address, the offset is in hex and the console takes the values as plain int , so you will have to explicitly convert the hex to int and use the offset (`0x301 == 769`) – Sanju Oct 24 '18 at 03:45
  • @DJCheeky check the "Sanju" comments. – Benyamin Jafari Oct 24 '18 at 05:07
1

In Manual 2, the address is 0x301 hex. Try client.read_coils address = 769 count = 1. Addresses should be given in decimal format (hex 0x301 = dec 769).

JoSSte
  • 2,953
  • 6
  • 34
  • 54
Mirek
  • 11
  • 1
0

I have found a solution to this. The problem is in the default value for the unit ID. The manual which can be found at the vendor's website shows an example Modbus TCP packet format with unit ID value set to "1".

But the factory setting for unit ID is "255". You can change the default address in a menu, password 3002. Now, I can read values with the following Python code:

message = tcp.read_holding_registers(slave_id=255, starting_address=0x1000, quantity=6)
response = tcp.send_message(message, sock)
MarSarK
  • 16