pymodbus Exception Response(131, 3, IllegalAddress)
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
add a comment |
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
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 with0x40000
or0x400
(as a default in many cases)?0x40000
(hexadecimal) have different with40000
(decimal)
– Benyamin Jafari
Jan 1 at 11:55
add a comment |
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
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
python modbus pymodbus
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 with0x40000
or0x400
(as a default in many cases)?0x40000
(hexadecimal) have different with40000
(decimal)
– Benyamin Jafari
Jan 1 at 11:55
add a comment |
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 with0x40000
or0x400
(as a default in many cases)?0x40000
(hexadecimal) have different with40000
(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
add a comment |
2 Answers
2
active
oldest
votes
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)
add a comment |
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)
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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)
add a comment |
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)
add a comment |
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)
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)
answered Oct 31 '17 at 3:49
BhavinBhavin
4614
4614
add a comment |
add a comment |
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)
add a comment |
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)
add a comment |
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)
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)
edited Jan 1 at 11:56
answered Dec 10 '17 at 8:54


Benyamin JafariBenyamin Jafari
3,39332248
3,39332248
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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
or0x400
(as a default in many cases)?0x40000
(hexadecimal) have different with40000
(decimal)– Benyamin Jafari
Jan 1 at 11:55