Hi. I have a similar problem. Have you been able to fix your Problem? Regards, Alex
I remember seeing the same problem. But I do remember that something inexplicable happened and it started to work.
I assumed it was some library linking magic (that is still inexplicable).
I know this is ambiguous and might not help much, nor am I a MATLAB expert. Can you try placing the .NET function in the Control Panel and link it to CyUSB.net?
If possible add the Matlab project here?
I meant link to Cyusb.dll.
Has anyone figured this out yet? I am currently stuck at the same step. I put CyUSB.dll in the same directory as my matlab .m file:
CyUSBdll = NET.addAssembly('C:\......\CyUSB.dll');
disp('CyUSB.dll already loaded');
% Create a list of USB devices
usbDevices = CyUSB.USBDeviceList(CyUSB.CyConst.DEVICES_CYUSB);
% USB Device Count
num_usbDevices = usbDevices.Count; % <=== returned 1 when the device is plugged in, 0 when it's not.
usbDevice = usbDevices.Item(0) % <===== matlab crashes here.
did you manage to figure it out ? I need to develop a similar application
Does anyone here has idea about how to interface Matlab to cyusb driver? I am working on building communication between Matlab and CY7C68013, but haven't got any good idea...
cyusb_lib = NET.addAssembly('d:\Matlab\FX3\CyUSB.dll') %Load the dll from wherever it is on your computer
devList = CyUSB.USBDeviceList(CyUSB.CyConst.DEVICES_CYUSB); % Fill a USBdeviceList object with all the details of the devices using the cypress driver
%you probably need to create callback functions for usb events (I called mine FX3_attach and FX3_detach). I haven’t made them useful yet but mine just looked like
function ret = FX3_detach(sender, args )
'detach callback called'
args.FriendlyName % prints the name of the device that was detached
then you can attach the listener using:
hAttached = addlistener(devList,'DeviceAttached', @FX3_attach);
hDetached = addlistener(devList,'DeviceRemoved', @FX3_detach);
% You can test the callbacks by pressing the reconnect button on the Cypress Control Centre
%loop through all the devices to find the one you want
for i=0: (devList.Count -1)
if ( devList.Item(i).FriendlyName == ‘Cypress FX3 USB BootLoader Device’); % or whatever you set the name to, could alternatively check Item(i).ProductID == 243
myDev = handle(devList.Item(i));
myEndpts = handle(myDev.Endpoints); % seems to be much easier if you create a handle to the endpoints as only the first of each type is automatically listed. while with a handle you can select any of them
myEndpts.Length %tells you how many you have
% myEndpts(1) should be the control endpoint
%for my code endpoints 3 and 4 are setup as bulk out and bulk in. they are also set to loopback data. So to send in data
%to receive data you need to set up a byte array first
rxBuffer = NET.createArray('System.Byte', length(data)); % fine as long as the length of the buffer is >= length of data returned
I have problem,
Why when I write in matlab devList.Item(0), matlab works no longer?
Without this feature you can not continue to work.
Does anyone have a solution for this?
I thank you in advance.