[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Dalsa-1M30P / driver not working?



Dear Friend:

Again, I'd like to thank Mr. Stein for his help.  But I still
have problems.

The configuration:  a Dalsa 1M30P camera connected to an IC-PCI
frame grabber with AM-DIG acquisition module and probably 4M
of memory.  The system is a 2-processor pentium "passive
backplane/single board" computer with 132M of memory.  The 
computer has been lent to us while we evaluate the 1M30P, so 
I don't have complete documentation (Windows on the machine at 
arrival, but we were having other problems with Windows).  The 
currently installed Linux is the Mandrake 7.1 distribution
(2.2.15-4mdksmp), and I have the revision 0.7.1 devie driver.

The first problem is I don't have a proper .cam file for
this camera, so I can't use test_itifg.  Has anyone tried 
this camera before?

I was able to compile and load the device driver.  When 
I open up the /dev/ic0idI device I get the following results
for the following ioctl's (the ioctl calls return successfully
also):

   GIOC_GE_GET_PAGEDSIZE    1576960
   GIOC_GE_GET_RAWSIZE      1572864
   GIOC_GE_GET_WIDTH           1024
   GIOC_GE_GET_HEIGHT           768
   GIOC_GE_GET_CAMERA             0
   GIOC_GE_GET_DEPTH             16

The camera is supposed to have a 1024x1024 active area with 
12 bit digitization.  1024*1024*3/2 = 1572864 = 1024*768*2, 
so the  RAWSIZE almost makes sense, except that there should be
an additonal 2x20 light-shielded and 2x4 isolation pixels
on each row, and there should be an extra 6 isolation rows.

If I just run the above ioctl's things are ok.  If I 
additionally mmap PAGED_SIZE of /dev/zero and try reading from 
the camera, the read fails (I'll reproduce the code below,
and I'm using the serial port on the camera to program it
for an external trigger) with a "No data available" error. 
After this, any program which I attempt to start immediately
has a segmentation fault (and since I can't run shutdown, I
cycle power on the system).

I thank you in advance for any advice or help you can render.
I'd really like to get this to work and would be willing
to experiment a quite a bit.

Sincerely,
  Mike

P.S. Here is a listing of the code I was trying to use--note, running
as a normal user, not root.

#include <iostream.h>
#include <unistd.h>
#include <stdlib.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <sys/mman.h>

#include "../CAMERA/itifg-0.7.1/itifgExt.h"

char buf[2048];

int main(int argc, char *argv[])
{
  int fd = open("/dev/ic0idI",O_RDONLY);
  //int fd = open("/dev/ic2idI",O_RDONLY);
  if(fd<0){ cerr << "open failed:" << strerror(errno) << endl; exit(1); }

  size_t paged_size;
  if( ioctl(fd, GIOC_GE_GET_PAGEDSIZE, &paged_size) < 0 ){
    cout << "GIOC_GE_GET_PAGEDSIZE: " << strerror(errno) << endl;
    exit(1);
  }
  cout << "paged_size = " << paged_size << endl;

   
  size_t raw_size;
  if( ioctl(fd, GIOC_GE_GET_RAWSIZE, &raw_size) < 0 ){
    cout << "GIOC_GE_GET_RAWSIZE: " << strerror(errno) << endl;
    exit(1);
  }
  cout << "raw_size = " << raw_size << endl;

  short width;
  if( ioctl(fd, GIOC_GE_GET_WIDTH, &width) < 0 ){
    cout << "GIOC_GE_GET_WIDTH: " << strerror(errno) << endl;
    exit(1);
  }
  cout << "width = " << width << endl;
 
  short height;
  if( ioctl(fd, GIOC_GE_GET_HEIGHT, &height) < 0 ){
    cout << "GIOC_GE_GET_HEIGHT: " << strerror(errno) << endl;
    exit(1);
  }
  cout << "height = " << height << endl;

  int camera_id;
  if( ioctl(fd, GIOC_GE_GET_CAMERA, &camera_id) < 0 ){
    cout << "GIOC_GE_GET_CAMERA: " << strerror(errno) << endl;
    exit(1);
  }
  cout << "camera_id = " << camera_id << endl;

  int depth;
  if( ioctl(fd, GIOC_GE_GET_DEPTH, &depth) < 0 ){
    cout << "GIOC_GE_GET_DEPTH: " << strerror(errno) << endl;
    exit(1);
  }
  cout << "depth = " << depth << endl;

  int zerofd = open("/dev/zero",O_RDONLY);
  if(zerofd<0){ cout << "can't open zero??" << endl; exit(1); }
 
  void* ptr = mmap(0, paged_size, PROT_READ|PROT_WRITE,
                        MAP_PRIVATE, zerofd, 0);
  if(ptr==0){ cout << "can't mmap zero???" << endl; exit(1); }

  struct timeval timeout;
  timeout.tv_sec = 5; timeout.tv_usec = 0;
  if( ioctl(fd, GIOC_GE_SET_TIMEOUT, &timeout) < 0 ){
    cout << "GIOC_GE_SET_TIMEOUT: " << strerror(errno) << endl;
    exit(1);
  }


  int nread = read(fd, ptr, paged_size);
  if( nread<0 ){
     cout << strerror(errno) << endl; 
  }else{
    cout << "nread = " << nread  << endl;
  }
}