Modbus bridge

51 views
Skip to first unread message

Carlos Tangerino

unread,
Dec 6, 2015, 3:25:04 AM12/6/15
to libmodbus
Hi.
My box is connected to a downstream serial devices and I want to share the connection with other masters in the upstream network.
So I'll also be a tcp slave and will redirect transparently the request to the downstream devices and reply back to the sender.

modbus_receive (tcp_ctx)
    strip tcp header
    modbus_send_raw_request (rtu_ctx)
    modbus_receive_confirmation (rtu_ctx)
    strip crc
    add tcp header back
send message to client (tcp_ctx).  <-- WHAT FUNCTION HERE??

It turns that I did not find any API that allows me to send a raw answer since I'd like to reply with the original tcp header. modbus_send_raw_request send a request with tcp header with all zeros.

I saw some hacks but none were ported to the library and I do not want to distribute hacked library code.

Thanks for the help.
Carlos
    

Carlos Tangerino

unread,
Dec 9, 2015, 8:25:00 AM12/9/15
to libmodbus
No one can send me a tip here?

Francisco Ares

unread,
Dec 9, 2015, 11:20:18 AM12/9/15
to libm...@googlegroups.com
-12-09 11:25 GMT-02:00 Carlos Tangerino <carlos.t...@gmail.com>:

--
Vous recevez ce message, car vous êtes abonné au groupe Google Groupes "libmodbus".
Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse libmodbus+...@googlegroups.com.
Pour obtenir davantage d'options, consultez la page https://groups.google.com/d/optout.


Hi,

As far as I could understand Modbus, if you set up your box correctly, you don't need to care about other masters, they will work as expected.

Perhaps you should set up your box as a master to the downstream devices, and as a slave to the upstream ones.

Good luck and best regards,
Francisco

Carlos Tangerino

unread,
Jan 15, 2016, 1:05:39 AM1/15/16
to libmodbus
My box does not act as a modbus slave, I use the library to scan devices connected to the serial line only (it a master)
But other services in the network may want to read some devices information and my box is in the middle, so I need to: 
1 Act as slave in the LAN port to read an generic request (any command, any node, etc), 
2 Remove the modbus/tcp header (save it for later use), redirect the function. node, payload and CRC to the serial port
3 Wait for the reply
4 Add the original modbus/tcp header received in 2 to the serial, and send back the reply  to the system in the LAN port.

What I'm looking for is a function to perform the action in 4
May be expose the send function to the user?

Thanks and best regards

Carlos

Carlos Tangerino

unread,
Feb 3, 2016, 2:36:13 PM2/3/16
to libmodbus
Any good soul could give a bit of help on this please.
Thanks in advance
Reply all
Reply to author
Forward
0 new messages