Intrefacing dll library in pascal format
[1/4] from: th72::dds::nl at: 19-Dec-2006 17:27
Hello list,
I am trying to interface the dallas TMex (ibutton) library to rebol.
I'ts programmed (the library) in pascal so I don't know if it is
possible to interface it with rebol. Sofar it is possible to open a
session and do the first setup. After that.....?
The problem is with:
*short far pascal TMFirst(*
*long* /session_handle/*, * // session handle for the desired 1-Wire
network
*void far **/state_buffer/ // state buffer provided for the 1-Wire
network session
*);
*and:
*short far pascal TMRom(*
*long* /session_handle/*, * // session handle for the desired 1-Wire
network
*void far **/state_buffer,/ // state buffer provided for the 1-Wire
network session
*short far **/ROM/ // buffer to read or write from the internal
ROM buffer
*);
*What do I do with the *state_buffer?
The doc says:
/state_buffer/
Specifies a pointer to a memory location that TMEX keeps all of the
state information for the 1-Wire networks. This parameter is required by
most TMEX API functions.
I tried in Rebol something like this:
tmfirst: make routine! [
session [integer!]
buffer [string!]
return: [integer!]] tmex-lib "TMFirst"
I tried it even with a struct! but also no luck.
How do I define "buffer" and how do I pass the buffer-pointer to TMrom?
Rebol crashes or the buffer stay's empty.
Has someone tried this before or is this something way above my head???
Thanks for your time!
Tim
[2/4] from: anton::wilddsl::net::au at: 28-Dec-2006 1:27
Hi Tim,
just dealing with the "buffer" question;
Yeah, just pass it in a string prepared like so:
>> insert/dup buffer: make string! 20 "^-" 20
== ""
>> buffer
== {^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-}
That fills the string with null (0) bytes.
(I'm a bit rusty with my DLL interfacing but I suspect that will help.)
Anton.
[3/4] from: greggirwin::mindspring::com at: 27-Dec-2006 12:26
Hi Tim,
In addition to Anton's note about prefilling the buffer var, you can
also use SHORT in structs, and I believe routines, where there is a
short/word on the C/Pascal side. In most cases an integer! will work
fine with routine calls, but not with structs.
-- Gregg
[4/4] from: th72::dds::nl at: 29-Dec-2006 16:40
Hi Anton,
Thanks for your suggestion. That was indeed the problem and your
solution solved it.
Tim
Anton Rolls wrote: