Prosilica PvAPI: can't

2011/5/27 <eberlid [..] ...>

> Do you see any issues in the code?
>
> Header file:
>

> #ifndef OROCOS_CAMERA_PROSILICA_COMPONENT_HPP
> #define OROCOS_CAMERA_PROSILICA_COMPONENT_HPP
>
> #include <rtt/RTT.hpp>
> #include <iostream>
>
> #define _LINUX
> #define _x64
>
> #include "PvApi.h"
>
> class Camera_prosilica
>    : public RTT::TaskContext
> {
>  public:
>    Camera_prosilica(string const& name);
>
>    bool configureHook();
>    bool startHook();
>    void updateHook();
>    void stopHook();
>    void cleanupHook();
>
>  private:
> };
>
> #endif
> 

>
> source file:
>
> #include "camera_prosilica-component.hpp"
> #include <rtt/Component.hpp>
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
>
> #include <unistd.h>
> #include <time.h>
> #include <signal.h>
>
> #include "arpa/inet.h"
>
> /*
>  * Using this macro, only one component may live
>  * in one library *and* you may *not* link this library
>  * with another component library. Use
>  * O_CREATE_COMPONENT_TYPE()
>  * ORO_LIST_COMPONENT_TYPE(Camera_prosilica)
>  * In case you want to link with another library that
>  * already contains components.
>  *
>  * If you have put your component class
>  * in a namespace, don't forget to add it here too:
>  */
>
>
> void Sleep(unsigned int time)
> {
>    struct timespec t,r;
>
>    t.tv_sec    = time / 1000;
>    t.tv_nsec   = (time % 1000) * 1000000;
>
>    while(nanosleep(&t,&r)==-1)
>        t = r;
> }
>
>
> Camera_prosilica::Camera_prosilica(string const& name)
>        : TaskContext(name, PreOperational) {
>        std::cout << "Camera_prosilica constructed !" <<std::endl;
> }
>
>
> bool Camera_prosilica::configureHook() {
>        tPvHandle camera;
>        tPvAccessFlags flags = ePvAccessMaster;
>        tPvErr err;
>        unsigned long inetAddr = inet_addr("192.168.0.101");
>
>
>        if(PvInitialize() != ePvErrSuccess) {
>                fprintf(stderr, "\n-- Failed to initialize API!\n");
>                return false;
>        }
>        else {
>                fprintf(stdout, "\n-- Successfully initialized API!\n");
>        }
>
>        Sleep(2000);
>
>        err = PvCameraOpenByAddr(inetAddr,flags,&camera);
>        if(err != ePvErrSuccess) {
>                fprintf(stderr, "-- Error opening camera by address: %d\n",
> static_cast<int>(err));
>                return false;
>        }
>        else
>                fprintf(stdout, "-- Successfully opened camera by
> address!\n");
>
>        Sleep(500);
>
>        err = PvCaptureAdjustPacketSize(camera,1500);
>        if(err != ePvErrSuccess) {
>                fprintf(stderr, "-- Error adjusting packet size: %d\n",
> static_cast<int>(err));
>                return false;
>        }
>        else
>                fprintf(stdout, "-- Successfully set packet size!\n");
>
>        Sleep(500);
>
>        err = PvCaptureStart(camera);
>        if(err != ePvErrSuccess) {
>                fprintf(stderr, "-- Error capture start: %d\n",
> static_cast<int>(err));
>                return false;
>        }
>        else
>                fprintf(stdout, "-- Successfully started capture!\n");
>
>        Sleep(500);
>
>        unsigned long FrameSize = 0;
>        err = PvAttrUint32Get(camera,"TotalBytesPerFrame",&FrameSize);
>        if(err != ePvErrSuccess) {
>                fprintf(stderr, "-- Error getting TotalBytesPerFrame: %d\n",
> static_cast<int>(err));
>                return false;
>        }
>        else
>                fprintf(stdout, "-- Successfully got
> TotalBytesPerFrame!\n");
>
>        Sleep(500);
>
>        PvCaptureEnd(camera);
>        PvCameraClose(camera);
>        PvUnInitialize();
>
>        return true;
> }
>
> bool Camera_prosilica::startHook() {
>
>        return true;
> }
>
> void Camera_prosilica::updateHook() {
>
> }
>
> void Camera_prosilica::stopHook() {
>
>    std::cout << "Camera_prosilica executes stopping !" <<std::endl;
> }
>
> void Camera_prosilica::cleanupHook() {
>
>        //PvUnInitialize();
>
>    std::cout << "Camera_prosilica cleaning up !" <<std::endl;
> }
>
>
> ORO_CREATE_COMPONENT(Camera_prosilica)
> 

>
> Since it just opens and closes the camera in the config-hook it is clear
> that camera is closed after configuration. The goal is to get the
> TotalBytesPerFrame successfully. I tried to get/set other attributes without
> success...
>
> It returns each time with
>
> -- Successfully initialized API!
> -- Successfully opened camera by address!
> -- Successfully set packet size!
> -- Successfully started capture!
> -- Error getting TotalBytesPerFrame: 6
> 

>
> Can you compare my code with your code?
>

I look at my code and the problematic line is almost the same for me:

PvAttrUint32Get(mCameraHandle,"TotalBytesPerFrame",&frameSize)

I have no idea, sorry.

Philippe