Comments (7)
Are you actually desiring unit 1?
Do you want to use register or address numbering? (0 based or 1 based?)
What logging do you get when you use the logging from the examples?
On 07/30/2014 06:17 PM, Haoming Wang wrote:
Hello, I want to read and print the values stored in holding registers 00 to 04,
and I succeeded with Modpoll, but when I tried with this code in python, the
result is None#!/usr/bin/env python
from pymodbus.client.sync import ModbusSerialClient as ModbusClient
client=ModbusClient(method='rtu',port='/dev/ttyUSB0',baudrate=9600,timeout=1)
client.connect()response=client.read_holding_registers(0,4,unit=1)
print response
client.close()Could you give a hand on this issue? tks in advance
—
Reply to this email directly or view it on GitHub
#50.
from pymodbus.
My device's slave id is 1, so I think 'unit' should be 1. According to the documentation, it is 0 based.
I try this code today without changing anything, and the result is different, which is 'ReadRegisterResponse (4)',
its type is :class 'pymodbus.register_read_message.ReadHoldingRegistersResponse'
I just add a sentence: "print response.getRegister(number of the register)" and I succeed in reading its value! Thanks for your help.
from pymodbus.
Hello,
I have successfully got the register values using code:
code:
`
import pymodbus
import serial
from pymodbus.pdu import ModbusRequest
from pymodbus.client.sync import ModbusSerialClient as ModbusClient
#initialize a serial RTU client instance
from pymodbus.transaction import ModbusRtuFramer
#!/usr/bin/env python
#from pymodbus.client.sync import ModbusSerialClient as ModbusClient
client=ModbusClient(method='rtu',port='/dev/ttyUSB0',baudrate=9600,timeout=1,parity='N')
client.connect()
response=client.read_holding_registers(0004,6,unit=1)
print response.getRegister(0); // This returns value of only one register
print response.registers[0:] // This returns the response for whole length of registers
client.close()
`
hope it will be helpful.
from pymodbus.
I have used the same process above. But I have 3 slaves and having different sets of holding registers. I want to create an event on one slave that if one of its holding register is high it master should process it first and then it will process the rest slaves holding registers.
How can i do it.
Any help will be highly appreciated.
from pymodbus.
@007-akash this is a closed issue, if you have a new issue, please make a new issue.
from pymodbus.
What do u mean by closed issue. Is it solved already or cannot be solved?
from pymodbus.
@007-akash You will have come with your own business logic to achieve what you are asking. You can refer to the example callback_server. It may not be something that is a solution right out of the box for your but atleast should give you some hints on how to go ahead. Again , as I said in the beginning (if I understand correctly) your query falls out of the scope of pymodbus . If you think this is something Pymodbus should support, request you to create a new issue with more details as the status of this issue is Closed
.
from pymodbus.
Related Issues (20)
- Message_Parser example not working on latest pymodbus release HOT 1
- Remove compare old/new encode in framer buildPacket. HOT 1
- Sporadic response decoding failures HOT 5
- Exception on read when no connection (self.transport is None). HOT 6
- Runtime Error when init AsyncModbusTcpClient outside of an running event loop HOT 2
- attached to a different loop HOT 1
- Pymodbus StartAsyncSerialServer serves only 1 result from datastore even when many are requested HOT 1
- Missing TLS certificate validation HOT 7
- `ModbusSerialClient` does not handle `termios.error` on `connect` HOT 2
- Activate use of message.decode for framer ASCII, SOCKET, TLS HOT 1
- client_server_sync_test have become very slow on 3.12 for no reason ?? HOT 9
- off-by-one on rtu server response to a 0x03 request HOT 7
- ModbusServerRequestHandler.execute() `AttributeError: 'dict' object has no attribute 'validate'` HOT 11
- Regression of #1924 HOT 15
- rtu-over-tcp use pymodbus Ask for help HOT 8
- Add execution of actions for WriteMultipleRegistersRequest and WriteMultipleCoilsRequest HOT 10
- Hope to add a method to obtain the client's IP address on hook or callback. HOT 2
- Retrieve server timestamp HOT 4
- Build Proper Payload and write into register using Pymodbus HOT 10
- TCP client frame mismatch under heavy load HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pymodbus.