IAN CHUNG Posted July 18, 2019 Report Share Posted July 18, 2019 Trying to call the function below. I would like to read CL_MEASDATA information. Actually just need Evxy. ER_CODE KMAPI CLGetMeasData(DEVICE_HANDLE hDevice, CL_COLORSPACE Type, CL_MEASDATA* pColor); typedef union tCL_MEASDATA { CL_EvxyDATA Evxy; CL_EvuvDATA Evuv; CL_EvTduvDATA EvTduv; CL_EvDWPeDATA EvDWPe; CL_XYZDATA XYZ; CL_RenderingDATA Rendering; CL_PWDATA Pw; CL_SPCDATA Spc; } CL_MEASDATA; typedef struct tCL_EvxyDATA { float Ev; float x; float y; } CL_EvxyDATA; typedef struct tCL_EvuvDATA { float Ev; float u; float v; } CL_EvuvDATA; typedef struct tCL_EvTduvDATA { float Ev; float T; float duv; } CL_EvTduvDATA; typedef struct tCL_EvDWPeDATA { float Ev; float DW; float Pe; } CL_EvDWPeDATA; typedef struct tCL_XYZDATA { float X; float Y; float Z; } CL_XYZDATA; typedef struct tCL_RenderingDATA { float Data[CL_RENDERING_LEN]; } CL_RenderingDATA; The RenderingDATAis stored in the array in below order 0 1 2 ・・・ 14 15 Ra R1 R2 ・・・ R14 R15 typedef struct tCL_PWDATA { float PeakWave; } CL_PWDATA; typedef struct tCL_ScotopicDATA { float Ev; float Es; float SP; } CL_ScotopicDATA; Quote Link to comment
JKSH Posted July 18, 2019 Report Share Posted July 18, 2019 (edited) 2 hours ago, IAN CHUNG said: Trying to call the function below... ER_CODE KMAPI CLGetMeasData(DEVICE_HANDLE hDevice, CL_COLORSPACE Type, CL_MEASDATA* pColor); So here are more details about the other parts of the function: https://stackoverflow.com/questions/38632316/typeloadexception-using-dllimport ER_CODE: I32 KMAPI: stdcall DEVICE_HANDLE: Pointer CL_COLORSPACE: Enum (size is not well-defined in C, but it's usually 32-bit) Your CLFN must have Calling Convention = "stdcall (WINAPI)" and have 4 parameters: Name Type Data Type/Format return type Numeric Signed 32-bit Integer hDevice Numeric Signed/Unsigned Pointer-sized Integer (pass by Value) Type Numeric Signed/Unsigned 32-bit Integer (pass by Value) pColor Adapt to Type Handles by Value 2 hours ago, IAN CHUNG said: Actually just need Evxy. ... typedef union tCL_MEASDATA { CL_EvxyDATA Evxy; // ... } CL_MEASDATA; typedef struct tCL_EvxyDATA { float Ev; float x; float y; } CL_EvxyDATA; If you only want to read Evxy from the function, you can pretend that the parameter type is CL_EvxyDATA* instead of CL_MEASDATA*. This works because is a CL_MEASDATA union and CL_EvxyDATA is one of the structs it can store. Make a Type Definition: A Cluster that contains 3 SGL numbers, and use this cluster to to tell the CLFN how to interpret the data. Edited July 18, 2019 by JKSH Add snippet Quote Link to comment
IAN CHUNG Posted July 19, 2019 Author Report Share Posted July 19, 2019 Thank you very much for this kind reply. I tried this method (A Cluster that contains 3 SGL numbers, and use this cluster to to tell the CLFN how to interpret the data.).But it will show this error or the program crashed. Quote Link to comment
IAN CHUNG Posted July 19, 2019 Author Report Share Posted July 19, 2019 This is the program. It can run to CL polling measure.vi libclapi.dlCL-500A.llb Quote Link to comment
JKSH Posted July 19, 2019 Report Share Posted July 19, 2019 1 hour ago, IAN CHUNG said: But it will show this error or the program crashed. Oops, sorry... I didn't notice CL_RenderingDATA. This means the union is 64 bytes long. Try using a cluster of 16 SGLs, and only read the first 3 values. Or, try changing the parameter configuration: Type: Array Data type: 4-byte Single Dimensions: 1 Array format: Array Data Pointer Minimum Size: 16 Quote Link to comment
IAN CHUNG Posted July 19, 2019 Author Report Share Posted July 19, 2019 Thank you very much! It works for Array Data Pointer! I used float array (Size: 16) and read the first 3 values. Thanks a lot! Quote Link to comment
xufeng.ke Posted August 9, 2022 Report Share Posted August 9, 2022 Could you help to share your latest labview driver of CL-500A? thank you very much Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.