Hi,
I have a few questions and hope you can help me with that. I am writing a C-program and use the MS Flight Simultor 2002 and FSUIPC version 2.87. The program starts the Flight Simulator, gives it 200 ms and stops it. For that I use the offset 0262. For pause I write 1 and for un-pause I write 0 to it. This works but it takes too long to set or unset the pause (50 ms on average). So I try to find a faster way to set or unset the pause.
First I tried to write a faster setPause function in the IPCUser.c file (see below).
void
FSUIPC_setPause(gboolean bval)
{
DWORD *pdw;
DWORD dwError;
FS6IPC_WRITESTATEDATA_HDR *pHdr = (FS6IPC_WRITESTATEDATA_HDR *) m_pNext;
// Initialise header for write request
pHdr->dwId = FS6IPC_WRITESTATEDATA_ID;
pHdr->dwOffset = 0x0262;
pHdr->nBytes = 1;
// Copy in the data to be written
CopyMemory(&m_pNext[sizeof(FS6IPC_WRITESTATEDATA_HDR)], &bval, 1);
// Update the pointer ready for more data
m_pNext += sizeof(FS6IPC_WRITESTATEDATA_HDR) + 1;
ZeroMemory(m_pNext, 4); // Terminator
m_pNext = m_pView;
SendMessageTimeout(m_hWnd, m_msg, m_atom, 0, SMTO_BLOCK, 2000, &dwError);
if (dwError != FS6IPC_MESSAGE_SUCCESS) {
MDL_WARNING("ERROR setting MS/FS to pause.");
return;
}
// Decode and store results of Read requests
pdw = (DWORD *) m_pView;
*pdw = 0;
m_pNext = m_pView;
return;
}
That works, but I still have the problem that it takes too long. With the command
SendMessageTimeout(m_hWnd, m_msg, m_atom, 0, SMTO_BLOCK, 2000, &dwError);
you can set the time, the system is waiting for set or unset the pause (2000 ms by default). I set this value to 0 but it doesn't have any effect. Perhaps someone of you know why or where I make a mistake.
My second idea was to suspend all FS threads after 200 ms and then, if the FS should get the next 200 ms, resume all FS threads. Unfortunately it doesn't realy work. Somehow the FS notices that its threads where suspended and tries to retrieve this time. Does anyone know how the FS notices the suspending of its threads?
I hope you have any ideas and can help me with my problems. Thanks! [/code]