Connecting to USB Serial Device

Post Reply
theSuess
Posts: 8
Joined: Tue Feb 20, 2024 9:34 am

Connecting to USB Serial Device

Post by theSuess » Tue Feb 20, 2024 9:44 am

I'm porting an existing tool to the switch and the last piece of the puzzle is communicating with a device attached to the USB port. The existing implementation supports either libserial or libusb, both of which seem to be incompatible with the switch.

I think I should be able to rewrite the communication lib using usbhs, but I can't even get the switch to discover the device at all.
My current minimal code looks like this:

Code: Select all

memset(interfaces, 0, sizeof(interfaces));
memset(&filter, 0, sizeof(filter));
filter.Flags = 0
rc = usbHsQueryAllInterfaces(&filter,interfaces,sizeof(interfaces),&total_entries);
if (R_FAILED(rc)) printf("querying interfaces: 0x%x\n", rc);
if (R_SUCCEEDED(rc)) printf("queried interfaces. Found %d\n",total_entries);
When running this on hardware, no device is detected. I've tried multiple devices with no difference in outcome

Am I approaching this the right way, or is there a better way to talk to USB devices?

WinterMute
Site Admin
Posts: 1859
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: Connecting to USB Serial Device

Post by WinterMute » Tue Feb 20, 2024 2:45 pm

Help keep devkitPro toolchains free, Donate today

Personal Blog

theSuess
Posts: 8
Joined: Tue Feb 20, 2024 9:34 am

Re: Connecting to USB Serial Device

Post by theSuess » Tue Feb 20, 2024 3:27 pm

Sadly, that didn't work either in my case. I tried matching against the VID/PID with no results.

I'm not sure if I got the right values, so I'd like to just dump everything the switch sees - Is it possible to build a filter which matches almost every device?

WinterMute
Site Admin
Posts: 1859
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: Connecting to USB Serial Device

Post by WinterMute » Tue Feb 20, 2024 8:32 pm

You could try using UsbHsInterfaceFilterFlags_bcdDevice_Min for flags & set bcdDevice_Min=0 - that should pick up anything the system hasn't claimed for itself.
Help keep devkitPro toolchains free, Donate today

Personal Blog

theSuess
Posts: 8
Joined: Tue Feb 20, 2024 9:34 am

Re: Connecting to USB Serial Device

Post by theSuess » Wed Feb 21, 2024 6:09 pm

Found my issue.... I had sys-con loaded which claims all USB devices... Thanks for the help, learnt a lot about USB and the switch while debugging this. Now to actually talking to the device...

Post Reply

Who is online

Users browsing this forum: No registered users and 23 guests