I'm way over my head on this one and hoping for a push in the right direction. I have an Ethernet based D/A converter that comes with a dll library suitable for use with C and VB. As you might guess, I want to use it with Vee. I have some sample C code that I'm trying to modify. It appears that I can load the library and run the simplest functions but only the complicated functions do anything useful.
I have two problems: 1) converting the .h file entries to a format suitable for Vee and 2) obtaining the handle that the _init function apparently generates so it can be used as an input for the more useful functions. Here are two representative .h file entries:
MXIOEXPORT int CALLBACK MXEIO_Init() MXIOEXPORT int CALLBACK MXEIO_Connect( char * szIP, WORD wPort, DWORD dwTimeOut, int * handle ) MXIOEXPORT int CALLBACK AO_Reads( int hConnection, BYTE bytSlot, BYTE bytStartChannel, BYTE bytCount, double dValue[] ) MXIOEXPORT int CALLBACK AO_Writes( int hConnection, BYTE bytSlot, BYTE bytStartChannel, BYTE bytCount, double dValue[] )
Modifying the first to "long _stdcall MXEIO_Init()" appears to work correctly (I get the expected OK return value) but after that I need the handle this function generates for use with the other functions. Also, I would guess that I'm not converting many of the parameter specifications correctly.
Would anybody care to make some suggestions?
Barrie whoi
--- You are currently subscribed to vrf as: hua_jing@agilent.com To subscribe please send an email to: "vrf-request@lists.it.agilent.com" with the word subscribe in the message body. To unsubscribe send a blank email to "leave-vrf@it.lists.it.agilent.com". To send messages to this mailing list, email "vrf@agilent.com". If you need help with the mailing list send a message to "owner-vrf@it.lists.it.agilent.com". Search the "unofficial vrf archive" at "http://www.vrfarchive.com/vrf_archive". Search the Agilent vrf archive at "http://vee.engineering.agilent.com".
> I need the handle this function > generates for use with the other > functions.
You mean you need the handle from Connect, right? Ints are usable, so you don't need to replace those.
That function would translate: int _stdcall MXEIO_Connect(char *szIP, short wPort, long dwTimeout, int *handle);
The important part of this one is the handle has to be taken off the *right* side of the function call box (it's an output).
Both the Reads and Writes calls take BYTE (aka unsigned char) for two inputs, and you're kind of sunk there. Try it as long. Chances are it's optimized as long anyway. If it has to be BYTE then you'll need a wrapper to call those functions. VEE can't do char. At least it didn't used to. I thought I read something recently to the effect that 8.5 does include char in CFI definitions? If that's so then use char and forget I mentioned it.
The other thing about Reads is that the output array (double dValue []) must be allocated before you call the function. This is a Real64 array. Allocate enough storage for all the channels read, pass it in on the left and take the output from the right.
Type conversions are discussed here: http://www.vrfarchive.com/vrf_archive/CProgramming101.htm#refTypeTable You're interested in "Funky Windows Types" for the most part. -SHAWN-
--- You are currently subscribed to vrf as: hua_jing@agilent.com To subscribe please send an email to: "vrf-request@lists.it.agilent.com" with the word subscribe in the message body. To unsubscribe send a blank email to "leave-vrf@it.lists.it.agilent.com". To send messages to this mailing list, email "vrf@agilent.com". If you need help with the mailing list send a message to "owner-vrf@it.lists.it.agilent.com". Search the "unofficial vrf archive" at "http://www.vrfarchive.com/vrf_archive". Search the Agilent vrf archive at "http://vee.engineering.agilent.com".
* <paramname> can be a string consisting of an alpha character followed by alphanumeric characters, up to a total of 512 characters. The parameter names are optional, but recommended. If a parameter is to be passed by reference, the parameter name must be preceded by the indirection symbol (*).
The valid return types are:
* character strings (char*, corresponding to the VEE Text data type)
* integers (byte, short, int, long, int64, VEE_BOOL, corresponding to the VEE Uint8, Int16, Int32,Int64, and Boolean data types)
* single and double precision floating point real numbers (float and double corresponding to the VEE Real32 and Real64 data types).
Reiner
-----Original Message----- From: Shawn Fessenden [mailto:shawn@vrfarchive.com] Sent: Tuesday, July 01, 2008 8:55 PM To: VRF Subject: RE: [vrf] Using a vendor supplied DLL
> I need the handle this function > generates for use with the other > functions.
You mean you need the handle from Connect, right? Ints are usable, so you don't need to replace those.
That function would translate: int _stdcall MXEIO_Connect(char *szIP, short wPort, long dwTimeout, int *handle);
The important part of this one is the handle has to be taken off the *right* side of the function call box (it's an output).
Both the Reads and Writes calls take BYTE (aka unsigned char) for two inputs, and you're kind of sunk there. Try it as long. Chances are it's optimized as long anyway. If it has to be BYTE then you'll need a wrapper to call those functions. VEE can't do char. At least it didn't used to. I thought I read something recently to the effect that 8.5 does include char in CFI definitions? If that's so then use char and forget I mentioned it.
The other thing about Reads is that the output array (double dValue []) must be allocated before you call the function. This is a Real64 array. Allocate enough storage for all the channels read, pass it in on the left and take the output from the right.
Type conversions are discussed here: http://www.vrfarchive.com/vrf_archive/CProgramming101.htm#refTypeTable You're interested in "Funky Windows Types" for the most part. -SHAWN-
--- You are currently subscribed to vrf as: reiner.schlieker@siemens.com To subscribe please send an email to: "vrf-request@lists.it.agilent.com" with the word subscribe in the message body. To unsubscribe send a blank email to "leave-vrf@it.lists.it.agilent.com". To send messages to this mailing list, email "vrf@agilent.com". If you need help with the mailing list send a message to "owner-vrf@it.lists.it.agilent.com". Search the "unofficial vrf archive" at "http://www.vrfarchive.com/vrf_archive". Search the Agilent vrf archive at "http://vee.engineering.agilent.com".
--- You are currently subscribed to vrf as: hua_jing@agilent.com To subscribe please send an email to: "vrf-request@lists.it.agilent.com" with the word subscribe in the message body. To unsubscribe send a blank email to "leave-vrf@it.lists.it.agilent.com". To send messages to this mailing list, email "vrf@agilent.com". If you need help with the mailing list send a message to "owner-vrf@it.lists.it.agilent.com". Search the "unofficial vrf archive" at "http://www.vrfarchive.com/vrf_archive". Search the Agilent vrf archive at "http://vee.engineering.agilent.com".
* <paramname> can be a string consisting of an alpha character followed by alphanumeric characters, up to a total of 512 characters. The parameter names are optional, but recommended. If a parameter is to be passed by reference, the parameter name must be preceded by the indirection symbol (*).
The valid return types are:
* character strings (char*, corresponding to the VEE Text data type)
* integers (byte, short, int, long, int64, VEE_BOOL, corresponding to the VEE Uint8, Int16, Int32,Int64, and Boolean data types)
* single and double precision floating point real numbers (float and double corresponding to the VEE Real32 and Real64 data types).
Reiner
-----Original Message----- From: Shawn Fessenden [mailto:shawn@vrfarchive.com] Sent: Tuesday, July 01, 2008 8:55 PM To: VRF Subject: RE: [vrf] Using a vendor supplied DLL
> I need the handle this function > generates for use with the other > functions.
You mean you need the handle from Connect, right? Ints are usable, so you don't need to replace those.
That function would translate: int _stdcall MXEIO_Connect(char *szIP, short wPort, long dwTimeout, int *handle);
The important part of this one is the handle has to be taken off the *right* side of the function call box (it's an output).
Both the Reads and Writes calls take BYTE (aka unsigned char) for two inputs, and you're kind of sunk there. Try it as long. Chances are it's optimized as long anyway. If it has to be BYTE then you'll need a wrapper to call those functions. VEE can't do char. At least it didn't used to. I thought I read something recently to the effect that 8.5 does include char in CFI definitions? If that's so then use char and forget I mentioned it.
The other thing about Reads is that the output array (double dValue []) must be allocated before you call the function. This is a Real64 array. Allocate enough storage for all the channels read, pass it in on the left and take the output from the right.
Type conversions are discussed here: http://www.vrfarchive.com/vrf_archive/CProgramming101.htm#refTypeTable You're interested in "Funky Windows Types" for the most part. -SHAWN-
--- You are currently subscribed to vrf as: reiner.schlieker@siemens.com To subscribe please send an email to: "vrf-request@lists.it.agilent.com" with the word subscribe in the message body. To unsubscribe send a blank email to "leave-vrf@it.lists.it.agilent.com". To send messages to this mailing list, email "vrf@agilent.com". If you need help with the mailing list send a message to "owner-vrf@it.lists.it.agilent.com". Search the "unofficial vrf archive" at "http://www.vrfarchive.com/vrf_archive". Search the Agilent vrf archive at "http://vee.engineering.agilent.com".
--- You are currently subscribed to vrf as: hua_jing@agilent.com To subscribe please send an email to: "vrf-request@lists.it.agilent.com" with the word subscribe in the message body. To unsubscribe send a blank email to "leave-vrf@it.lists.it.agilent.com". To send messages to this mailing list, email "vrf@agilent.com". If you need help with the mailing list send a message to "owner-vrf@it.lists.it.agilent.com". Search the "unofficial vrf archive" at "http://www.vrfarchive.com/vrf_archive". Search the Agilent vrf archive at "http://vee.engineering.agilent.com".
Ah, beautiful! So there you go Barrie - byte is the ticket.
And see, there's byte* along with char*, so passing strings containing character 0 works now too. That's a major plus. -SHAWN-
--- You are currently subscribed to vrf as: hua_jing@agilent.com To subscribe please send an email to: "vrf-request@lists.it.agilent.com" with the word subscribe in the message body. To unsubscribe send a blank email to "leave-vrf@it.lists.it.agilent.com". To send messages to this mailing list, email "vrf@agilent.com". If you need help with the mailing list send a message to "owner-vrf@it.lists.it.agilent.com". Search the "unofficial vrf archive" at "http://www.vrfarchive.com/vrf_archive". Search the Agilent vrf archive at "http://vee.engineering.agilent.com".
I used the information you (Shawn) provided and managed to get the subject DLL functions working. I'm still using Vee 6.01 for almost all of what I do so the v8.0 improvements were my last resort (I own it but rarely use it). Fortunately the "try long" suggestion worked as a replacement for BYTE and some experimentation allowed me to deal with the handle issue. So, if anyone wants to control a hydraulic plant using MOXA 4000 series ioLogik modules, Vee can do the job.
Shawn, can you provide a sample "wrapper" as discussed in your "C 101" writeup? I like the readability improvement and, although I managed to get past my problems this time, who knows about the next time....
Thanks everyone for the help.
Barrie whoi
Shawn Fessenden wrote: >> FYI, from the VEE 8.0 help: >> > > Ah, beautiful! So there you go Barrie - byte is the ticket. > > And see, there's byte* along with char*, so passing strings containing > character 0 works now too. That's a major plus. > -SHAWN- > > > > > --- > You are currently subscribed to vrf as: bwalden@whoi.edu To subscribe > please send an email to: "vrf-request@lists.it.agilent.com" with the word subscribe in the message body. > To unsubscribe send a blank email to "leave-vrf@it.lists.it.agilent.com". > To send messages to this mailing list, email "vrf@agilent.com". > If you need help with the mailing list send a message to > "owner-vrf@it.lists.it.agilent.com". > Search the "unofficial vrf archive" at "http://www.vrfarchive.com/vrf_archive". > Search the Agilent vrf archive at "http://vee.engineering.agilent.com". > >
--- You are currently subscribed to vrf as: hua_jing@agilent.com To subscribe please send an email to: "vrf-request@lists.it.agilent.com" with the word subscribe in the message body. To unsubscribe send a blank email to "leave-vrf@it.lists.it.agilent.com". To send messages to this mailing list, email "vrf@agilent.com". If you need help with the mailing list send a message to "owner-vrf@it.lists.it.agilent.com". Search the "unofficial vrf archive" at "http://www.vrfarchive.com/vrf_archive". Search the Agilent vrf archive at "http://vee.engineering.agilent.com".
I'm way over my head on this one and hoping for a push in the right direction. I have an Ethernet based D/A converter that comes with a dll library suitable for use with C and VB. As you might guess, I want to use it with Vee. I have some sample C code that I'm trying to modify. It appears that I can load the library and run the simplest functions but only the complicated functions do anything useful.
I have two problems: 1) converting the .h file entries to a format suitable for Vee and 2) obtaining the handle that the _init function apparently generates so it can be used as an input for the more useful functions. Here are two representative .h file entries:
MXIOEXPORT int CALLBACK MXEIO_Init()
MXIOEXPORT int CALLBACK MXEIO_Connect( char * szIP, WORD wPort, DWORD dwTimeOut, int * handle ) MXIOEXPORT int CALLBACK AO_Reads( int hConnection, BYTE bytSlot, BYTE bytStartChannel, BYTE bytCount, double dValue[] ) MXIOEXPORT int CALLBACK AO_Writes( int hConnection, BYTE bytSlot, BYTE bytStartChannel, BYTE bytCount, double dValue[] )
Modifying the first to "long _stdcall MXEIO_Init()" appears to work correctly (I get the expected OK return value) but after that I need the handle this function generates for use with the other functions. Also, I would guess that I'm not converting many of the parameter specifications correctly.
Would anybody care to make some suggestions?
Barrie
whoi
---
You are currently subscribed to vrf as: hua_jing@agilent.com To subscribe please send an email to: "vrf-request@lists.it.agilent.com" with the word subscribe in the message body.
To unsubscribe send a blank email to "leave-vrf@it.lists.it.agilent.com".
To send messages to this mailing list, email "vrf@agilent.com".
If you need help with the mailing list send a message to "owner-vrf@it.lists.it.agilent.com".
Search the "unofficial vrf archive" at "http://www.vrfarchive.com/vrf_archive".
Search the Agilent vrf archive at "http://vee.engineering.agilent.com".