06-21-2019 01:11 PM
I am trying to use a Hamamatsu Dental Sensor to measure the position of a fan-beam x-ray. Hamamatsu supplies a .dll and header file.
The wizard successfully handled the simple commands such as those to open and close the device but some of the more complex commands are giving me headaches. Here is the simplest example of the ones that I can't get to work:
Header file:
DWORD WINAPI HPK_GetSensorInformation (
HANDLE DeviceHandle,
PUNIT_INTEGRATION_PARAMETER pIntegParam,
PUNIT_SENSOR_INFORMATION pSensorInfo
);
Here are the two structures that are referenced:
typedef struct _tag_UnitIntegrationParameter {
USHORT Xray_Incident_Threshold;
USHORT Integration_End_Threshold;
double Integration_Time;
} UNIT_INTEGRATION_PARAMETER, *PUNIT_INTEGRATION_PARAMETER;
typedef struct _tag_UnitSensorInformation {
UNIT_INTEGRATION_PARAMETER IntegParam;
USHORT Lot_Serial_No;
UCHAR Sensor_Type;
UCHAR Firmware_Version;
} UNIT_SENSOR_INFORMATION, *PUNIT_SENSOR_INFORMATION;
Here's the calling program, which opens device, opens a data pipe and then reads the device setup parameters:
The cluster of three values is the input to the structure UNIT_INTEGRATION_PARAMETER, aka pIntegParam. These are written to the device and seem to work OK. I don't assign anything to the other structure, UNIT_SENSOR_INFORMATION, aka pSensorInfo. The return for pIntegParam contains the values that I assigned. The UNIT_SENSOR_INFORMATION structure contains the structure UNIT_INTEGRATION_PARAMETER and the return for pSensorInfo contains the information that I passed in through pIntegParam. It also includes the Lot_Serial_Number, and should return the strings Sensor_Type and Firmware_Version, which are all stored in the sensor. I do get a value for Lot_Serial_Number but neither of the other two.
From what I've read on the forum the strings are actually pointers. How can I access these values? I've seen many references to using wrapper .dlls but I'm no C programmer. I also don't have the source code.
Any help out there?
06-24-2019 03:31 AM
How does:
UNIT_INTEGRATION_PARAMETER IntegParam;
USHORT Lot_Serial_No;
UCHAR Sensor_Type;
UCHAR Firmware_Version;
translate to:
U16
U16
double
U16
I64
I64
An I64 is not a char. A char is an U8:
U16
U16
double
U16
U8
U8
I'd wire the input constant, the automatic output has given me problems at times.
I'd also put show the names of the CFLN (right click it), as it makes much more readable code.
06-24-2019 07:22 AM
Thanks for your suggestions. The structure UNIT_SENSOR_INFORMATION contains another structure (UNIT_INTEGRATION_PARAMETER) and then the USHORT and 2 UCHAR. These are character strings, which I understood were passed as pointers to memory addresses. Can you clear this up for me? They are definitely not single characters. I assumed that with the address i could use MoveBlock to get the strings but I don't get anything at all.
06-24-2019 08:48 AM
@eajohnso wrote:
Thanks for your suggestions. The structure UNIT_SENSOR_INFORMATION contains another structure (UNIT_INTEGRATION_PARAMETER) and then the USHORT and 2 UCHAR. These are character strings, which I understood were passed as pointers to memory addresses. Can you clear this up for me? They are definitely not single characters. I assumed that with the address i could use MoveBlock to get the strings but I don't get anything at all.
Un UCHAR isn't a pointer. It's just a type, usually a byte. Character strings (not the correct term probably) are * char [], or pointers to character arrays.
I suppose they are enum like values, so each value has a string meaning, like a LV enum.