2

I'm using Canon EDSDK_64 v2.15. I'm able to recieve events send by Canon SDK using simple message loop under Windows7. For example when I want to take a picture and waiting for image data I use:

xCanonError = EdsSendCommand(xCanonEOS, kEdsCameraCommand_TakePicture, 0);

if(xCanonError != EDS_ERR_OK)
    {
        AddLogText(L"sending command TakePicture - error - "+SmartCanon::GetCanonSDKError(xCanonError));
        return false;
    }

    MSG msg;

    while(eState == detector_state_busy)
    {       
        if (::GetMessage(&msg, NULL, NULL, NULL) == -1)
        {
            AddLogText(L" - capture image - waiting for an image - GetMessage() error - " + std::to_wstring(HRESULT_FROM_WIN32(GetLastError())));
            break;
        }
        else
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }

        Sleep(2);
    };

That is how I register my object handler:

xCanonError = EdsSetObjectEventHandler(xCanonEOS, kEdsObjectEvent_All, CSDKHandleObjectEvent, this);
    if (xCanonError != EDS_ERR_OK)
    {
        AddLogText(L"EdsSetObjectEventHandler() - error - "+GetCanonSDKError(xCanonError));
        EdsRelease(xCanonEOS);
        xCanonEOS = NULL;
        EdsTerminateSDK();
        return;
    }

Where xCanonEOS is EdsCameraRef; this is a pointer to a class which I use to do all the work with my Canon camera. And here is my object event handler function:

    EdsError EDSCALLBACK CSDKHandleObjectEvent(EdsObjectEvent p_sCSDKEvent, EdsBaseRef p_sCSDKObject, EdsVoid* p_pCSDKData)
    {
// my class for working with Canon camera
SmartCanon::TDetectorCANON* v_psDetectorCanonEOS = reinterpret_cast<SmartCanon::TDetectorCANON*>(p_pCSDKData);
    // a lot of irrelevant code...
v_psDetectorCanonEOS->SetState(detector_state_idle);
    return EDS_ERR_OK;
    }

My problem is that the very same code do not work under Windows 8.1. Program just go into the while loop and the registered callback function is never called.

I'm using VS2013 x64 compiler. My camera is Canon EOS 60D. My app is using MFC library.

Can someone can point out what I'm doing wrong or provide a solution how to fix this issue?

Jossef Harush Kadouri
  • 32,361
  • 10
  • 130
  • 129
Amadeusz
  • 1,488
  • 14
  • 21
  • Why do you loop over an event? My understanding of events is that you don't have to loop. But anyway, did you try to use the 32bit version too? the 64bit version is currently beta. If you have to loop. Did you try to make the Sleep-time longer for testing purposes? – Johannes Bildstein Feb 20 '15 at 23:18
  • @JohannesB Normally I wouldn't have to but EDSKD works this way (on Windows platform at least) - on stack are many questions about this. I know that 64bit is beta, but for fundamental reasons I can't use 32bit version. I tried to prolong sleep time up to 200 ms with no effect. – Amadeusz Feb 22 '15 at 11:53
  • are you sure about that? I work with EDSDK events completely normal (although I use C#). Only with console applications you have to use the EdsGetEvent method to get events to fire. Have a look at my tutorial with a working example: http://www.codeproject.com/Articles/688276/Canon-EDSDK-Tutorial-in-Csharp – Johannes Bildstein Feb 22 '15 at 11:58
  • After I gave it some thought you are right - I should be able to recieve EDSDK messages with my program main message loop. But this should also happen with this local message loop. I also remembered some situations that first were weird to me but now they make sense: I run my app on computer with Win8 - take a photo - no callback is called - I switch computer to one with Win7 (do not turn off camera!) - I run my app - first thing after registering an EDSDK object callback and entering idle state - proper callback is called (!!!). So an event is set but I can't recieve it... – Amadeusz Feb 22 '15 at 12:47
  • So you are saying that the event from the win8 app is stored until you register on the win7 machine and then is fired without you doing anything else? That'd be really odd. Did you try to strip down the problem to it's bare minimum? And can you reproduce that problem with at different app? I would try it but I don't have win8 – Johannes Bildstein Feb 22 '15 at 21:49

1 Answers1

-1

I had the same problem and with the 32 bits version resolved the callback function.

Hector
  • 1