I’m trying to use the new uart callback function instead of polling. However I’m struggling to make good use of it, because I cannot pass any context with the callback. I’m also not very familiar with squirrel so I might be missing something.
It seems like I can pass a function defined in a class as callback, but when the callback is called it does not seem to be called in the class instance context, e.g. I cannot add the received data to an instance variable in that object.
Are the callback function only be usable in a global context, which seems to be a pretty limited use case or is there another way to make that work?
I don’t quite understand it why I need to explicitly bind ‘this’ as the class instance should always be bound. At least that’s what the squirrel docs say:
while by default a squirrel function call passes as environment object ‘this’, the object where the function was indexed from.
But probably this doesn’t apply when passing the function reference as callback.
Anyhow, it works now. Now I have to figure out why I just receive garbage from the UART …
yeah, I’m pretty sure it is a baudrate issue. Trying to attach an electric imp to a Honeywell Rondostat thermostat, which I flashed with an open source firmware. The amtel is running with an internal frequency, which isn’t very accurate I guess.
The imp baudrate doesn’t need to be a “round” number (eg 9600bps, 19200bps); if you want to run at 9,250bps then just specify that in the uart configure call. Might help?