pymodbus Exception Response(131, 3, IllegalAddress)












3















I'm trying to run this piece of code:



from pymodbus.client.sync import ModbusSerialClient as ModbusClient
import logging

logging.basicConfig()
log = logging.getLogger()
log.setLevel(logging.DEBUG)

client = ModbusClient(method='rtu', baudrate=9600, parity='E', port='/dev/ttyUSB0', timeout=1)
client.connect()

rr = client.read_holding_registers(40000, 7, unit=0x01)
print rr
client.close()


But I get only this:



DEBUG:pymodbus.transaction:Running transaction 1
DEBUG:pymodbus.factory:Factory Response[131]
DEBUG:pymodbus.transaction:adding transaction 0
DEBUG:pymodbus.transaction:getting transaction 1
Exception Response(131, 3, IllegalAddress)


On the other hand this C code (using libmodbus) is working:



modbus_t *mb;
int16_t hregs[9];
mb = modbus_new_rtu('/dev/ttyUSB0', 9600, 'E', 8, 1);
modbus_set_slave(mb, 1);
modbus_read_registers(mb, 0x40000, 7, hregs)


What am I doing wrong?










share|improve this question




















  • 1





    Are you sure your libmodbus code is working? You're reading address 0x40000 (262144), no Modbus slave will accept this address.

    – Ronaldo
    Oct 21 '15 at 17:44











  • Yes, I'm sure that C code is working.

    – Dmitry Misharov
    Oct 21 '15 at 23:16











  • Did you try with 0x40000 or 0x400 (as a default in many cases)? 0x40000 (hexadecimal) have different with 40000 (decimal)

    – Benyamin Jafari
    Jan 1 at 11:55


















3















I'm trying to run this piece of code:



from pymodbus.client.sync import ModbusSerialClient as ModbusClient
import logging

logging.basicConfig()
log = logging.getLogger()
log.setLevel(logging.DEBUG)

client = ModbusClient(method='rtu', baudrate=9600, parity='E', port='/dev/ttyUSB0', timeout=1)
client.connect()

rr = client.read_holding_registers(40000, 7, unit=0x01)
print rr
client.close()


But I get only this:



DEBUG:pymodbus.transaction:Running transaction 1
DEBUG:pymodbus.factory:Factory Response[131]
DEBUG:pymodbus.transaction:adding transaction 0
DEBUG:pymodbus.transaction:getting transaction 1
Exception Response(131, 3, IllegalAddress)


On the other hand this C code (using libmodbus) is working:



modbus_t *mb;
int16_t hregs[9];
mb = modbus_new_rtu('/dev/ttyUSB0', 9600, 'E', 8, 1);
modbus_set_slave(mb, 1);
modbus_read_registers(mb, 0x40000, 7, hregs)


What am I doing wrong?










share|improve this question




















  • 1





    Are you sure your libmodbus code is working? You're reading address 0x40000 (262144), no Modbus slave will accept this address.

    – Ronaldo
    Oct 21 '15 at 17:44











  • Yes, I'm sure that C code is working.

    – Dmitry Misharov
    Oct 21 '15 at 23:16











  • Did you try with 0x40000 or 0x400 (as a default in many cases)? 0x40000 (hexadecimal) have different with 40000 (decimal)

    – Benyamin Jafari
    Jan 1 at 11:55
















3












3








3








I'm trying to run this piece of code:



from pymodbus.client.sync import ModbusSerialClient as ModbusClient
import logging

logging.basicConfig()
log = logging.getLogger()
log.setLevel(logging.DEBUG)

client = ModbusClient(method='rtu', baudrate=9600, parity='E', port='/dev/ttyUSB0', timeout=1)
client.connect()

rr = client.read_holding_registers(40000, 7, unit=0x01)
print rr
client.close()


But I get only this:



DEBUG:pymodbus.transaction:Running transaction 1
DEBUG:pymodbus.factory:Factory Response[131]
DEBUG:pymodbus.transaction:adding transaction 0
DEBUG:pymodbus.transaction:getting transaction 1
Exception Response(131, 3, IllegalAddress)


On the other hand this C code (using libmodbus) is working:



modbus_t *mb;
int16_t hregs[9];
mb = modbus_new_rtu('/dev/ttyUSB0', 9600, 'E', 8, 1);
modbus_set_slave(mb, 1);
modbus_read_registers(mb, 0x40000, 7, hregs)


What am I doing wrong?










share|improve this question
















I'm trying to run this piece of code:



from pymodbus.client.sync import ModbusSerialClient as ModbusClient
import logging

logging.basicConfig()
log = logging.getLogger()
log.setLevel(logging.DEBUG)

client = ModbusClient(method='rtu', baudrate=9600, parity='E', port='/dev/ttyUSB0', timeout=1)
client.connect()

rr = client.read_holding_registers(40000, 7, unit=0x01)
print rr
client.close()


But I get only this:



DEBUG:pymodbus.transaction:Running transaction 1
DEBUG:pymodbus.factory:Factory Response[131]
DEBUG:pymodbus.transaction:adding transaction 0
DEBUG:pymodbus.transaction:getting transaction 1
Exception Response(131, 3, IllegalAddress)


On the other hand this C code (using libmodbus) is working:



modbus_t *mb;
int16_t hregs[9];
mb = modbus_new_rtu('/dev/ttyUSB0', 9600, 'E', 8, 1);
modbus_set_slave(mb, 1);
modbus_read_registers(mb, 0x40000, 7, hregs)


What am I doing wrong?







python modbus pymodbus






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 1 at 11:53









Benyamin Jafari

3,39332248




3,39332248










asked Oct 21 '15 at 16:21









Dmitry MisharovDmitry Misharov

318




318








  • 1





    Are you sure your libmodbus code is working? You're reading address 0x40000 (262144), no Modbus slave will accept this address.

    – Ronaldo
    Oct 21 '15 at 17:44











  • Yes, I'm sure that C code is working.

    – Dmitry Misharov
    Oct 21 '15 at 23:16











  • Did you try with 0x40000 or 0x400 (as a default in many cases)? 0x40000 (hexadecimal) have different with 40000 (decimal)

    – Benyamin Jafari
    Jan 1 at 11:55
















  • 1





    Are you sure your libmodbus code is working? You're reading address 0x40000 (262144), no Modbus slave will accept this address.

    – Ronaldo
    Oct 21 '15 at 17:44











  • Yes, I'm sure that C code is working.

    – Dmitry Misharov
    Oct 21 '15 at 23:16











  • Did you try with 0x40000 or 0x400 (as a default in many cases)? 0x40000 (hexadecimal) have different with 40000 (decimal)

    – Benyamin Jafari
    Jan 1 at 11:55










1




1





Are you sure your libmodbus code is working? You're reading address 0x40000 (262144), no Modbus slave will accept this address.

– Ronaldo
Oct 21 '15 at 17:44





Are you sure your libmodbus code is working? You're reading address 0x40000 (262144), no Modbus slave will accept this address.

– Ronaldo
Oct 21 '15 at 17:44













Yes, I'm sure that C code is working.

– Dmitry Misharov
Oct 21 '15 at 23:16





Yes, I'm sure that C code is working.

– Dmitry Misharov
Oct 21 '15 at 23:16













Did you try with 0x40000 or 0x400 (as a default in many cases)? 0x40000 (hexadecimal) have different with 40000 (decimal)

– Benyamin Jafari
Jan 1 at 11:55







Did you try with 0x40000 or 0x400 (as a default in many cases)? 0x40000 (hexadecimal) have different with 40000 (decimal)

– Benyamin Jafari
Jan 1 at 11:55














2 Answers
2






active

oldest

votes


















2














I am assuming you want to read the first seven holding registers. In that case, the address to be given to the read_holding_registers function is 0. The function implicitly adds the offset of 40000 for holding registers.



So, try changing your read code to this



rr = client.read_holding_registers(0, 7, unit=0x01)





