Hello,
I'm reading documentation provided by LeapSDK V5 and I'm trying to practice some aspects shown in the documentation.
I have issues on the "Using LeapC -> Reading Device Properties" section where I desire to get Device Information. I follow the steps as shown:
1. Open the connection.
2. Call LeapPollConnection() at least once to complete opening the connection.
3. Get the device count by calling LeapGetDeviceList(), passing a NULL pointer instead of an array of device reference structs. LeapC writes the device count to the pnArray parameter.
So I type:
...
#define "ExampleConnection.h"
LEAP_DEVICE_REF* pArray = NULL;
int main(int argc, char** argv) {
/* 1. Open the connection */
/* 2. Call LeapPollConnection() at least once to complete opening the connection. This is done in serviceMessageLoop() */
LEAP_CONNECTION* connHandle = OpenConnection();
eLeapRS result;
result = LeapGetDeviceList(connHandle, pArray, 100 * sizeof(LEAP_DEVICE_REF));
...
but when I run the program (built with no errors), the execution is interrupted by an exception and I get the following message:
Exception thrown at 0x00007FF93FC46C29 (LeapC.dll) in MotionProject.exe: 0xC0000005: Access violation reading location 0x00000000000004B0.
despite the steps say that I should pass a NULL pointer. Then I tried to go forward with the next steps:
4- Create an array of LEAP_DEVICE_REF structs large enough to hold the number of attached devices.
5- Call LeapGetDeviceList() again, passing in the correct size array and setting pnArray to the number of elements in your array. LeapC fills in the device reference struct for each attached device and updates pnArray to the number of records it actually wrote.
So I edit the code by adding allocation of memory for the pArray pointer:
pArray = (LEAP_DEVICE_REF*) malloc(100*sizeof(LEAP_DEVICE_REF));
result = LeapGetDeviceList(connHandle, pArray, 100 * sizeof(LEAP_DEVICE_REF));
But I get the same error:
Exception thrown at 0x00007FF940646C29 (LeapC.dll) in MotionProject.exe: 0xC0000005: Access violation reading location 0x00000000000004B0.
In both the cases, the pArray members, handle and id have 0 as value.
I'm using Visual Studio 2019 in Windows 10, x64.
How can I solve the issue?
Thank you in advance