ABSTRACT

This chapter provides a complete example of how a complete and fully working embedded system can be assembled exclusively from open-source components, including the C-language software development toolchain used to build it. The internal organization of the FreeModbus protocol stack is based on a layered design. Only a single mutual exclusion domain must be provided for the whole protocol stack, because FreeModbus critical regions have been kept very short, and hence, unnecessary blocking has been reduced to a minimum. Since part of Modbus requests handling is application-dependent, the event handling function just mentioned works in concert with appropriate callback functions that must be implemented at the application layer. In order to facilitate callback development, the FreeModbus protocol stack provides callbacks for the most common Modbus requests. The performance of the Modbus slave protocol stack has been evaluated by exercising it using a matching Modbus master implementation.