09-01-2025 11:04 PM
Hello,
I'm working on integrating the MEMS-FPI spectrum module from Hamamatsu into my LabVIEW application. The official DLL provided by Hamamatsu includes a function:
HRESULT hpkfpi_getdevcount(HPKFPI_INITPARAM* initparam);
The HPKFPI_INITPARAM structure is defined as:
#define HPKFPI_INITARY_NUMBER 255
#define HPKFPI_INITARY_STRLEN 32
typedef struct {
int32_t sizeof_parameter;
int32_t devicecount;
char buf_VID[HPKFPI_INITARY_NUMBER][HPKFPI_INITARY_STRLEN];
char buf_PID[HPKFPI_INITARY_NUMBER][HPKFPI_INITARY_STRLEN];
char buf_SERIAL[HPKFPI_INITARY_NUMBER][HPKFPI_INITARY_STRLEN];
} HPKFPI_INITPARAM;
Where:
sizeof_parameter: Size of the structure (24488 bytes)
devicecount: Number of connected devices (0 to 😎
buf_VID, buf_PID, buf_SERIAL: Buffers for receiving vendor IDs, product IDs, and serial numbers, respectively.
I'm encountering difficulties when attempting to pass this structure to the DLL using LabVIEW's Call Library Function Node (CLFN). Specifically, I'm unsure how to correctly pass the HPKFPI_INITPARAM cluster. Below is what I had but I kept getting the invalid parameter error code. Any insights or examples would be greatly appreciated.
09-02-2025 02:22 AM
LabVIEW arrays are not the same as C array pointers and what you have in that structure is again a different thing than a C array pointer. Fixed size arrays in a structure are inlined by the C compiler. You got that basically already right by calculating the sizeof_parameter correctly.
So you need to create an array of bytes with 24488 bytes and pass that to the Call Library Node (CLN) after you filled in the 24488 in the sizeof_parameter 32-bit integer in the front.
Easiest to do that is by using the Flatten to String function to add the sizeof_parameter into the array, then pass the whole to your CLN and afterwards get the relevant data out.
I leave the exercise of getting the 255 potential strings with up to 32 characters each for you to tackle. Most likely those strings are padded with zero bytes at the end to fill up the 32 characters each, so it would probably be useful to scan for that and limit the actual strings accordingly.
09-03-2025 03:11 AM
Thank you very much for the input. I've gotten basic functions working, but I'm stuck on a more complex function and would appreciate some guidance. The function HRESULT hpkfpi_getinfo(HFPI hfpi, HPKFPI_INFO* info);
hfpi is device handle (U64) from another function and info is
typedef struct {
int32_t sizeof_parameter;
uint32_t idInfo;
char* buf;
int32_t bufsize;
} HPKFPI_INFO;
Where:
I initialized a 24 byte array of 0, initialize sizeof_parameter to 24, idInfo to 3 and bufsize to 32. How do I properly tell the DLL the address of my 32-byte string buffer? I assume I cannot just calculate a memory address myself. Is there a way to configure the CLFN so it automatically handles the pointer or do I need to use a different method to pass the address of my buffer into the buf of the array? Would greatly appreciate any hints on this issue.