comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » problem with call_external
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
problem with call_external [message #2783] Fri, 16 September 1994 12:04 Go to next message
knight is currently offline  knight
Messages: 37
Registered: January 1992
Member
I am trying to call a c function from IDL, and it works *ONCE.* On the second
call, I get the following:

IDL> a=get_sdv_frame()
% Unable to free memory: from array descriptor.
Invalid argument
% Execution halted at GET_SDV_FRAME </users/nuc/idl/pro/get_sdv_frame.pro(
46)> .
% Called from $MAIN$ .
IDL>

Is this a symptom you can tie to a specific cause? In this case, I am
transferring data from a digital frame grabber to the location of an IDL array.

I attach the particulars below.

Thanks, Fred


-------------------------------IDL site -------------------------------

IDL. Version 3.6 (sunos sparc).
Copyright 1989-1994, Research Systems, Inc.
All rights reserved. Unauthorized reproduction prohibited.
Installation number: 2016-1.
Licensed for use by: Groups 101 and 105


-------------------------------IDL function to call_external ---------------
;+
; NAME:
; get_sdv_frame
; PURPOSE:
; This function returns a frame of data read from the SDV digital frame
; grabber.
; EXAMPLE:
; a = get_sdv_frame(sdvunit)
; CALLING SEQUENCE:
; a = get_sdv(sdvunit[,options])
; INPUTS:
; sdvunit = 0 or 1, depending on which SDV card is being accessed
; OPTIONAL INPUTS:
;
; KEYWORD PARAMETERS:
; help = flag to print this header
; OUTPUTS:
; a = frame of data, usually shorts, with dimensions selected via last
; execution of the program script sdvload
; OPTIONAL OUTPUTS:
;
; COMMON BLOCKS:
;
; SIDE EFFECTS:
;
; RESTRICTIONS:
;
; PROCEDURE:
;
; MODIFICATION HISTORY:
; write, 15 Sep 94, FKK (knight@ll.mit.edu)
;-
FUNCTION get_sdv_frame,sdvunit,help=help
;
; =====>> HELP
;
IF keyword_set(help) THEN BEGIN
doc_library,'get_sdv_frame'
return,0
ENDIF
;
; =====>> Use call external
;
IF n_elements(sdvunit) EQ 0 THEN sdvunit = 0
frame = intarr(255,256) ; frame buffer
result = call_external( $
'/export/home/telluride/sdv/new/get_sdv_frame.so' $ ; .so location
,'get_sdv_frame' $ ; symbol
,long(sdvunit) $ ; 1st param
,frame) ; 2nd param
return,frame
END

---------------------------- c code in .so file ---------------------

/*
* Function to grab one frame from the sdv card.
* Start with $SDV/new/sdvread.c.
* Modify for use with IDL via call_external.
* knight@ll.mit.edu, 15 Sep 94
*/

#include <stdio.h>
#include <sys/types.h>
#include "camera.h"
#include "sdvlib.h"

int get_sdv_frame(argc,argv)
int argc ;
void *argv[] ;
{
char devname[20];
SdvDev *sd;

sprintf(devname,"/dev/sdv%d",*(int *) argv[0]) ;
if ((sd = sdv_open(devname, SDV_NOLOCKDEV)) == NULL)
{
printf("couldn't open %s\n",devname);
exit(1);
}
sd->image = (caddr_t)argv[1];
if (sdv_grab(sd) < 0)
printf("couldn't get frame from %s\n",devname);
sdv_close(sd) ;
free(argv[1]);
printf("done\n") ;
}


--------------------------- makefile -------------------------

get_sdv_frame: get_sdv_frame.c sdvlibso.c
cc -pic -fsingle -c get_sdv_frame.c
cc -pic -fsingle -c sdvlibso.c
ld -o get_sdv_frame.so -assert pure-text get_sdv_frame.o sdvlibso.o
--
=Fred Knight (knight@ll.mit.edu) (617) 981-2027
C-483\\MIT Lincoln Laboratory\\244 Wood Street\\Lexington, MA 02173
Re: Problem with call_external [message #20403 is a reply to message #2783] Mon, 19 June 2000 00:00 Go to previous message
Paul Probert is currently offline  Paul Probert
Messages: 7
Registered: May 1995
Junior Member
Tom,
One thing I discovered was that if your dllmain() function crashes
(hits a runtime
error or such) then IDL will report that it can't find the .dll when it
really means
it can't successfully load and initialize it.

Tom Price wrote:
>
> Hello,
>
> This may be an old question but I just found this group. I am trying to use
> one of the examples in the IDL external directory so that I can call it
> using call_external. I am running Windows 98 with Visual C++ 5.0. I am
> generating a DLL within the environment but when I try to run call_external
> with this .dll I get an error saying that it can't find the dll. I have
> moved the dll everywhere and even run call_external with the full file
> description to the directory where the dll resides. I assume I am doing
> something stupid with the compilation but I can't figure out what. I am
> using the switch settings within C++ to make the dll. Do I have something
> set wrong there???
>
> All help greatly appreciated.
>
> Regards,
>
> Tom Price
> Xinetics Inc.

--
Paul Probert
Associate Scientist
The University of Wisconsin-Madison
Dept. of Electrical and Computer Engineering
Re: Problem with call_external [message #20406 is a reply to message #2783] Mon, 19 June 2000 00:00 Go to previous message
Bernard Puc is currently offline  Bernard Puc
Messages: 65
Registered: January 1998
Member
Tom Price wrote:
>
> Hello,
>
> This may be an old question but I just found this group. I am trying to use
> one of the examples in the IDL external directory so that I can call it
> using call_external. I am running Windows 98 with Visual C++ 5.0. I am
> generating a DLL within the environment but when I try to run call_external
> with this .dll I get an error saying that it can't find the dll. I have
> moved the dll everywhere and even run call_external with the full file
> description to the directory where the dll resides. I assume I am doing
> something stupid with the compilation but I can't figure out what. I am
> using the switch settings within C++ to make the dll. Do I have something
> set wrong there???


Can you send the complete error message generated by IDL when the
call_external function fails?

--
Bernard Puc AETC, INC.
bpuc@va.aetc.com 1225 Jefferson Davis Highway #800
(703) 413-0500 Arlington, VA 22202
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Problem with call_external
Next Topic: IDL for linux on Macintosh ppc

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 11:51:29 PDT 2025

Total time taken to generate the page: 0.00758 seconds