throwing errors and GetUsbListEntry, Matlab

View previous topic View next topic Go down

throwing errors and GetUsbListEntry, Matlab

Post  JimHokanson on Tue Jul 25, 2017 5:04 am

I ran into an issue with having multiple devices (Mcs.Usb.CStg200xDownloadNet) connected to the same physical device. I was surprised to not find any errors, except for hard crashes (in this case of Matlab) when trying to make method calls with a device that had no serial number. While I can presumably do a better job ensuring a single connection to the device, I was surprised that no errors were being thrown.

Out of curiosity, I tried running code which gets the first entry from an entry list, with no devices attached. To my surprise I got back what looks like a valid device, although again the serial number was empty and the DeviceId (for example) had the following values:
IdVendor: None
IdProduct: None
BcdDevice: 0
BusType: MCS_UNDEFINED_BUS

Although it is clear that this is not a valid list entry, I am surprised that no error was thrown indicating an invalid request (i.e. requesting the first device when none are present - for GetUsbListEntry).

So the question is, is there some way of enabling errors. How is incorrect behavior supposed to be handled (in this case an in general)? Am I simply not seeing the documentation in regards to handling errors? My big concern is that I'll manage to do something wrong while convincing myself I am doing it right.

Thanks,
Jim

JimHokanson

Posts : 7
Join date : 2017-07-07

View user profile

Back to top Go down

Re: throwing errors and GetUsbListEntry, Matlab

Post  JimHokanson on Tue Jul 25, 2017 5:20 am

I should mention that in the case of the connection:
CMcsUsbNet.Connect

It does mention returning an error code (0 on success) which if non-zero can be interpreted with CUsbExceptionNet

And I also just found the EnableExceptions command for CMcsUsbNet.

This makes it clear that in some cases I need to be explicitly looking for exceptions. It also clears up my interactions with CMcsUsbNet, which is probably 99% of my code, but I'm still confused about the design approach for the other STG classes.

Thanks,
Jim

JimHokanson

Posts : 7
Join date : 2017-07-07

View user profile

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum