emw
Posts: 52
Joined: Tue Apr 12, 2016 2:53 pm

simultaneous usb gadget and host

Wed Sep 26, 2018 7:50 pm

I want to use a Raspberry Pi Zero W to capture (and manipulate) data between a computer and a usb printer. I was thinking I could set up two usb ports - one a host USB port, the other a device (gadget) port. The gadget port would have to be configured to look like the printer.

Unfortunately the pi only has one OTG port, and I have not been able to find a hat to add a second port. I suppose I could add a usb chip via gpio, but that will also requires a bunch of driver coding. Its been a few year since I have done any driver work, so I am try to avoid this option. Does any one have any suggestions on how to add and addition Host or device port (not hub).

User avatar
thagrol
Posts: 3776
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: simultaneous usb gadget and host

Wed Sep 26, 2018 8:16 pm

Would any of the USB host addons or chips for arduino and clones do the job of providing a second host? I'd guess you'd need drivers though.

It will also depend on what you want the zero to appear as to it's host device. Without writing your own code there is only a limited set of devices it can emulate and your printer isn't likely to be one of them.

If you want the zero to be transparent to the printer and printee, I suspect that's not going to be easily possible.

As an alternative, rather than using USB for the incoming traffic to the zero, could you achieve the same end result by using it as a network print server?
Arguing with strangers on the internet since 1993.

emw
Posts: 52
Joined: Tue Apr 12, 2016 2:53 pm

Re: simultaneous usb gadget and host

Thu Sep 27, 2018 2:32 pm

Thanks for the comments thagrol,

No, I can't use a network printer, I don't have the option of changing the interface to a network interface.

As for addons or chips for arduino... that has some potential. I see there has been some work with the MAX3421E. There is also a linux driver this chip. I have found some questions from people trying to get it working on the pi, but it does not look anyone has gotten it working yet.

User avatar
thagrol
Posts: 3776
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: simultaneous usb gadget and host

Thu Sep 27, 2018 2:47 pm

Another thought occurs:

Use two Pi. One zeroW to act as the USB slave device communicating over a private WiFi network or GPIO to a second Pi that hosts the printer. I never looked very far into this but I believe software exists for sharing USB ports/devices over a network.
Arguing with strangers on the internet since 1993.

ejolson
Posts: 6042
Joined: Tue Mar 18, 2014 11:47 am

Re: simultaneous usb gadget and host

Fri Sep 28, 2018 4:20 pm

thagrol wrote:
Thu Sep 27, 2018 2:47 pm
Another thought occurs:

Use two Pi. One zeroW to act as the USB slave device communicating over a private WiFi network or GPIO to a second Pi that hosts the printer. I never looked very far into this but I believe software exists for sharing USB ports/devices over a network.
You could also pair the two Pi Zero W computers using Bluetooth, as it is suitable for point-to-point short range communication.

Return to “Advanced users”