12-10-2008 03:24 PM - edited 12-10-2008 03:32 PM
Hi, I tried to use comedi, compiled on my amd x64 architecture, through Call Library Function Node and it does not work. It sort of makes sense that the driver is 64 bit as well as libcomedi.so.0 while Labview is 32bit application - no wonder, it can not load 64bit library, even though, it can glance through the available methods inside.
my question is .... is there a way to use 64bit comedi driver through labview? or i have to install 32bit linux?
the way it does not work right now as follows ...
1) I put the call library function node vi on the canvas and go to configure
2) choose library and a function from the list
3) set the parameters (return and arguments)
4) click OK,
5) labview starts searching for libcomedi.so.0 even though it shows that on the top of the search window that it searches for /usr/loca/lib/libcomedi.so.0. Eventually the search stops and suggests to browse your self. If you point to the library manually it says that 'libcomedi.so.0' is not a valid LabView file.
12-11-2008 10:34 AM - edited 12-11-2008 10:37 AM
answering to myself ... with the help of comedi forums i was able to compile a 32bit library using 32bit chroot environment. Luckily the driver supports 32bit calls.
Now I am able to use the library in Labview!
However ..... I am stuck at ....
what if driver returns a poitner to a structure ? basically, I have "comedi_t * comedi_open(const char * filename)".
Labview allows me to choose only Numeric, Void, and String as return values. So my question is - How do I cast the integer that I receive from the call to necessary structure/object pointer to pass it along?
12-12-2008 12:13 AM
12-12-2008 11:54 AM - edited 12-12-2008 12:01 PM
here is a problem I am having right now ... the structure that I am trying to pass around is:
typedef struct comedi_cmd_struct comedi_cmd;
struct comedi_cmd_struct{
unsigned int subdev;
unsigned int flags;
unsigned int start_src;
unsigned int start_arg;
unsigned int scan_begin_src;
unsigned int scan_begin_arg;
unsigned int convert_src;
unsigned int convert_arg;
unsigned int scan_end_src;
unsigned int scan_end_arg;
unsigned int stop_src;
unsigned int stop_arg;
unsigned int *chanlist;
unsigned int chanlist_len;
sampl_t *data;
unsigned int data_len;
};
1. Luckily all of the fields are 32bit integers so I can just create an array or a cluster(converted later to array) and pass it to a library function.
2. Unfortunately, this structure contains other pointers. For instance chanlist is an array of channels to scan.
In order for things to work I have to initialize that pointer with an address of an array created in labview as a constant/variable. Is there a way to greate an array and then extract its address out of it somehow?
ADDED:
There is a neat way to access data using a pointer generated by a DLL/SO library using MoveBlock... is there a opposite action? extract address of a variable to pass it to dll?
12-12-2008 12:52 PM - edited 12-12-2008 12:53 PM
here is how I obtained an address of an array created in Labview ...
I have created a CIN with the following code:
/* CIN source file */
#include "extcode.h"
/* Typedefs */
typedef struct {
int32 dimSize;
int32 elt[1];
} TD1;
typedef TD1 **TD1Hdl;
MgErr CINRun(TD1Hdl arg1, int32 *zeroAddr);
MgErr CINRun(TD1Hdl arg1, int32 *zeroAddr)
{
*zeroAddr = (int32)(*arg1)->elt;
return noErr;
}
Now I am going to check it it helps me ...