Using Modbus on FEZ Panda

Apr 1, 2012 at 5:58 PM

I didn't have the chance to analyze the code yet but I would like o throw a simple idea at you. Would it be possible to run the Modbus library on a NET MF device that does not have native TCP ? FEZ Panda with a connect shield is an example where you have TCP using Wiznet W5100 chip. So basicaly is there any abstraction made for the transport layer?

Coordinator
Apr 5, 2012 at 3:39 PM

The library has been designed to be pretty well abstracted, so you should able to create "any" kind of transport wrapper.

I don't know how the Fez works, but if you take a look at the code, you'll see that you might swap the TCP/UDP driver with the serial one. The host can't realize the difference.

Hope it helps.

Apr 6, 2012 at 12:00 PM

The library works :) I have tested Modbus TCP master using a custom USBizi based board with Wiznet W5100 chip. It means that it will work for any other board from GHI that does not have built in Ethernet (e.g. FEZ Panda + Connect shield). There was only one thing i needed to change in the source to implement the W5100 tranport wrapper.

    /// <summary>
    /// Server-refined derivation of the data carrier
    /// </summary>
    public class ServerCommData
        : CommDataBase
    {
        public ServerCommData(IProtocol protocol, ByteArrayReader incomingData = null)
            : base(protocol)
        {
            IncomingData = incomingData;
        }
    }

You can download the source code here. Maybe it will inspire you to make even better abstraction. 

 

Coordinator
Apr 6, 2012 at 12:29 PM

Well to know that you was able to make it working with a less effort also for the Fez.

About the modification, well...yeah, perhaps could be better using an optional parameter in the ctor other than exposing the IncomingData as public. I wasn't aware of that, because in my mind any of the driver should be placed inside the same package.

Good suggestion, good news. Thank you.

Apr 6, 2012 at 8:46 PM

Feel free to use the code i provided to show people that your library is FEZ friendly (FEZ Cobra cobra has built in ethernet so no need for extra wrapper). If i encounter a project that needs modbus i will test your library more. Btw. aren't you missing socket.Bind() in TCP slave example?