share|improve this answer































    1















    Exception Response(131, 3, IllegalAddress) means:




    A value contained in the query data field is not an allowable value for the slave. This indicates a fault in the structure of remainder of a complex request, such as that the implied length is incorrect. It specifically does NOT mean that a data item submitted for storage in a register has a value outside the expectation of the application program, since the MODBUS protocol is unaware of the significance of any particular value of any particular register.




    http://www.simplymodbus.ca/exceptions.htm






    [UPDATE]:



    Did you try with 0x40000 or 0x400 (as a default in many cases)? 0x40000 (hexadecimal) have different with 40000 (decimal)






    share|improve this answer

























      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f33264449%2fpymodbus-exception-response131-3-illegaladdress%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      2














      I am assuming you want to read the first seven holding registers. In that case, the address to be given to the read_holding_registers function is 0. The function implicitly adds the offset of 40000 for holding registers.



      So, try changing your read code to this



      rr = client.read_holding_registers(0, 7, unit=0x01)





      share|improve this answer




























        2














        I am assuming you want to read the first seven holding registers. In that case, the address to be given to the read_holding_registers function is 0. The function implicitly adds the offset of 40000 for holding registers.



        So, try changing your read code to this



        rr = client.read_holding_registers(0, 7, unit=0x01)





        share|improve this answer


























          2












          2








          2







          I am assuming you want to read the first seven holding registers. In that case, the address to be given to the read_holding_registers function is 0. The function implicitly adds the offset of 40000 for holding registers.



          So, try changing your read code to this



          rr = client.read_holding_registers(0, 7, unit=0x01)





          share|improve this answer













          I am assuming you want to read the first seven holding registers. In that case, the address to be given to the read_holding_registers function is 0. The function implicitly adds the offset of 40000 for holding registers.



          So, try changing your read code to this



          rr = client.read_holding_registers(0, 7, unit=0x01)






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Oct 31 '17 at 3:49









          BhavinBhavin

          4614




          4614

























              1















              Exception Response(131, 3, IllegalAddress) means:




              A value contained in the query data field is not an allowable value for the slave. This indicates a fault in the structure of remainder of a complex request, such as that the implied length is incorrect. It specifically does NOT mean that a data item submitted for storage in a register has a value outside the expectation of the application program, since the MODBUS protocol is unaware of the significance of any particular value of any particular register.




              http://www.simplymodbus.ca/exceptions.htm






              [UPDATE]:



              Did you try with 0x40000 or 0x400 (as a default in many cases)? 0x40000 (hexadecimal) have different with 40000 (decimal)






              share|improve this answer






























                1















                Exception Response(131, 3, IllegalAddress) means:




                A value contained in the query data field is not an allowable value for the slave. This indicates a fault in the structure of remainder of a complex request, such as that the implied length is incorrect. It specifically does NOT mean that a data item submitted for storage in a register has a value outside the expectation of the application program, since the MODBUS protocol is unaware of the significance of any particular value of any particular register.




                http://www.simplymodbus.ca/exceptions.htm






                [UPDATE]:



                Did you try with 0x40000 or 0x400 (as a default in many cases)? 0x40000 (hexadecimal) have different with 40000 (decimal)






                share|improve this answer




























                  1












                  1








                  1








                  Exception Response(131, 3, IllegalAddress) means:




                  A value contained in the query data field is not an allowable value for the slave. This indicates a fault in the structure of remainder of a complex request, such as that the implied length is incorrect. It specifically does NOT mean that a data item submitted for storage in a register has a value outside the expectation of the application program, since the MODBUS protocol is unaware of the significance of any particular value of any particular register.




                  http://www.simplymodbus.ca/exceptions.htm






                  [UPDATE]:



                  Did you try with 0x40000 or 0x400 (as a default in many cases)? 0x40000 (hexadecimal) have different with 40000 (decimal)






                  share|improve this answer
















                  Exception Response(131, 3, IllegalAddress) means:




                  A value contained in the query data field is not an allowable value for the slave. This indicates a fault in the structure of remainder of a complex request, such as that the implied length is incorrect. It specifically does NOT mean that a data item submitted for storage in a register has a value outside the expectation of the application program, since the MODBUS protocol is unaware of the significance of any particular value of any particular register.




                  http://www.simplymodbus.ca/exceptions.htm






                  [UPDATE]:



                  Did you try with 0x40000 or 0x400 (as a default in many cases)? 0x40000 (hexadecimal) have different with 40000 (decimal)







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Jan 1 at 11:56

























                  answered Dec 10 '17 at 8:54









                  Benyamin JafariBenyamin Jafari

                  3,39332248




                  3,39332248






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f33264449%2fpymodbus-exception-response131-3-illegaladdress%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      MongoDB - Not Authorized To Execute Command

                      How to fix TextFormField cause rebuild widget in Flutter

                      in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith