marefano
Posts: 1
Joined: Fri Jan 19, 2018 2:04 pm

Raspbetty pi and PC communication over USB protocol

Fri Jan 19, 2018 2:19 pm

Hi,
first of all, this is my first topic and I wanted to thank all those who will answer.

My scenario: i have a raspberry pi zero where run a linux distribution and a proprietary application.
It's not important what the application do, but is something that take-compute-send data.
I want to use only one connection among my pc and rasp pi. So this cable have to power the raspberry and have to send and receive data to/from it. I have seen that the OTG USB can do both.
But my problem is that i don't know how to set the OTG and i am concerned about which protocoll i have to use.
I can't use serial protocol because it's slow, i would use the usb protocol or something else with high boudrate.
Someone have any suggestion about?

Kind Regards
Stefano

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

Re: Raspbetty pi and PC communication over USB protocol

Fri Jan 19, 2018 5:46 pm

Sounds like you need the ethernet gadget.

I've a python script that takes care of some of the config and loads the g_ether module with MAC addresses drived from the Pi's serial number. See here: https://github.com/thagrol/usb-gadget/b ... xed_mac.py

A word of warning, B, B+, 2B, and 3B cannot be used as USB gadgets (there's a USB hub/ethernet chip in the way). Zero and ZeroW can, A and A+ may work but I've not tried them and the config may be different to that needed for the Zero(W).

Once g_ether is loaded you'l get a new netowrk device on the Pi and the PC, most probably USB0, and can send data over that as you would over any other network link.

Edit: if you decide to use that script you'll also need this one from the same repository: https://github.com/thagrol/usb-gadget/b ... tserial.py

Edit 2: corrected first link.
Arguing with strangers on the internet since 1993.

Return to “C/C++”