Make SimpleSerial into a multiple-cog accessable object.
photomankc
Posts: 943
I'm working on a custom driver for the Parallax 4x20 LCD for my thermostat project.· Last on the plate was the ability to set a backlight timeout without foreground attention.· To do this I made a simple little routine to fire off a cog to count-down milliseconds until it reaches zero or another backlight time request is made in which case it is reset to the request and starts over again.· When it reaches zero it clears the cog indicator and calls stop on itself.· I ran into lots of trouble though with simple_serial being touched by another cog.· The cog was launched from inside the LCD driver but if it touched the rx(byte) function that killed further communication and from then on no other text would be sent to the LCD.·
If I replace simple_serial with SerialMirror then it works just fine and backlight timer works just as I desire it.· However I do not need full duplex which just burns up a pin and I don't really want to use two cogs just to provide this function.· Does anyone know where I might start to make modify simple_serial work with multiple cogs?
If I replace simple_serial with SerialMirror then it works just fine and backlight timer works just as I desire it.· However I do not need full duplex which just burns up a pin and I don't really want to use two cogs just to provide this function.· Does anyone know where I might start to make modify simple_serial work with multiple cogs?
Comments
You could add code to the Simple_Serial object to get exclusive access when the init method is called and release exclusive access when the finalize method is called. You'd just have to have your two different cogs call init whenever they want to output something and call finalize when they're done. You'd have to make sure that each cog doesn't hog the serial object preventing the other from doing its work.