sfera-labs / exo-sense-py-modbus Goto Github PK
View Code? Open in Web Editor NEWModbus RTU Slave and TCP Server app for Exo Sense Py
Home Page: https://www.sferalabs.cc/product/exo-sense-py/
Modbus RTU Slave and TCP Server app for Exo Sense Py
Home Page: https://www.sferalabs.cc/product/exo-sense-py/
Hi, where can I found an example of the implementation of the Modbus slave?
For the function: def get_request(self, unit_addr_list, timeout=None)
Thanks
Hi,
Your library works perfectly! But I have a device that uses the "little endian byteorder".
How to add :
if lsb_first:
formatcode = "<" # Little-endian
else:
formatcode = ">" # Big-endian
I think I'd have to add a constant for decoding
def read_holding_registers(starting_address: int, quantity: int) -> bytes:
"""
Create Modbus Protocol Data Unit for reading holding registers.
:param starting_address: The starting address
:type starting_address: int
:param quantity: Quantity of coils
:type quantity: int
:returns: Packed Modbus message
:rtype: bytes
"""
if not (1 <= quantity <= 125):
raise ValueError('Invalid number of holding registers')
return struct.pack('>BHH',
Const.READ_HOLDING_REGISTERS,
starting_address,
quantity)
I'd like to do it but I'm not sure of my abilities !
Thank you
Hello!
First, many thanks for tweaking original pycom lib, and share on github.
I'm using the library successfully with WiPy devices as Modbus TCP server, but there's some problem I can't find under another ESP32 board (olimex ESP32-POE) with micropython v1.11.
The exact same code works without problems under WiPy, but on micropython throws this error:
Traceback (most recent call last):
File "main.py", line 47, in <module>
File "modbus.py", line 44, in bind
File "/lib/uModBus/tcp.py", line 144, in bind
TypeError: function takes 2 positional arguments but 1 were given
I've added a print over line 144:
self._sock.bind((socket.getaddrinfo(local_ip, local_port))[0][-1])
In order to see if local_ip and local_port have correct values and also checked socket.getaddrifo() returns the same tuple both with WiPy and Micropython.
At the moment I'm trying, but I'm not obtaining good results. Perhaps newer usocket library breaks something?
Best regards
Hi, I do some changes in the modbus.py, probably not implemented it correctly.
Can we communicate by email?
Where can I define Modbus slave address?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.