riggsre
Posts: 52
Joined: Fri Feb 10, 2012 5:25 pm

Re: USB communication with a PC

Mon Feb 20, 2012 5:23 pm

How about have the Pi output the information to a html page and the PC reads the info from the "web" page and manipulates the data. I'm not good enough to do it but I bet a good Java programmer could.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 25430
Joined: Sat Jul 30, 2011 7:41 pm

Re: USB communication with a PC

Mon Feb 20, 2012 5:54 pm

riggsre said:


How about have the Pi output the information to a html page and the PC reads the info from the "web" page and manipulates the data. I'm not good enough to do it but I bet a good Java programmer could.


That's a pretty easy solution to the problem. wget on the host to get a page created by a cgi script on the Raspi via a simple webserver.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I own the world’s worst thesaurus. Not only is it awful, it’s awful."

Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: USB communication with a PC

Mon Feb 20, 2012 5:59 pm

@JamesH:

1) Regarding the boldface type.  Yes, it is a combination of the forum software and my dodgy browser (a platform/software combination so weird that it isn't worth describing).  I note that no one seems to have anything good to say about this software (Wordpress), but, FWIW, I don't really see it as any worse than any of the other web-based forum softwares that I've seen.  They all seem equally bad to me.

Anyway,  it seems I could never quite get the hang of quoting here (this software), no doubt because of my browser.  I am aware of the problem (I.e., I can see that it is coming out in bold - be thankful, at least it is not in all caps...), but just haven't been awake enough to go back in and fix it.

2) Regarding the "XY Problem".  Did you Google it as I suggested?  If so, you'd see that we're on the same side here.  I was just trying to give some explanation for the OP's frustration with this thread -> It is classic "XY".  Everyone is trying to solve his problem, by ignoring his question.  Amusing - that's all I'm saying...
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

riggsre
Posts: 52
Joined: Fri Feb 10, 2012 5:25 pm

Re: USB communication with a PC

Mon Feb 20, 2012 6:26 pm

Joe Schmoe said:


@JamesH:

1) Regarding the boldface type.  Yes, it is a combination of the forum software and my dodgy browser (a platform/software combination so weird that it isn't worth describing).  I note that no one seems to have anything good to say about this software (Wordpress), but, FWIW, I don't really see it as any worse than any of the other web-based forum softwares that I've seen.  They all seem equally bad to me.

Anyway,  it seems I could never quite get the hang of quoting here (this software), no doubt because of my browser.  I am aware of the problem (I.e., I can see that it is coming out in bold - be thankful, at least it is not in all caps...), but just haven't been awake enough to go back in and fix it.

2) Regarding the "XY Problem".  Did you Google it as I suggested?  If so, you'd see that we're on the same side here.  I was just trying to give some explanation for the OP's frustration with this thread -> It is classic "XY".  Everyone is trying to solve his problem, by ignoring his question.  Amusing - that's all I'm saying...


Huh? maybe posted in wrong thread?

User avatar
panik
Posts: 369
Joined: Fri Sep 23, 2011 12:29 pm
Location: Netherlands

Re: USB communication with a PC

Mon Feb 20, 2012 7:56 pm

Deus said:



+1 to the usb to rs232 adapter.  I"ve used several and have been generally quite satisfied with them


Many PC"s don"t have rs232 ports (including mine). I want to be able to give this to someone else without a hassle.


The idea of these adapters is that you don"t need an RS232 port. Only a USB port. These come in all shapes and sizes, from USB to 9-pin, but also from USB to 3.3V or 5V logic levels. On a breakout board or in a neat cable.

edit: http://www.ftdichip.com/Produc.....Cables.htm

edit2: (grrr... forum software)

rpt said:


Easiest solution is two USB-RS232 adapters and a null modem cable. I use that all the time at work.


Found this: http://www.ftdichip.com/Produc.....BtoUSB.htm
Microcontroller addon boards and software for Raspberry Pi A+/B+/Pi2:
- ARMinARM: ARM Cortex-M3 (STM32)
- AVRPi: ATmega32U4 & ATmega328 ("Arduino")
http://www.onandoffables.com

spurious
Posts: 343
Joined: Mon Nov 21, 2011 9:29 pm

Re: USB communication with a PC

Mon Feb 20, 2012 8:40 pm

Deus said:



Why is it right?



Ethernet is designed for communication between two computers, USB is designed for communication between a computer and a peripheral.

R-Pi is a computer not a peripheral.

The simplest method to achieve the communication you are trying to get is through Ethernet, not over the USB port.

I was trying to help you simplify you quest, as a lot of the responses were literally answering your question, which seems a very convoluted approach to a very simple problem.

But if you want to do it the hard way, then just ignore me.

User avatar
abishur
Posts: 4477
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
Contact: Website

Re: USB communication with a PC

Mon Feb 20, 2012 8:58 pm

spurious said:


Deus said:



Why is it right?



Ethernet is designed for communication between two computers, USB is designed for communication between a computer and a peripheral.

R-Pi is a computer not a peripheral.

The simplest method to achieve the communication you are trying to get is through Ethernet, not over the USB port.

I was trying to help you simplify you quest, as a lot of the responses were literally answering your question, which seems a very convoluted approach to a very simple problem.

But if you want to do it the hard way, then just ignore me.



Technically, the simplest method is the one that the OP is most comfortable with and presumably has existing knowledge in

While I certainly agree that a USB->USB crossover cable seems wasteful (it's basically doing TCP/IP over a USB connection anyway, and it usually cost a pretty penny), if the OP is familiar with sending data over serial com ports, then there's no reason not to do a usb->serial->serial->usb sort of connection.

So OP, what sort of solution seems like the best choice based on what you know and have been presented in this thread?
Dear forum: Play nice ;-)

User avatar
Vindicator
Posts: 314
Joined: Sat Sep 17, 2011 11:10 pm
Location: Susanville Ca USA
Contact: Website

Re: USB communication with a PC

Mon Feb 20, 2012 9:01 pm

The person who posted the USB to USB null modem cable has seemed to answer the original poster's question as he wants to use USB.

Make sure to do your home work so as to not damage your devices.
If you are more worried about ,spelling, punctuation or grammar you have probably already missed the point so please just move on.

bitplane
Posts: 25
Joined: Sun Jan 08, 2012 6:20 am
Contact: Website

Re: USB communication with a PC

Thu Feb 23, 2012 8:59 am

How would a GPIO banging metal USB solution work? Are we talking a micro-sd port soldered to some minimal number of components, and some already available free software driver to allow the device to act as a USB device?

I'm not really a hardware guy but if I'm understanding this correctly, this sort of thing would allow all kinds of crazy USB hackery…


The cheapest pass-through USB protocol analyser ever, to assist in creating Linux drivers for devices that are Windows / Mac only.
A portable printer that collects data from an offline machine, stores to SD so you can send to a real printer later. 

Presenting a dynamic, virtual filesystem to some other device as USB mass storage:


Network, auto-transcoding filesystem for a TV with USB port
An SD card reader

Emulating input devices:


Using it as a keyboard logger (naughty!)
Automating inflexible, proprietary software/hardware solutions.
Combined with a Bluetooth dongle, use your phone's sensor hardware as a wireless games controller (Xbox, Wii, etc) or graphics tablet (PC, Mac)



Emulating mobile devices like iPhone, Android and so on. Maybe pretend to be a known device to sync all info from a computer (naughty!)
Emulate some new technology to make old / incompatible technology work, or vice versa. No Mac drivers for the USB printer / scanner / camera / joystick / trackball / microphone / barcode reader that you just inherited? No problem!

Plus a million and one other things that I''m not smart enough to think of, but would make great little projects for anyone interested in such things.
edit: forum doesn't like multi-level bullet-points

Tomo2k
Posts: 127
Joined: Mon Dec 19, 2011 10:00 pm

Re: USB communication with a PC

Thu Feb 23, 2012 8:01 pm

bitplane said:


How would a GPIO banging metal USB solution work? Are we talking a micro-sd port soldered to some minimal number of components, and some already available free software driver to allow the device to act as a USB device?


It wouldn't. Not fast enough, and re-implementing the USB Device stack that way would be seriously hard.

On Model A (not possible on the B) it might be plausible to enable the USB-On-The-Go feature. No idea how complex that is.

To the OP: Two simple solutions:

A) Use a USB to serial adapter on the 'host' PC and connect to the RPi using either another USB to serial or the serial port on the GPIO.

B) Use Ethernet – UDP sockets are easier than TCP ones.

