By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,332 Members | 1,427 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,332 IT Pros & Developers. It's quick & easy.

can't read from a buffer

P: n/a
hello everyone
ok i have created a shared memory segment and can save data into it.. i
can check because the segment is directly connected to a file in the
disk. so yes i have verified data (bytes really) is written into the
memory. the problem is reading...
basically just like in saving i create the same exact structure:
struct manualStruct {
Q_UINT8 mC1St;
Q_UINT8 mC2St;
Q_UINT8 mC3St;
};
Q_UINT8 is just a Qt specific platform free type which is basically
unsigned int 8bits long
and then
struct manualStruct *manualVar=(manualStruct*)((char*)file_memory +
0xC5);
basically file_memory is a void* pointer to the shared memory segment,
so i cast it, add an offset to the exact location where data is written
and then i simply assingn manualVar.
next i should be able to just:
MANUAL_cap1State=manualVar->mC1St;
MANUAL_cap2State=manualVar->mC2St;
MANUAL_cap3State=manualVar->mC3St;
where MANUAL_* variables are int.
then i just test with cout to see if the values have been copies and
well they haven't...
any ideas why?
nass

Sep 26 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
nass schrieb:
[read from shared memory]
then i just test with cout to see if the values have been copies and
well they haven't...
any ideas why?
Wrong offset?

Read here:
http://www.parashift.com/c++-faq-lit...t.html#faq-5.8

--
Thomas
http://www.netmeister.org/news/learn2quote.html
Sep 26 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.