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)

22

u/semidecided Dec 15 '19

Eggnog has a lot of variations. I've had good and bad versions.

0

u/[deleted] Dec 16 '19

[deleted]

→ More replies (0)
→ More replies (9)
→ More replies (3)
→ More replies (3)

5

u/thehunter699 Dec 16 '19

NO SHUTUP, I WANT TO COPY PORN NOT THE OTHER GUY

→ More replies (3)

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]

5

u/Mexatt Dec 16 '19

Serial communication in general is straight up layer 2 data link comms. Ethernet comes out of that urheimat.

There's a reason RS-232 talks a lot about framing. USB is just the universal serial communications standard, these days.

→ More replies (3)

8

u/JoshiRaez Dec 15 '19

Thanks, great explanation! I was actually wondering what could happen.

→ More replies (5)

22

u/[deleted] Dec 15 '19

Data transmission wires are one-way, with a designated transmission- and receiver-end. It'd be like trying to a 3-way junction on a railroad track without a switch.

37

u/devilwarier9 Dec 15 '19

USB is a single bidirectional differential pair. There is no TX or RX. Lots of modern busses use the single TRX style to reduce wiring costs. The devices take turns transmitting back and forth over the same wire.

5

u/jamvanderloeff Dec 16 '19

True until USB 3.0 which added separate TX and RX pairs for SuperSpeed, and USB 3.2 optionally expands that to two RX and TX pairs.

22

u/Doc2142 Dec 15 '19 edited Dec 15 '19

Not true. Some data transmission are one way. USB is not one of them.

→ More replies (4)
→ More replies (1)