0
\$\begingroup\$

I have a project with a custom USB device that pumps out a stream of data every 1.125 seconds to a Raspberry Pi running Windows 10 IoT, and occasionally receives an 8-byte command. The USB device and the Raspberry Pi are in a custom enclosure and I've got a nice touchscreen going for basic interactivity.

I was kicking around the idea of having the option of plugging a real PC into the device and having that take over the operation of the USB device. Let's consider the device-to-Pi connection to be permanent, and that I can wire an external USB port to my enclosure that connects to the device. I understand that USB is a point-to-point protocol and I can't just use a y-cable. I am able to modify the USB device at the PCB level.

Is there a way to do this? Ideally, I'd like the device to detect when a PC has plugged in and override the device-to-Pi connection and permit two-way communication with the PC while it's connected.

BOUNS POINTS: Is there a way to still receive the data stream at the Raspberry Pi? This would solve some datalogging issues.

I did find this: http://www.ti.com/lit/ds/symlink/ts5usbc400.pdf. It sounds like it might work (I can use Vbus of the PC to toggle the logic somehow, maybe), just glancing at the datasheet. However, this doesn't solve the problem of the bonus question.

If it helps, the USB device uses an NXP MK66FX1M0VLQ18 microcontroller.

\$\endgroup\$

closed as too broad by Chris Stratton, Finbarr, Lior Bilia, PeterJ, Sparky256 Sep 17 '18 at 4:21

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    \$\begingroup\$ 2 Computers 1 USB device, is this something... crazy? \$\endgroup\$ – Harry Svensson Sep 10 '18 at 17:26
  • 2
    \$\begingroup\$ This just isn't how USB is intended to work. \$\endgroup\$ – Olin Lathrop Sep 10 '18 at 17:27
  • 6
    \$\begingroup\$ Why not have the PC get the data from the Pi over ethernet? \$\endgroup\$ – The Photon Sep 10 '18 at 17:27
  • 1
    \$\begingroup\$ @OlinLathrop I get that two simultaneous hosts isn't the right way to go, but by using a switch which has one selected at all times seems reasonable. Maybe my bonus question isn't possible, but switching hosts should be. There are commercial products that can do it, I'd just rather implement it at the board level. \$\endgroup\$ – Ben S. Sep 10 '18 at 17:30
  • 1
    \$\begingroup\$ @HarrySvensson: I see what you did there. \$\endgroup\$ – Rev1.0 Sep 10 '18 at 19:15
2
\$\begingroup\$

5 options:

1, use the usb switch you mentioned. Or one that can also switch power. That's exactly what they were designed to do.

2, use the second usb interface on the NXP device, and disconnect from the first usb interface/RPi when it detects a connection.

3, use both usb interfaces that your microcontroller has at the same time, one per host. Code the product to respond to only one control interface but spit data at both.

4, use the RPi as a middle man, not having the "real" (what is real 😉) pc connect to the usb device, but to the rpi via network, or the RPi usb peripheral connection.

5, use an alternative to usb, like bluetooth, ethernet, or wireless. Frankly, that microcontroller can act like a real pc as well.

\$\endgroup\$
  • \$\begingroup\$ Your suggestion #3 is completely unrealistic. Two hosts will emit periodic SOFs, and due to natural frequency differences between two hosts the SOF from one host will collide with EOF1-EOF2 prohibited interval of the second host, and second host will disconnect due to "babbling" condition after few minutes. And many other packet collisions will occur, because of no synchronization between host schedulers. \$\endgroup\$ – Ale..chenski Sep 10 '18 at 19:07
  • \$\begingroup\$ #4 is the best solution, Rpi-Zero-W will do. Verified. \$\endgroup\$ – Ale..chenski Sep 10 '18 at 19:17
  • 1
    \$\begingroup\$ @ale the microcontroller has two usb interfaces, both can be used at the same time. The USB packets would get replied to, the higher level control messages can be ignored. Ops data collector program may not even need to be modified. \$\endgroup\$ – Passerby Sep 10 '18 at 19:18
  • \$\begingroup\$ Okay, I misunderstood your #3. Two different devices on same SoC will work, agree. \$\endgroup\$ – Ale..chenski Sep 10 '18 at 19:26

Not the answer you're looking for? Browse other questions tagged or ask your own question.