I've been working on a small C# program to enable hardware in loop simulation with FSX. It's working nicely now, so I've posted the code up at http://code.google.com/p/fsxio/
I've been using it to test my Android autopilot (subject for another blog post when I get around to it), but I've designed it so it should be easily adaptable to other projects. It communicates with FSX using the simconnect API, and sends the sim data via UDP using the X-Plane 10 binary protocol, with the same units and axis conventions as X-Plane (so I can re-use the same parsing code). Only difference is instead of a "DATA" header, it sends "FSX!" in the first 4 bytes of each packet. The sim data output in this version are: latitude, longitude, true altitude, groundspeed, indicated airspeed, body-fixed-frame accelerations, body rotation rates, roll, pitch, true heading, magnetic heading, and gps ground track.
For input, it listens on port 49005 for incoming UDP packets, and sends the received aileron/elevator/throttle/rudder positions to FSX. I use the mini-SSC protocol for the control data, because it's really simple (255 for sync byte, channel from 0-3, position from 0-254).
Data are sent each simulation frame, which is usually faster than the graphically rendered frames. Ideally FSX simulates at 63 hz, but sometimes dips to 40-50 hz on my core2 duo machine. I couldn't figure out how to get useful body-frame accelerations directly from FSX, so instead I take the world velocities, differentiate to get accelerations, then build a rotation matrix with the sim roll/pitch/heading, and rotate the earth-frame acclerations into the body frame. It's a bit inelegant, but works well. There is some noise on the resulting acceleration values, but it's less than a typical MEMS accelerometer and works fine in the DCM algorithm. I've also included a simple model for gyro noise and bias drift.
If you want to play with/modify it, check out the entire directory and it *should* compile....
Here's a quick video of the setup doing it's thing: http://www.youtube.com/watch?v=zdPcyU4q6AQ&feature=youtu.be