Daniel0175 Posted March 4, 2017 Report Posted March 4, 2017 Hi, I'm using the Fsuipc_MFC in my C++ application. Everything work fine with Fsuipc communication. My only problem is i need to read in loop a lots of offset. These offset are modify in an external program (SIOC for OpenCockpits IoCards). So i need to verify in a loop if the value of the offset as change. because the big quantity of reading, i've create a thread only for these action. The time that i read all the offset, it take a few second to pass all the offset and start again at the top of the list. i'll try to perform the process() once at every 20 read request. It help a bit but not much. here the function that i'll create to read the offset: void SimFsuipc::SimFsuipcRead(DWORD dwOffset, DWORD dwSize, long *pDest) { CFSUIPC FSConnection; static int Count = 0; FSConnection.Open(Result); if (FSConnection.GetResultMessage() != 0) { cout << FSConnection.GetResultMessageString() << endl; } if (!FSConnection.ReadAndProcess(dwOffset, dwSize, pDest)) //if (!FSConnection.Read(dwOffset, dwSize, pDest)) { FSConnection.GetResultMessage(); cout << FSConnection.GetResultMessageString() << endl; } else { Count++; } /*if (Count >= 20) { FSConnection.Process(); Count = 0; }*/ cout << *pDest << endl; } You will find in the attach file my file that is using my function. Don't forget that these offset are modify in a extern program and that why i need to read them as fast as possible. What should i do or what method do i need to use to upgrade my reading speed? Thank you for your help! Daniel SimFsuipc_OffsetRead.h
Thomas Richter Posted March 4, 2017 Report Posted March 4, 2017 Hi, when FS is running you only OpenFSUIIPC once, not every time you want to read / write. And you close only once as well when you close your app or FS has closed. Also you read/ write multiple Offsets with one Process call and not for every Offset, i.e. if ( !FSUIPC_Read(0x02BC, 4, &ias, &dwResult) || !FSUIPC_Read(0x0020, 4, &alt, &dwResult) || !FSUIPC_Read(0x31E4, 4, &ralt, &dwResult) || !FSUIPC_Process(&dwResult)) { ... } The Process call will return success If you think you process too many Offsets at the time then split into groups and process for each groupe, that takes only couple milli seconds but NOT seconds. Thomas
Daniel0175 Posted March 4, 2017 Author Report Posted March 4, 2017 Thank you Thomas for your reply. Quote when FS is running you only OpenFSUIIPC once, not every time you want to read / write. And you close only once as well when you close your app or FS has closed. I know, the only reason i did like this for now, it i perform the opening (FSConnection.Open(Result);) in another function and for some reason when i only perform a Read or ReadAndProcess i get a link not open error. I will resolve this issue later. Quote Also you read/ write multiple Offsets with one Process call and not for every Offset, I'll try this solution too, you can see in my function a variable Count, i used this variable to count the number of request and after 20 request i perform a process. You can see the code in remark Inside the function. /*if (Count >= 20) { FSConnection.Process(); Count = 0; }*/ maybe my count was not enough hi to make a significant change, i'll try an higher value. I don't remember what is the maximum byte accepted for the process queue. I think is 30 but not sure.
Pete Dowson Posted March 6, 2017 Report Posted March 6, 2017 On 3/4/2017 at 5:02 PM, Daniel0175 said: I'll try this solution too, you can see in my function a variable Count, i used this variable to count the number of request and after 20 request i perform a process. As far as the FSUIPC processing of requests is concerned it is MUCH more efficient to do all your requests in one Process call each cycle, and just match your cycle time to your typical frame rate, but no higher than needed by your application. 20 or 30 times per second should be easy with no performance impact for quite a huge number of variables. The time taken at both ends is in the changing of process and the queueing of messages in FS. You can see this if you use FSInterrogate to request are large area of the offsets. Try larger and larger with a higher and lower frequency. You'll see it takes a lot more variables than you think to impinges upon performance at all. Pete
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now