can't read from a buffer

Discussion in 'C++' started by nass, Sep 26, 2006.

  1. nass

    nass Guest

    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
     
    nass, Sep 26, 2006
    #1
    1. Advertising

  2. Thomas J. Gritzan, Sep 26, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Raja
    Replies:
    12
    Views:
    24,646
    John Harrison
    Jun 21, 2004
  2. Juergen Wohnich

    How can i read a webpage in a buffer

    Juergen Wohnich, Dec 3, 2005, in forum: C++
    Replies:
    1
    Views:
    353
    Jonathan Mcdougall
    Dec 3, 2005
  3. Replies:
    2
    Views:
    623
    sergejusz
    Mar 26, 2007
  4. Neal Becker

    buffer creates only read-only buffer?

    Neal Becker, Jan 8, 2009, in forum: Python
    Replies:
    0
    Views:
    423
    Neal Becker
    Jan 8, 2009
  5. xingye
    Replies:
    9
    Views:
    294
    Michael Lu
    Apr 19, 2004
Loading...

Share This Page