rpi350
Posts: 3
Joined: Thu Jan 18, 2018 5:11 am

Sending bits to a computer via USB from Rpi

Thu Jan 18, 2018 5:19 am

Hello, I was wondering how I could send a byte array of 16 or more bytes from the pi to a computer, where the computer would receive it via USB. How would it be possible? If possible, could you please include links of any tutorials or videos?
Should I use UART? Could UART send a byte array of this length?
I have sent them over via wifi, using sockets on python, now I need to send them over USB, as it is faster and more reliable.
Thanks!

User avatar
topguy
Posts: 4344
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Sending bits to a computer via USB from Rpi

Fri Jan 19, 2018 9:36 pm

I would say that using two usb2serial converters and a nullmodem cable between them might be fairly simple solution. Yes you can also use the UART at the Pi side instead of one of the usb2serial converters.

But I'm not convinced it will be faster than networking, it might be more predicable in transfer speed. What kind of speeds do you need ?

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

Re: Sending bits to a computer via USB from Rpi

Sat Jan 20, 2018 12:10 pm

If your pi is a zero or zerow you can use it in USB gadget mode. The most useful in your case would be g_ether, g_serial, or g_multi

The g_ether module would allow your existing socket based code to run without modification other than to which network interface and IP address to use.
Note to self: don't feed the trolls

rpi350
Posts: 3
Joined: Thu Jan 18, 2018 5:11 am

Re: Sending bits to a computer via USB from Rpi

Sun Jan 21, 2018 2:15 am

Hi @topguy, I linked up sensors to the rpi and what it needs to do is as soon as any event occurs, it needs to send a signal to the computer right away.
Now the only thing I need to do is to send it over to the PC via USB, as wifi or any networking would not be reliable.
Could you please elaborate or provide me any link with how this usb2serial converters and a nullmodem cable would need to be set up?
Thank you for your response!
@thagrol, I am using rpi 3 model B, so I can't make it work like a USB gadget. Also, sadly, the pi can't also be connected to the PC using USB as both the PC and rpi are masters, hence my question.
Thanks for your response!

User avatar
fruitoftheloom
Posts: 16430
Joined: Tue Mar 25, 2014 12:40 pm
Location: Bognor Regis UK

Re: Sending bits to a computer via USB from Rpi

Sun Jan 21, 2018 3:44 am

rpi350 wrote:
Sun Jan 21, 2018 2:15 am
Hi @topguy, I linked up sensors to the rpi and what it needs to do is as soon as any event occurs, it needs to send a signal to the computer right away.
Now the only thing I need to do is to send it over to the PC via USB, as wifi or any networking would not be reliable.
Could you please elaborate or provide me any link with how this usb2serial converters and a nullmodem cable would need to be set up?
Thank you for your response!
@thagrol, I am using rpi 3 model B, so I can't make it work like a USB gadget. Also, sadly, the pi can't also be connected to the PC using USB as both the PC and rpi are masters, hence my question.
Thanks for your response!

Yes you can connect a RPi and a PC via USB using an Active Cable see:

viewtopic.php?f=36&t=131042
""understanding the theoretical, but not always the end goal""

My other Devices are the ChromeBit CS10, ChromeCast & Huawei Mate 10 Pro SmartPhone

rpi350
Posts: 3
Joined: Thu Jan 18, 2018 5:11 am

Re: Sending bits to a computer via USB from Rpi

Mon Jan 22, 2018 4:39 pm

Hi fruitoftheloom,
Unfortunately I don't have any control on the other end. The other end runs windows and it won't be possible to run linux on it. Thanks though!

User avatar
fruitoftheloom
Posts: 16430
Joined: Tue Mar 25, 2014 12:40 pm
Location: Bognor Regis UK

Re: Sending bits to a computer via USB from Rpi

Mon Jan 22, 2018 5:02 pm

rpi350 wrote:
Mon Jan 22, 2018 4:39 pm
Hi fruitoftheloom,
Unfortunately I don't have any control on the other end. The other end runs windows and it won't be possible to run linux on it. Thanks though!

Theoretically it should work with Windows, but I was unable to check as have no Windows Machine...
""understanding the theoretical, but not always the end goal""

My other Devices are the ChromeBit CS10, ChromeCast & Huawei Mate 10 Pro SmartPhone

Return to “Beginners”

Who is online

Users browsing this forum: No registered users and 7 guests