-
Data: 2023-04-05 22:28:10
Temat: Re: Multiplekser/sniffer/arbiter modbus
Od: Piotrek <p...@p...na.berdyczow.info> szukaj wiadomości tego autora
[ pokaż wszystkie 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.
Następne wpisy z tego wątku
- 05.04.23 22:44 heby
- 05.04.23 23:02 Piotrek
- 06.04.23 08:47 Dawid Rutkowski
- 06.04.23 09:28 heby
- 06.04.23 11:17 Dawid Rutkowski
- 06.04.23 11:23 heby
- 06.04.23 11:56 Dawid Rutkowski
- 06.04.23 12:12 heby
- 06.04.23 13:45 Dawid Rutkowski
- 06.04.23 14:33 heby
- 06.04.23 14:47 Dawid Rutkowski
- 06.04.23 15:47 heby
- 06.04.23 16:09 Dawid Rutkowski
- 06.04.23 16:19 heby
- 06.04.23 16:36 Dawid Rutkowski
Najnowsze wątki z tej grupy
- Re: Kompensacja mocy biernej przy 230VAC
- Re: Kompensacja mocy biernej przy 230VAC
- RCD wybija
- Re: Kompensacja mocy biernej przy 230VAC
- Łożysko ślizgowe - jaki olej
- Re: Kompensacja mocy biernej przy 230VAC
- Re: Kompensacja mocy biernej przy 230VAC
- Współczesny falomierz
- Zasilacz 7V na szynę DIN
- Waga z legalizacją
- Wietnam wykłada 500M$ i chce zbudować fabrykę za 50G$
- Pendrive zdycha, czy coś jeszcze innego? Problem z plikami.
- Odkurzacz Smapp Dynamic - dawny Zelmer
- Nagra IV i zewnętrzny pilot
- Fejk muzyczny czy nie fejk
Najnowsze wątki
- 2025-03-31 Kraków => IT Expert (Network Systems area) <=
- 2025-03-31 Białystok => NMS System Administrator <=
- 2025-03-31 Częstochowa => Product Manager - Systemy infrastruktury teleinformaty
- 2025-03-31 Sąd/Sędzia odrzuca wniosek o 30d aresztu Ziobry i jedzie po PO-Komisji Sroki [i Ziobrze w GW wersji]
- 2025-03-31 Warszawa => Sales Executive / KAM <=
- 2025-03-31 Warszawa => International Freight Forwarder <=
- 2025-03-31 Re: Państewko prawka Rumunia czyli pokaz UE leworządności - lider unieważnionych wyborów niedopuszczony do powtórki
- 2025-03-31 Dęblin => JavaScript / Node / Fullstack Developer <=
- 2025-03-31 Re: Kompensacja mocy biernej przy 230VAC
- 2025-03-31 Re: Kompensacja mocy biernej przy 230VAC
- 2025-03-31 Wrocław => Senior Backend Developer <=
- 2025-03-31 Białystok => Generative AI Engineer <=
- 2025-03-31 China-Kraków => Key Account Manager IT <=
- 2025-03-31 Prawne ciekawostki: Ksiądz KRK wygrał ze swoim biskupem sprawę o "naruszenie dóbr osobistych" [SN oddalił kasacje]
- 2025-03-31 Podatek od "konta wspólnego"