We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I have started the uModbus tcp server on 89.223.127.70:502 for online debuging of the clients.
Available registers from 0-150 for reading and 6-150 for writing.
Code:
import logging from socketserver import TCPServer, ThreadingMixIn from collections import defaultdict from umodbus import conf from umodbus.server.tcp import RequestHandler, get_server from umodbus.utils import log_to_stream from datetime import datetime log_to_stream(level=logging.DEBUG) data_store = defaultdict(int) conf.SIGNED_VALUES = True host = '0.0.0.0' port = 502 class ThreadingServer(ThreadingMixIn, TCPServer): pass ThreadingServer.allow_reuse_address = True try: app = get_server(ThreadingServer, (host, port), RequestHandler) except PermissionError: print("You don't have permission to bind on {}".format(port)) print("Hint: try with a different port (ex: localhost:50200)") exit(1) @app.route(slave_ids=[1], function_codes=[3, 4], addresses=list(range(0, 150))) def read_data_store(slave_id, function_code, address): """" Return value of address. """ ts = datetime.now() data_store[0] = ts.year data_store[1] = ts.month data_store[2] = ts.day data_store[3] = ts.hour data_store[4] = ts.minute data_store[5] = ts.second return data_store[address] @app.route(slave_ids=[1], function_codes=[6, 16], addresses=list(range(6, 150))) def write_data_store(slave_id, function_code, address, value): """" Set value for address. """ data_store[address] = value if __name__ == '__main__': try: app.serve_forever() finally: app.shutdown() app.server_close()
The text was updated successfully, but these errors were encountered:
Is it possible to run rtu over tcp server (via raw socket or even RFC 2217) with a same data_store?
data_store
some how like that:
import serial from umodbus.client.serial import rtu serial_port = serial.serial_for_url("socket://0.0.0.0:5020")
Sorry, something went wrong.
in fact i need to start tcp ThreadingServer with rtu ADU on a different port.
ThreadingServer
is it possible
No branches or pull requests
I have started the uModbus tcp server on 89.223.127.70:502 for online debuging of the clients.
Available registers from 0-150 for reading and 6-150 for writing.
Code:
The text was updated successfully, but these errors were encountered: