Hardware agnostic swtiching

Selfbondage software and other kinky developments

Moderators: Riddle, Shannon SteelSlave

Post Reply
rsubspanked
*
Posts: 1
Joined: 23 Feb 2015, 12:39

Hardware agnostic swtiching

Post by rsubspanked »

I've followed this forum for quite a long time, but never posted. So hello there.

Anyway, I've always been tasked with stuff like databases, analysis, comm, data encoding, so I get very little time to play with the idea of, “why can't my pc turn on the lights, or heck, reset a router.” But when I do have a little time to mess with it, I come across the real problem that every single way of having a pc turn a switch on and off, involves a custom-like combination of a specific library/application and a specific vendor's piece of hardware. My irritation with this dates back all the way to using an ISA relay board in an 80386....

So, eg, I write a program designed for a pair of relays that open or close a pair of circuits attached to a xxxbdsm device, and another to turn off an electromagnet after a certain amount of time to release keys. Not particularly hard....

but... say I give it to Bob the Perv. Unless he has THE relay board I'm using; it won't work.

So my most recent recreational foray involved writing a class library, that wraps the relay hardware library or driver api. I don't think I approached it quite right the last time, so I'm planning to make another poke at it.

I think the wrapper needs to look like

class RelaySwitch
close(); / on(); open(); / off(); getState();
spawn an async thread - close(int ms); / on(int ms); open(int ms); / off(int ms);
some boards have timer commands in them, but that again binds you to a particular hw type

class RelayList
init(); addby(type, a, b) // Ethernet(ipaddr, port); SystemPort(int xport);
count(); assignName(IdType id, string textid); // assign textid to relay #id
getAssignmentList(); // tab delimited set of id, text pairs; encrypt and stuff in registry or file
RelaySwitch getRelay(IdType x);
RelaySwitch getRelay(string x);

Underneath, the idea is that init(); fishes for a variety of known relay controllers that have known drivers, say, like phidget; or those using generic usb HID; addby allows the end user to add their device simply by its hardware location; software records this to registry/file and uses on future startup.

Trick I think involves getting a unique and persistent id for each relay device found on init();/addby() so if it finds an Ethernet board, IdType would include a MAC and a relay port number; an HID by product id and serial (or bus position if no serial); that sort of thing. Direct bus board would have a port#, etc.

OS specific problems exist in threads, usb comm, networking, eg, getting to the same usb relay board from a Windows machine will be different than getting to it from a unix machine. Etc. So the plan is to write to windows, but isolate the OS specific stuff as much as possible.

I like this approach, because you get a piece of pervy software, and name the relay channels in a single spot; and then the software and ui are consistent through all runs, always calling the relay that drops the key, “KeyRelease”, and always calling the one that squirts you with pee, “SquirtVictim”. If you then send it to Bob, and he uses a completely different set of hw, he still only has to do a config dialog to ID the relay attached to the squirter and the relay attached to the magnet.
So the package should likely include an “example” that includes a completed dialog class to show what relays RelayList finds, and allows the user to test, name, and add/configure their hardware.

There are also devices that provide various inputs, but I've not gone there, as the first problem of hardware agnostic relay api keeps bugging me.

If you get down to it, this, in my opinion is why the Arduino's etc are successful; because Relay 1 on is the same for Bob's relay as it is for Ivan's. It doesn't happen on the PC environment, because the people that would do it, are also in a very cutthoat competition for a small market with each other...

Any thoughts would be helpful. Maybe this third try I've thought everything through well enough to be satisfied with the result, but if you see something I'm overlooking...

A passing thought... the reason “CD Tray release” is a thing? Its the only thing common to most all PCs that has a switch type api (open/close tray) that interacts with the real world. Imagine if you could have real switches, and the software you use to toggle that switch doesn't care whether that switch is an ethernet relay in the attic, or a little USB switch, or whatever.
User avatar
Sir Cumference
Moderator
Posts: 1606
Joined: 29 Jan 2012, 22:00
Location: Scandinavia

Re: Hardware agnostic swtiching

Post by Sir Cumference »

you put a finger on something that has annoyed me too.

We have all this processing power, and the computers are basically limited to input through the keyboard, and output through screen and speakers.
(that is on the other hand all you need to watch cat videos and surf porn, satisfying 98% of the regular users. :facepalm: )


And yes. The arduino is cheap and easy to use.
:love:


The problem about making something new to interact with the world, is that it has to reach critical mass before anything really happens.
~ Leatherworking, blacksmithing , woodworking and programming are the most pervertable skills you can learn! ~
jands
*
Posts: 11
Joined: 21 Feb 2015, 08:41
Location: Australia

Re: Hardware agnostic swtiching

Post by jands »

I remember years ago making a very basic I/O controller using a old PC and a LPT parallel port, which alot of desktops are still coming with, very usable, only really need a few transistors and a relay and you have a great way to interface to the outside world.

Side note: A little device I came across along time ago, which I have used many a time is a device called the DACIO 300 made by a UK company Tronisoft. It is extremely easy to program for and is very cheap. They come standard with a RS232 connector via a MAX232, which i promptly removed and replaced with a inexpensive USB to TTL converter I found on eBay for $3. Add that to a 8 port 5v relay board. It communicates through a comport. The reason I love the idea of simple comms through a com port is that I have used these in a situation where I was not at the PC, so I created a virtual comm port, and can control these from anywhere over the internet.
Post Reply