CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2012
    Posts
    2

    mmap() check when complete ??

    Hi Developers.

    Iám programming a new ambilight system

    I hope anyone can help me with my problem.
    I have this code to get a pic from the decoder memory on my Dreambox 800.
    But my problem is that my code is to fast.
    I have tryed it with sleep but then my pics are to late.

    See my attachements:
    pic1 Ok.
    pic2 you see pic3 on top of pic2(so my code is to fast)
    pic3 Ok.

    Is there some fix, so i can check when memory is complete and has a complete pic ?
    Or some lock and unlock ?

    Code:
    memory = (unsigned char*)mmap(0, offset + stride*(ofs2+64), PROT_READ, MAP_SHARED, mem_fd, adr);
    if (memory == MAP_FAILED) {
    printf("[grabber] mmap failed\n");
    return false;
    }
    
    usleep(1000);  // we try to get a full picture, its not possible to get a sync from the decoder so we use a delay
    How can i check if the mmap is complete ?

    I hope any can help.

    Name:  post-27679-0-80406100-1347268467_thumb.png
Views: 482
Size:  4.2 KBName:  post-27679-0-83375500-1347268471_thumb.png
Views: 473
Size:  4.0 KBName:  post-27679-0-76610900-1347268473_thumb.png
Views: 484
Size:  1.2 KB


    Kind regards Martijn

  2. #2
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: mmap() check when complete ??

    This would typically only be doable if the host application has a specific API/trigger for this which you can trap.
    If that doesn't exist, any solution or attempt thereof will be a hack of some sort and may not work reliably across versions or even inside the app... These hacks also will take quite a bit of time to figure out and implement properly. If you're not used to diving into assembly code and inner workings of windows. this could be days of work, and possibly not even be doable at your level of expertise. It's not for the faint hearted.

    You could set a debugger memory trap that triggers when the last byte of the buffer gets filled/changed. However, that's going to significantly slow down the program.

    You could also debug the code and look at where the image completes, then try and squeeze your own trigger/hook code in there. A jump - trampoline - your own code - jump back is the typical approach for something like that. Although you could also use debugger interrupt.

  3. #3
    Join Date
    Sep 2012
    Posts
    2

    Re: mmap() check when complete ??

    Quote Originally Posted by OReubens View Post
    This would typically only be doable if the host application has a specific API/trigger for this which you can trap.
    If that doesn't exist, any solution or attempt thereof will be a hack of some sort and may not work reliably across versions or even inside the app... These hacks also will take quite a bit of time to figure out and implement properly. If you're not used to diving into assembly code and inner workings of windows. this could be days of work, and possibly not even be doable at your level of expertise. It's not for the faint hearted.

    You could set a debugger memory trap that triggers when the last byte of the buffer gets filled/changed. However, that's going to significantly slow down the program.

    You could also debug the code and look at where the image completes, then try and squeeze your own trigger/hook code in there. A jump - trampoline - your own code - jump back is the typical approach for something like that. Although you could also use debugger interrupt.
    Thanks! for your fast anwser!

    Can you give me a preview of code, how to do that ?
    Iám programming now for 2 years in c++ but sometimes it's verry difficult.

    Kind regards Martijn

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured