Giter Club home page Giter Club logo

Comments (7)

karlp avatar karlp commented on August 27, 2024

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.

 avatar commented on August 27, 2024

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.

tanmayee30 avatar tanmayee30 commented on August 27, 2024

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.

007-akash avatar 007-akash commented on August 27, 2024

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.

karlp avatar karlp commented on August 27, 2024

@007-akash this is a closed issue, if you have a new issue, please make a new issue.

from pymodbus.

007-akash avatar 007-akash commented on August 27, 2024

What do u mean by closed issue. Is it solved already or cannot be solved?

from pymodbus.

dhoomakethu avatar dhoomakethu commented on August 27, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.