orgua / OneWireHub

OneWire slave device emulator
GNU General Public License v3.0
343 stars 86 forks source link

how to build a generic slave for arbitrary code? #90

Open level20peon opened 3 years ago

level20peon commented 3 years ago

I am trying to build a slave which doesn't emulate an actual device but rather just uses the OneWireHub message framework in order to execute arbitrary code.

More specifically, I am talking to an AtTiny85 and want it to answer according to the data I sent to it (so something like "switch (cmd) { case 0x4E:..." hub->send('foo')). Unfortunately I don't know how to accomplish this, so what would you suggest I use as a codebase in order to emulate such a kind of slave?

I got the general attiny85-4slaves.ino up and running, but there's no input open which I could send data to (I can only poll the temperature of the DS18B20 via "cat /sys/bus/w1/devices/28-0b020b08010d/w1_slave" using a Pi). Could you point me to some example please? From what I read I need the "output" and the "state" file descriptors on the onewire device. I added the DS2408 device to the attiny demo, but I am unable to write anything to the state descriptor and while skipping the source code I don't understand how those descriptors are generated in the first place (there is no reference to "output" or "state" in the DS2408 header and cpp source files.

Maybe somebody already accomplished what I am trying to do? Any help would be greatly appreciated!