Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website

  • Hi, I want to specify the value of slave id , but when I execute the following code, I get an exception "com.serotonin.modbus4j.exception.ModbusTransportException: Invalid slave id".

    If slave id is less than 248?it will be OK.

    Is there a problem with the code? or slave id can not be greater than 247 ?

    int slave_id=255;
    ModbusRequest req = new ReadInputRegistersRequest(slave_id, 0, 5);
    ReadInputRegistersResponse rep = (ReadInputRegistersResponse) mp.send(req);

    Thanks


  • As I recall Modbus only has an 8-bit address, so one master can only talk to 255 slaves via 1 port, so valid addresses are in the range 0..247 where 0 is used as a broadcast address.

    However you can use another port, though.

    If have any doubts about it I recommend you google for modbus documentation.


  • Actually, max slave id is 240.


  • Thanks for fmunhoz's recommendation.

    In MODBUS Messaging on TCP/IP Implementation Guide, it says that

    On TCP/IP, the MODBUS server is addressed using its IP address; therefore, the MODBUS Unit Identifier is useless. The value 0xFF has to be used.

    When addressing a MODBUS server connected directly to a TCP/IP network, it’s recommended not using a significant MODBUS slave address in the “Unit Identifier” field. 0xFF is recommended for the “Unit Identifier" as non-significant value.

    But 0xFF is greater than 247 (decimal), how can I assign 0xFF to the slave device address?


  • @mlohbihler said:

    Actually, max slave id is 240.

    really?

    Is it not assigned from 1 to 247 (decimal) ?


  • @HenryDUT said:

    Thanks for fmunhoz's recommendation.

    In MODBUS Messaging on TCP/IP Implementation Guide, it says that

    On TCP/IP, the MODBUS server is addressed using its IP address; therefore, the MODBUS Unit Identifier is useless. The value 0xFF has to be used.

    When addressing a MODBUS server connected directly to a TCP/IP network, it’s recommended not using a significant MODBUS slave address in the “Unit Identifier” field. 0xFF is recommended for the “Unit Identifier" as non-significant value.

    But 0xFF is greater than 247 (decimal), how can I assign 0xFF to the slave device address?

    Who can help me?


  • Is the slave id actually causing problems for you?


  • Amazing. Here i have PLC General Electric F650, with slave Modbus TCP and the slave id is 254 (HEX FE). Great job Modbus4J assuming a slave id between 0 to 247. JAR to TRASH


  • I will refer you to the protocol specification.
    http://modbus.org/docs/PI_MBUS_300.pdf

    Page 19 (#10) is probably the page you'd be interested in, first paragraph. Some people suggest there are extra functions mapped onto units addressed 248-255, but I can't find a spec for that.

    http://www.modbus.org/docs/Modbus_over_serial_line_V1.pdf
    page 8

    http://www.modbus.org/docs/Modbus_Messaging_Implementation_Guide_V1_0b.pdf
    page 23


  • villadaniel_, since it is a PLC why don't you change its slave id to something in the range that will work?