Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > can't read from a buffer

Reply
Thread Tools

can't read from a buffer

 
 
nass
Guest
Posts: n/a
 
      09-26-2006
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

 
Reply With Quote
 
 
 
 
Thomas J. Gritzan
Guest
Posts: n/a
 
      09-26-2006
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
buffer creates only read-only buffer? Neal Becker Python 0 01-08-2009 01:58 AM
When using System.IO.FileStream, I write 8 bytes, then seek to the start of the file, does the 8 bytes get flushed on seek and the buffer become a readbuffer at that point instead of being a write buffer? DR ASP .Net 2 07-29-2008 09:50 AM
When using System.IO.FileStream, I write 8 bytes, then seek to the start of the file, does the 8 bytes get flushed on seek and the buffer become a readbuffer at that point instead of being a write buffer? DR ASP .Net Building Controls 0 07-29-2008 01:37 AM
convert M bit buffer to N bit buffer runcyclexcski@yahoo.com C++ 2 03-26-2007 09:43 AM
How to know the buffer size and increase buffer size in c++ Raja C++ 12 06-21-2004 06:21 PM



Advertisments