cancel
Showing results for 
Search instead for 
Did you mean: 

modbus tcp port lwIP stack on stm32f4 with DP83848 PHY

franck2399
Associate
Posted on November 05, 2015 at 16:32

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-dp83484
2 REPLIES 2
jpeacock
Associate II
Posted on November 05, 2015 at 19:45

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 Peacock
umakanta
Associate II
Posted on November 11, 2015 at 12:37

Hi,

You can use the Free MODBUS stack available from freemodbus <dot> org

Also 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