2015-11-05 07:32 AM
Good afternoon everyone,
I am fairly new to this forum.So hi everyone :) I am a young electronics and embedded systems engineer, used to driver dev but really a noob when it comes to internet networks understanding.I am looking for a running example of modbus tcp on stm32f4.
I must add that I allready ported and recompiled lwIP and I am actually hosting a webserver on stm32f4. I am using the DP83848 PHY. So basically wondering if anyone allready found a modbus tcp (using lwIP or not)I am using stm32workbench IDE.The thing is that, if I was able to adapt a running example of a lwIp port for stm32 on the stm32f4 discovery board using external DP83848 PHY, I don't know were to start to from to port modbus tcp, to lwIP. I am having hard time understanding the stack. I wonder how to receive a tcp packet, how the lwIp stack handles it, and simply if the lwIp stack can handle modbus tcp.
I was hoping someone allready did that and could help me or share examples.Any help will be really appreciated.Thank you all #modbus-tcp-lwip-stm32f4-dp834842015-11-05 10:45 AM
Implementing Modbus (or any other protocol) isn't dependent on the PHY you are using, it's strictly software once the Ethernet interface is passing messages reliably.
I haven't tried Modbus over TCP yet but the general idea is to create a Listener task for incoming messages. This assumes you are responding to an external control system that issues requests. In the TCP/IP stack there should be some form of portmapper that redirects incoming messages to a Listener task based on protocol (TCP or UDP, or both) and port number. From that point on it's up to you to handle the messages, establish a TCP connection if needed, and send back replies. A good example to look at is how FTP is implemented, where UDP establishes a connection on a known port, and then the session is moved to a dynamic port on TCP. Jack Peacock2015-11-11 03:37 AM
Hi,
You can use the Free MODBUS stack available from freemodbus <dot> orgAlso go through the ''Demo'' folder inside it to understand the standard design for MODBUS TCP (MCF5235TCP would be helpful).Then use TCP raw api calls to connect MODBUS stack to your LWIP stack.Hope this helps.Regards,UPatro