Port of FreeModbus Libary for mbed

I have begun porting the FreeModbus Libary (http://freemodbus.berlios.de/) for the mbed.

So far modbus functions 3,4,6 & 10 for modbus RTU have been implemented.



10 Feb 2011

Hi, I was looking at this code for possible use in ModbusTCP mode. When I enable the TCP mode the compiller can't find the mbtcp.h file, it's missing from the install. Has the TCP mode been tested?


10 Feb 2011

G'day John,

I have not had a requirement for Modbus TCP as yet, so have never gotten around to trying to implement it.  I'm not sure that I will be having time to revisit this project any time soon.  I will be interested to hear if you are able to get TCP mode working.  Good luck!



09 May 2011

Hi Cam,

Wondered if you'd care to share something on how do a simple "Hello World!" type of test of MODBUS RTU using your port of FreeMODBUS? Is there something on the web you can point me to help? What MODBUS testing software would you recommend? I appreciate your help.



09 May 2011


have anyone implemented MODBUS TCP yet ?



Vatsal Shah

22 Jul 2011


Still wondering if anyone has implemented MODBUS TCP using FreeMODBUS? I've tried but have been unsuccessful in getting the FreeMODBUS TCP code to compile with any of the mbed network libraries. Any hints really welcomed.



10 Mar 2014

Has anyone run the demo application, I'm a bit confused about the results I'm getting.

I'm using the demo as-is currently and using qmodmaster as the PC client. The demo defines 4 registers that should begin at address 1000, however the "zeroeth" register, the one that counts, is located at 999. Is there a +1 offset convention in modbus?

Also the demo doesn't seem to generate errors properly. I'm not sure how errors should be returned but accessing totally unimplimented features does error but out-of-range registers return nonsense values.

10 Mar 2014 . Edited: 10 Mar 2014

Hello Oliver,

I've not tried the demo but MODBUS does normally specify that the address for teh MODBUS access is +1 compared to the physical addess, so you'd need to ask for a read from 1001 to read registers 1000,1001,1002,1003.

This is even more confusing when you're actually looking at the MODBUS messages on the raw comms layer!



10 Mar 2014

Looks as if the library has it the other way round, it clearly adds 1 to the incoming address as I've found the "++" operation responsible. I can see how MODBUS could have a convention that "public" addresses start from 1 not 0.

I'm using QModMaster as the client and I can see from its debug output that it outputs addresses as-is, without offset. I wonder if maybe some clients don't? Maybe the convention is for the client to subtract 1, and the library is written to reverse this?

IMO the library ought to pass on the address as-is and if there is an offset it should be documented as a programming requirement.

08 Sep 2015
Hi Cam! Thanks for the modbus program! The http://mbed.org/users/cam/programs/Modbus/5zdqv program is compiled with errors for my k64f target. Does anyone have a solution to this problem ?? The error is: #error directive: "CMSIS Target not recognised #error: "CMSIS Target not recognised Thanks!
20 Jul 2016
Hi magnus e, Have you tried to right click and update it?
29 Sep 2017
hello cam I was wondering if you do not have a simple example of how to use this library, since I have several doubts about it and I do not know how to proceed to implement this communication.

Please log in to post a comment.