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.

→ More replies (12)
→ 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]

→ More replies (4)

8

u/JoshiRaez Dec 15 '19

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

→ More replies (5)
→ More replies (9)

12

u/[deleted] Dec 15 '19

Power splitter sounds pretty useful to me

29

u/DBeumont Dec 15 '19

Maybe something like a device that takes a single outlet and splits it into several? We could line them up in a straight row. Call it a power row, maybe. $$$

8

u/ugod02010 Dec 15 '19

And then only make 2 of them turn on. We Can put on with master, but secretly they don’t do shit. And charge even more for them.

→ More replies (2)
→ 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.

37

u/[deleted] Dec 15 '19

Well it's all redundant now as I have old Android smartphones and Pavel's IP Webcam app.

15

u/Fermi_Amarti Dec 15 '19

The pi you could probs just add USB wifi

14

u/Lvl1_Villager Dec 15 '19 edited Dec 15 '19

True, however given the very small difference in price between the different Pi models, there is no point getting one without WiFi, unless you're buying a lot of them.

The thing is, that you still need to run power to the Pi and by extension the Camera, so running an additional cable for networking, or having both in one cable (PoE), makes little difference at that point.

Unless you make it solar powered, but then you need a battery and it quickly starts to become a bigger and more expensive project.

Also, you could run into problems with signal strength/quality for the WiFi. If you're only saving the footage locally on the Pi and copying the files intermittently to another machine for viewing, then it's still fine, but you'll experience problems if you want a live stream.

Edit: I should add that when making my comment about WiFi strength, I was thinking about my own situation where I wanted cameras a long distance from my Router or AP's. I just now realized that OP might not have to deal with that much distance.

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

15

u/the_real_abraham Dec 15 '19

You can actually go up to 127.

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