Jump to content
The simFlight Network Forums

FSUIPC_User.lib - processing multiple offsets with a single FSUIPC_Process() Call


Recommended Posts

Hey Pete,

Maybe I'm just turning into an old fart, but I could have sworn I saw some documentation somewhere that shows how to read or write an array of offsets with one call to FSUIPC_Process() using the FSUIPC_User.lib in C++.... but for the life of me I just can't find it.

Can you either:  (A) point me in the right direction or (B) confirm that I am, in fact, senile and that documentation was just a wonderful dream 🙂 ... or maybe it was a different SDK/Dll?

Thanks, Pete...

Jeff

Link to comment
Share on other sites

Jeff I don't know the C++ implementation but from Delphi (which is also un-managed code) I would simply perform a single read implementation (e.g. read the number of bytes you need) into a byte-array, and then use simple pointer math to set the pointer to point at a specific position in this array, and then read the value you expect to find at that location (whether its a byte, short, int or whatever). So in stead of reading a single int (4 bytes) in a read operation you read 256, 512 ... whatever number of bytes you need.

EDIT: Probably misread your question. You can have multiple reads for a single Process like this:

char chTime1;
char chTime2;
char chTime3;
FSUIPC_Read(0x238, 1, chTime1, &dwResult);
FSUIPC_Read(0x239, 1, chTime2, &dwResult);
FSUIPC_Read(0x23A, 1, chTime3, &dwResult);
FSUIPC_Process(&dwResult);

But in this case, the following is better (one read operation, reading 3 bytes)
char chTime[3];
FSUIPC_Read(0x238, 3, chTime, &dwResult);
FSUIPC_Process(&dwResult);

Link to comment
Share on other sites

7 hours ago, 737MaxDriver2 said:

I could have sworn I saw some documentation somewhere that shows how to read or write an array of offsets with one call to FSUIPC_Process() using the FSUIPC_User.lib in C++.... but for the life of me I just can't find it.

As Pelle shows,  the FSUIPC_Read function doesn't know or care what the data is you are reading, nor does it limit how much you read in one go. So you can just define a structure for all the contiguous variables you want, then issue an FSUIPC_Read for the base offset address with the size of the structure as the number of bytes to be read. You could theoretically read the complete offset list into a 65536 byte structure or array, though I think the LIB code restricts this to 0x7F00 (i.e. a little less than half) -- see subsequent posts.

Pete

 

 

Link to comment
Share on other sites

2 minutes ago, pellelil said:

Pete, isn't there a max of 0x7F00 bytes in the request-buffer (content of the memory-mapped file shared by the client and FSUIPC) or this is an old limitation?

Ah, yes, I think there might be.  It would be to do with the Memory-Mapped file request in the fsuipc_open.  I suppose, theoretically, that could be extended. But there probably is no justification for more. It's really only that size to allow accumulations of requests rather than a single huge one.

I'll edit my earlier post.

Pete

 

Link to comment
Share on other sites

Thanks guys....

Followup ...

1) can I do this w/non-contiguous addresses:

FSUIPC_Write(0x238, 1, chTime1, &dwResult);
FSUIPC_Write(0x247, 7, chTime2, &dwResult);
FSUIPC_Write(0x259, 2, chTime3, &dwResult);
FSUIPC_Process(&dwResult);

2) can I mix read and write under ONE FSUIPC_Process or do I have to do all writes with a "Process" and then reads with a process:

FSUIPC_Write(0x238, 1, chTime1, &dwResult);
FSUIPC_Read(0x247, 7, chTime2, &dwResult);
FSUIPC_Process(&dwResult);

 

 

Link to comment
Share on other sites

Yes and Yes. Every time you you perform a Read or a Write all you are doing is putting your requests into a buffer (and you can mix read and write as much as you want). When you call process, this buffer is transferred to FSUIPC, and if you have read requests the data you request are put back into this buffer by FSUIPC so they are available to you after the Process call have been executed.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.