orgua / OneWireHub

OneWire slave device emulator
GNU General Public License v3.0
348 stars 89 forks source link

My version OneWireHub on IRQ #32

Closed valerivp closed 7 years ago

valerivp commented 7 years ago

I made a version that does not require constant polling of the port, and works completely inside the interrupt. This frees up resources for other tasks. I have this option is used for data collection (also inside the interrupt) with several wireless temperature sensors and presenting their data as a garland DS18B20. The object is made static, since it does not represent multiple similar objects in memory simultaneously, but it requires a static function handling the interrupt. Not much changed the logic OneWireItem - now he does not refer to OneWireHub. https://yadi.sk/d/dcJgSFr53HPEfC

The Serial debug does not affect performance and can be enabled always, since the output does not affect the delay With all this I get some I do not understand the error, and asking for help in removing them. In the screen shot. I simply ignore, but I want to completely remove

orgua commented 7 years ago

it would be easier to view your source on github. could you please make it available there? i thought about irq-versions too, but was afraid of the big overhead this solution introduces. For a proper implementation you need a big state-machine. By reading your text i think you just put the hub.poll() inside a irq-routine and therefore have to disable irq right on. Everything else means trouble because the routine will get called on every pin-change and we get a stack-overflow. IRQ-Routines should be as fast and short as possible. this means in our case that we should just save a timestamp of the last pin-change, feed it into the state-machine, act on it (e.g. receive a bit of data) and exit right away.