rawHID for teensy 4.0 Compling c files for Matlab

Status
Not open for further replies.

David2020

New member
Hi

I am new to this so please accept my apologies if my questions are naive. Basically what I want to do it to complete your c codes with MATLAB and make mex function that I can use in my Matlab scripts and transfer data between Teensy 4 and the computer. I used serial before but that requires specifying the serial port.

What I did, I downloaded your c source files from https://www.pjrc.com/teensy/rawhid.html and tried to compile them in Matlab with mex ('hid_WINDOWS.c') command. (I selected MinGW64 Compiler (C) ) . I receive the following error:

fatal error: ddk/hidsdi.h: No such file or
directory
#include <ddk/hidsdi.h>
^
compilation terminated.

it looks those files are not included in the newer versions of the MinGW compiler. I found a solution to change those including to the followings:

#include <hidsdi.h>
#include <hidpi.h>

however, when I am trying to compile I get this error:

Building with 'MinGW64 Compiler (C)'.
Error using mex
Cannot export mexFunction: symbol not defined
C:\Users\AppData\Local\Temp\mex_2019355346950168_6584\hid_WINDOWS.obj:hid_WINDOWS.c:(.text+0xbe):
undefined reference to `HidD_GetHidGuid'
C:\Users\AppData\Local\Temp\mex_2019355346950168_6584\hid_WINDOWS.obj:hid_WINDOWS.c:(.text+0xd2):
undefined reference to `__imp_SetupDiGetClassDevsA'
C:\Users\AppData\Local\Temp\mex_2019355346950168_6584\hid_WINDOWS.obj:hid_WINDOWS.c:(.text+0xfe):
undefined reference to `__imp_SetupDiGetDeviceInterfaceDetailA'
C:\Users\AppData\Local\Temp\mex_2019355346950168_6584\hid_WINDOWS.obj:hid_WINDOWS.c:(.text+0x135):
undefined reference to `__imp_SetupDiEnumDeviceInterfaces'
C:\Users\AppData\Local\Temp\mex_2019355346950168_6584\hid_WINDOWS.obj:hid_WINDOWS.c:(.text+0x1fa):
undefined reference to `HidD_GetAttributes'
C:\Users\AppData\Local\Temp\mex_2019355346950168_6584\hid_WINDOWS.obj:hid_WINDOWS.c:(.text+0x24e):
undefined reference to `HidD_GetPreparsedData'
C:\Users\AppData\Local\Temp\mex_2019355346950168_6584\hid_WINDOWS.obj:hid_WINDOWS.c:(.text+0x25f):
undefined reference to `HidP_GetCaps'
C:\Users\AppData\Local\Temp\mex_2019355346950168_6584\hid_WINDOWS.obj:hid_WINDOWS.c:(.text+0x28a):
undefined reference to `HidD_FreePreparsedData'
C:\Users\AppData\Local\Temp\mex_2019355346950168_6584\hid_WINDOWS.obj:hid_WINDOWS.c:(.text+0x334):
undefined reference to `HidD_FreePreparsedData'
collect2.exe: error: ld returned 1 exit status

I am kinda lost. basically, I want to convert these c functions into Matlab functions and use them in my code, but I am not sure, where should I start.

I would greatly appreciate any hint and help.

Thank you,
David
 
Status
Not open for further replies.
Back
Top