Our desktop application consists of a Mono/.NET 3.5 back end that communicates via USB with a variety of devices and a Silverlight front end that communicates with the back end via sockets. The firmware for the devices is developed in-house with C. To accelerate our development process and reduce bugs, we would like to share code between our firmware and desktop application. What tools and techniques would you suggest for us to be able to do this? Better yet, what have you successfully used in your software to solve a similar problem?
The two main things we'd like to share are the message structures that define our communication protocol and data that is currently defined through C structure/array constants. For the protocol messages, we're currently manually rewriting our message-implementing classes to match the C definitions, using the C code as a guide. For the data we share, we created a managed C++ application that links to the compiled C code then extracts the arrays' contents into an XML file.
Our techniques work, but they are less than optimal. For one, we had a multitude of bugs related to our reinterpretation of C structures as C#, due to the C code changing in parallel and programmer mistakes; we'd like to avoid this class of bugs in future development. For data sharing, I don't have a huge problem with our current solution, but the maintainer of the extraction program says that it's a painful process getting that to work properly.
We're a bit constrained on things we'll be able to change on the firmware for the devices. For one, we have a wide variety of processor architectures and embedded platforms, so the C code must remain portable. For another, the firmware runs real-time software and is constrained on available MIPS and storage space, so we cannot add anything with unpredictable or slow execution time.