Assuming you are familiar with C++, you'll probably want to check CInsim out (get the 0.6B compatible version here). See the linked tutorial programs to see how CInsim works and talks to LFS.
Feel free to search this forum section and Unofficial Addons section for some more examples.