UDP is individual 'datagrams' – the receiver automatically knows exactly how long each message is, so there is no need for any kind of 'start' or 'end of message' markers like with serial (or TCP).

You just get a lump of data and use it.

If you broadcast or (better but harder) multicast UDP, then you don't even care about the IP of the RPi or the PC at all – it quite simply Just Works.

Look on this page for examples of using Qt to send and receive datagrams – Unicast, Multicast and Broadcast.

User avatar
Emanuele
Posts: 182
Joined: Wed Aug 03, 2011 5:28 pm
Contact: Website

Re: USB communication with a PC

Sun Feb 26, 2012 9:20 am

I too think that it would be nice if model A could be configured to act as an USB device. To me it seems it would be an attractive solution for cross development.

It would be cheaper (you can buy model A instead of model B and you can find male to male USB cables for 1 quid or so) and maybe even more convenient (on a modern PC it is not unusual to have several USB ports that are very easy to reach).

I see no reasons why it could not be made easy to use too. Tethering a wireless network using USB on an Android 2.2+ phone certainly is (you just see a network interface (module: usbnet, device: usb0) ; it is so easy that I don't even bother looking for wireless adapters that work under linux anymore).

drgeoff
Posts: 10329
Joined: Wed Jan 25, 2012 6:39 pm

Re: USB communication with a PC

Sun Feb 26, 2012 3:52 pm

Emanuele said:

... and you can find male to male USB cables ....

I was going to challenge that statement but it seems to be true!

http://www.ebay.co.uk/itm/USB-.....3cba1d46a3

I wonder what they are used for.

User avatar
Emanuele
Posts: 182
Joined: Wed Aug 03, 2011 5:28 pm
Contact: Website

Re: USB communication with a PC

Sun Feb 26, 2012 4:57 pm

drgeoff said:


Emanuele said:


... and you can find male to male USB cables ....


I was going to challenge that statement but it seems to be true!

http://www.ebay.co.uk/itm/USB-.....3cba1d46a3

I wonder what they are used for.



I have one and I use it to connect a 2.5" HDD enclosure. By the way, the enclosures themselves are quite cheap (around 5 quids) and I would imagine they come with the cable included (mine did).

drgeoff
Posts: 10329
Joined: Wed Jan 25, 2012 6:39 pm

Re: USB communication with a PC

Sun Feb 26, 2012 5:32 pm

Emanuele said:


drgeoff said:


Emanuele said:


... and you can find male to male USB cables ....


I was going to challenge that statement but it seems to be true!

http://www.ebay.co.uk/itm/USB-.....3cba1d46a3

I wonder what they are used for.


I have one and I use it to connect a 2.5" HDD enclosure. By the way, the enclosures themselves are quite cheap (around 5 quids) and I would imagine they come with the cable included (mine did).



That is not in line with the USB design goals.  To quote from http://en.wikipedia.org/wiki/U.....Serial_Bus

"The standard connectors were deliberately intended to enforce the directed topology of a USB network: type A connectors on host devices that supply power and type B connectors on target devices that receive power. This prevents users from accidentally connecting two USB power supplies to each other, which could lead to dangerously high currents, circuit failures, or even fire."

User avatar
Emanuele
Posts: 182
Joined: Wed Aug 03, 2011 5:28 pm
Contact: Website

Re: USB communication with a PC

Sun Feb 26, 2012 6:42 pm

drgeoff said:

That is not in line with the USB design goals.  To quote from http://en.wikipedia.org/wiki/U.....Serial_Bus
"The standard connectors were deliberately intended to enforce the directed topology of a USB network: type A connectors on host devices that supply power and type B connectors on target devices that receive power. This prevents users from accidentally connecting two USB power supplies to each other, which could lead to dangerously high currents, circuit failures, or even fire."



I was surprised too when I saw the cable that came with the enclosure and the standard is surely very well designed in not allowing two hosts to be connected together unintentionally.

On the other hand, if model A could be configured to act as an USB device, I personally would have no problems using it like one, even if that would mean using a non standard cable.

spurious
Posts: 343
Joined: Mon Nov 21, 2011 9:29 pm

Re: USB communication with a PC

Sun Feb 26, 2012 7:09 pm

if this were to be done it would make sense to use the micro USB port that provides power and then a standard cable can be used.. but I have no idea how problematic that would make the board design.

Return to “Other projects”