Jump to content

OPi Zero OTG-USB communication like via ethernet


peter12

Recommended Posts

Hello, 

I am using OPi Zero with Armbian. From computer (Win or Ubuntu) or from other device with Android I am sending data to OPiZero device via LAN (many MBs/s). Now I would like to use for the same data communication via Opi's USB-OTG (because LAN has high latency). I read about g_serial and g_ether.


First question - I think g_ether mode is the best for my case (because of speed). Am I right?

 

I tried to find some basic tutorial, how to prepare Opi OTG for this. Is there any tutorial for this please? I would like to connect Opi with OTG to any Android device and my app on Android device (or Windows, or Linux) should be able to send data via OTG to Opi. (and yes, I read about a bit harder part to make it working on Win box, essential for me is Android and Linux box)

 

Many thanks in advance for pointing me right direction.

Link to comment
Share on other sites

I don't think you'll find much difference in terms of latency between a LAN or g_ether.

g_ether is supposed to make your device look like a USB ethernet device. Everything is still going to go through the network stack, so no latency savings there.

USB devices aren't the best when it comes to latency.  Unless both devices are USB3, you've got polling latencies and bus latencies.

 

I'd bet $5 a 100Mbit switched network would have lower ping latencies (less than 1ms) than a USG OTG network connection.

Not sure which would have a higher throughput, going via the USB stack would add extra CPU overhead.

Link to comment
Share on other sites

11 hours ago, chrisf said:

I don't think you'll find much difference in terms of latency between a LAN or g_ether.

g_ether is supposed to make your device look like a USB ethernet device. Everything is still going to go through the network stack, so no latency savings there.

USB devices aren't the best when it comes to latency.  Unless both devices are USB3, you've got polling latencies and bus latencies.

 

I'd bet $5 a 100Mbit switched network would have lower ping latencies (less than 1ms) than a USG OTG network connection.

Not sure which would have a higher throughput, going via the USB stack would add extra CPU overhead.

 

thank you for this feedback. And what do you think about Wifi latency? Will it be the same as LAN or worse?

Link to comment
Share on other sites

Thank you. I am trying to achieve the best speed and latency, so I thought via USB OTG will it be the best. Any idea?

 

My idea was to use USB OTG and communicate with OPiZero directly (many MBs/s and I need real-time aka close to no latency), so I could void all network components (such as routers, etc) - I have never used this type of communication before, so I am complete newbie with this, so any help is highly appreciated (such as which communication type to choose g_ether/g_serial/other, etc).

Link to comment
Share on other sites

I would suggest regular Ethernet. If you're worried about microsecond delays in a network switch, connect your OPi and PC together with a crossover cable.

 

At the end of the day though, you're not running a real time OS, so you're not going to get real-time latency.

 

What is your use-case that requires sub-millisecond latency? That's what you'll get with 10/100 Ethernet.

 

Here's some data:

On my local network, pinging an HC1 on the same switch is ~0.5ms

An XU4 going via two switches is also ~0.5ms

An expressobin via two switches is ~0.3ms

A router via 3 switches is ~0.2ms

Another router is ~0.3ms

 

The number of switches on the network doesn't really make a difference. The XU4 and HC1 have USB3 network adapters. The Espressobin has native (and it's own internal switch for the 3 ports), so does the router.

USB3 doesn't have the polling latency that USB2 does either.

 

The difference between the two routers is the 0.2ms one is an extra hop away, but it runs a proprietary real-time OS

The 0.3ms one runs Linux.

 

 

* this is a gigabit network, but latency isn't going to be much different with tiny ping packets.

 

Link to comment
Share on other sites

9 minutes ago, chrisf said:

What is your use-case that requires sub-millisecond latency?

my use case is analyze of fast changing pictures on device connected to Opi's USB OTG port. I am not able to use LAN crosscable between them, I just can use USB OTG or Wifi connection. So that is why I need to push "latency" and be as close as "real-time" possible. Example: connected device is sending data each 3ms, if I get it after another 5ms it means, these data are currently old because meanwhile another new data has been sent - so I need to push the "old" state as much as possibly, simply to say, to get the most fresh data.

Link to comment
Share on other sites

9 hours ago, peter12 said:

my use case is analyze of fast changing pictures on device connected to Opi's USB OTG port.

....

Example: connected device is sending data each 3ms

How big are these images? What are you even using to capture > 300 images per second on an Orange Pi Zero?

Link to comment
Share on other sites

29 minutes ago, peter12 said:

Images are 640x480px, so not so big data, but in uncompressed format. I am analyzing usually max. 60 images/s, in my case there is no need for 300 pics per second (for now).

What kind of analysis are you doing on the images? Hopefully your code is multi-threaded and making use of SIMD :)

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines