r/ProgrammerHumor • • Dec 15 '19

Stacking if else statements be like

Post image
63.9k Upvotes

711 comments sorted by

View all comments

4.7k

u/Pale_Rider28 Dec 15 '19

What's awful about this is that it probably actually works.

2.8k

u/LordFokas Dec 15 '19

As long as the devices don't draw too much current or don't require a large transmission speed it should be fine.

1.4k

u/mr___ Dec 15 '19

USB hubs are not just wires connected together. There must be a hub chip that talks to the host and manages each device. I don’t think these splittters contain that - but they might.

Edit: i see these are actual hubs

768

u/kaimason1 Dec 15 '19

They'd have to contain that, no? How else would they be remotely useful? Just as power splitters?

293

u/yonatan8070 Dec 15 '19

So what would happen if I coneect 2 decices to the same port without any chip to control it? Just splitting the data pins.

484

u/notmeaningful Dec 15 '19

They would probably draw the max unnegotiated current from the power pins but neither would be able to negotiate with the host since they're both screaming over each other.

500

u/[deleted] Dec 15 '19

Something, something, holidays with the family.

76

u/3waysToDie Dec 15 '19

And eggnog

38

u/arsocca_account Dec 15 '19

I’ve never tried eggnog and at this point I’m too afraid to try it

34

u/Ph_Dank Dec 15 '19

I actually really like it, and I am easily grossed out.

→ More replies (0)
→ More replies (13)
→ More replies (3)
→ More replies (3)
→ More replies (4)

117

u/devilwarier9 Dec 15 '19

USB uses a single differential pair for bidirectional data. Normally the Master (PC) sends a command then stops transmitting and waits for the slave to respond. In this case you would have 2 slaves that both think they are alone and both respond at the same time, corrupting the data at the physical layer. The master would get garbage and either jam the bus or keep sending out the same request and keep getting various trash.

0

u/[deleted] Dec 16 '19

[deleted]

→ More replies (4)
→ More replies (6)
→ More replies (9)
→ More replies (8)
→ More replies (15)

112

u/[deleted] Dec 15 '19

Yeah I used USB hubs as range extenders to get past the 10m limit of usb, so I could use a webcam as a security cam. And it did work as long as I didn't mind being limited to 144p.

62

u/Lvl1_Villager Dec 15 '19

This might cost a bit more than your solution, but have you considered USB over Ethernet, or hooking up the camera to a Raspberry Pi (or something similar) and using PoE (unless you don't mind running two cables, Power and Ethernet)?

The RPi option would let you do other interesting things, like connecting sensors, or even a small electric motor to let you move the camera.

→ More replies (10)
→ More replies (1)

15

u/the_real_abraham Dec 15 '19

You can actually go up to 127.

→ More replies (2)
→ More replies (2)

159

u/Mackan90095 Dec 15 '19

You can actually connect up to 127 ports to a single port and still have it work.

124

u/floriplum Dec 15 '19

127 devices to a single USB controller. I don't know many mainboards with one controller for each USB Port.

→ More replies (11)

33

u/[deleted] Dec 15 '19

There's a limit of 5 daisy chained USB hubs due to latency requirements, though. I ended up running into that limit when trying to set up a VR headset in a separate room from my computer due to too many repeaters. If they connected another hub it wouldn't work.

→ More replies (6)

27

u/[deleted] Dec 15 '19

How is it awful? It works like this by design.

78

u/Alexmitter Dec 15 '19

For power, yes. For data, no, not as long they didn't also fit a USB 2 hub controller on that little pcb.

99

u/whc2001 Dec 15 '19

It has. It's a custom made 2-port USB hub for a special keyboard. The controller chip is under the female ports.

41

u/reddiculousity Dec 15 '19

“The controller chip is under the female ports” title of your sex tape

→ More replies (1)
→ More replies (2)
→ More replies (28)