Reading from device USB with MATLAB using CyUSB.dll

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
vishwasd19
Level 1
Level 1
10 replies posted 10 sign-ins 5 replies posted

Hello,

I am using an electroencephalogram (EEG) that uses a CyUSB.sys driver. I am looking to get the incoming EEG data into MATLAB.  I am not a coder, I have taken codes from people posting questions here in the community. some of the code I have tried to work out from "Cypress CyUSB .NET DLL Programmer's Reference". Buf is a byte type I thought using a 'uint' should do the job. Please, someone, help me write these transfer codes, or if they can share theirs that has worked for them. I have no clue how to write .net code in Matlab.

Here is a link to my previous threads.

https://community.infineon.com/t5/USB-low-full-high-speed/Reading-from-device-USB-with-MATLAB-using-...

CODE:

try
   
    CyUSBdll = NET.addAssembly('C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\bin\CyUSB.dll');
catch error
   error.message
   if(isa(error,'NET.NetException'))
       e.ExceptionObject
   else
       disp('CyUSB.dll already loaded');
       return;
   end
end
%%USB Device Select
% Create a list of USB devices
usbDevices = CyUSB.USBDeviceList(CyUSB.CyConst.DEVICES_CYUSB);
device=usbDevices.Item(0);



CEP=device.ControlEndPt;
CEP.Target=CyUSB.CyConst.TGT_DEVICE;
 CEP.ReqType=CyUSB.CyConst.REQ_VENDOR;  
  CEP.Direction=CyUSB.CyConst.DIR_FROM_DEVICE;  
  CEP.ReqCode=0xB0;  
  CEP.Value=0;
  CEP.Index=0;
  len=64;
   buf=uint(len);

CEP.XferData(ref buf, ref len);

Error:

Last line is giving me this error

vishwasd19_0-1647854329762.png

 

0 Likes
1 Solution
4 Replies
Meghavi
Moderator
Moderator
Moderator
250 replies posted 100 solutions authored 10 likes received

Hi,

- Can you please let us know which USB controller does it have i.e. FX2LP/FX3?

- Is it possible to share the firmware source code?

Regards

0 Likes

Hi Meghavi

It is FX2LP and all we have is the hardware and a driver and software developed by the hardware people, DLLs of which are not accessible.

0 Likes
vishwasd19
Level 1
Level 1
10 replies posted 10 sign-ins 5 replies posted
Also, in the last line if I change it to this
' CEP.XferData(buf, len);'
the error now is
No method 'XferData' with matching signature found for class 'CyUSB.CYControlEndPoint'.

 
0 Likes