eGospodarka.pl
eGospodarka.pl poleca

eGospodarka.plGrupypl.misc.elektronikaMultiplekser/sniffer/arbiter modbusRe: Multiplekser/sniffer/arbiter modbus
  • Path: news-archive.icm.edu.pl!news.icm.edu.pl!newsfeed.pionier.net.pl!3.eu.feeder.erj
    e.net!2.eu.feeder.erje.net!feeder.erje.net!weretis.net!feeder8.news.weretis.net
    !news.neodome.net!feeder1.feed.usenet.farm!feed.usenet.farm!peer02.ams4!peer.am
    4.highwinds-media.com!news.highwinds-media.com!newsfeed.neostrada.pl!unt-exc-02
    .news.neostrada.pl!unt-spo-a-02.news.neostrada.pl!news.neostrada.pl.POSTED!not-
    for-mail
    Date: Wed, 5 Apr 2023 22:28:10 +0200
    MIME-Version: 1.0
    User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
    Thunderbird/102.9.0
    Subject: Re: Multiplekser/sniffer/arbiter modbus
    Content-Language: en-US
    Newsgroups: pl.misc.elektronika
    References: <u0jesg$3rbf4$1@dont-email.me>
    <4...@g...com>
    <u0kfa6$513$1@dont-email.me>
    <642dcc7b$0$19610$65785112@news.neostrada.pl>
    <u0kjt4$nps$1@dont-email.me>
    From: Piotrek <p...@p...na.berdyczow.info>
    In-Reply-To: <u0kjt4$nps$1@dont-email.me>
    Content-Type: text/plain; charset=UTF-8; format=flowed
    Content-Transfer-Encoding: 8bit
    Lines: 96
    Message-ID: <642dd9da$0$19615$65785112@news.neostrada.pl>
    Organization: Telekomunikacja Polska
    NNTP-Posting-Host: 5.173.168.10
    X-Trace: 1680726490 unt-rea-a-02.news.neostrada.pl 19615 5.173.168.10:22133
    X-Complaints-To: a...@n...neostrada.pl
    X-Received-Bytes: 4545
    Xref: news-archive.icm.edu.pl pl.misc.elektronika:779549
    [ ukryj nagłówki ]

    On 05.04.2023 21:58, heby wrote:
    >> A rzeczywisie musisz? Nie możesz sobie zrobić "man in the middle"
    >
    > Dokładnie to chcę sobie zrobić. Z tą róznicą, że nie pasywny sniffer,
    > ale aktywny arbiter, co sprowadza się do trochę większej algroytmiki
    > buforowania. Ale to tylko kwestia programistyczna, do ogarnięcia.

    Osadzone we FreeRTOS - zasadniczo samo się pisze ;-)

    >
    > Liczyłem na jakiś ... powiedzmy ... gotowiec z 3 dziurkami RS485,
    > obsługujący 2 masterów i 1 slave. Chyba nie jestem jedyny na świecie z
    > takim pomysłem ;)

    GPT twierdzi, że nie ma ;-)

    "[...]

    Unfortunately, there are no known open-source projects that implement a
    two-master, one-slave Modbus architecture. However, you can start with
    existing Modbus libraries (e.g., libmodbus, FreeModbus) and modify them
    according to the outlined approach to develop your custom solution."

    ale przyciśnięty do muru

    Are you sure there is no such open source project?

    zaczął programować w Python. LOL

    "I apologize if my previous response may have been unclear. While it is
    challenging to be aware of every single open-source project available,
    to the best of my knowledge (as of the knowledge cutoff in September
    2021), there was no specific open-source project that implements a
    two-master, one-slave Modbus architecture.

    However, you may find open-source projects that implement Modbus
    gateways or proxies, which you could adapt to achieve the desired
    two-master, one-slave communication. One such project is modbus-tk, a
    Python library that allows you to create Modbus masters and slaves, and
    it includes a TCP to Serial gateway implementation.

    Project Repository: https://github.com/ljean/modbus-tk

    Here's a basic example of how you can use modbus-tk to create a Modbus
    TCP to Serial gateway:

    python

    import modbus_tk
    import modbus_tk.defines as cst
    from modbus_tk import modbus_tcp
    from modbus_tk import modbus_rtu

    def main():
    # Configure Modbus RTU master
    master_rtu = modbus_rtu.RtuMaster(
    modbus_tk.utils.create_serial_handler(port="/dev/tty
    S0")
    )
    master_rtu.set_timeout(5.0)
    master_rtu.set_verbose(True)

    # Configure Modbus TCP server
    server_tcp = modbus_tcp.TcpServer(address="0.0.0.0", port=502)
    server_tcp.start()

    # Main loop to process Modbus TCP requests and forward them to
    Modbus RTU
    while True:
    try:
    request = server_tcp.get_request(blocking=True)
    if request is not None:
    response = master_rtu.execute(
    request.slave_id,
    request.function_code,
    request.starting_address,
    request.quantity_of_x,
    request.output_value,
    )
    request.set_response(response)

    except modbus_tk.modbus.ModbusError as exc:
    print("Error processing request:", str(exc))

    if __name__ == "__main__":
    main()

    This example creates a Modbus TCP server that forwards incoming requests
    to a Modbus RTU master. You could extend this example to support two
    Modbus TCP masters and manage the communication with the single Modbus
    RTU slave.

    Please note that this example uses Python, and you would need to adapt
    the code to your specific requirements, such as handling communication
    conflicts between the two masters."

    P.

Podziel się

Poleć ten post znajomemu poleć

Wydrukuj ten post drukuj


Następne wpisy z tego wątku

Najnowsze wątki z tej grupy


Najnowsze wątki

Szukaj w grupach

Eksperci egospodarka.pl

1 1 1

Wpisz nazwę miasta, dla którego chcesz znaleźć jednostkę ZUS.

Wzory dokumentów

Bezpłatne wzory dokumentów i formularzy.
Wyszukaj i pobierz za darmo: