As the title says... Chat on...

User avatar
By gschulz
#63778 In my application, I need to send a continuous stream of bits without interruption. I tried the SPI bus, but can't get it to run without interfering with other tasks (i.e WiFi slows down or crashes). I found that the gpio.serout function set to -1 loops does exactly what I want, except I would like to periodically change the sequence that is being transmitted. I can tolerate a random delay when restarting the sequence, which happens rarely, but I can't tolerate a significant delay on a regular basis. If I set the serout sequence to run once, then callback to reload, there is a random delay of several mS added, which becomes several seconds if WiFi is accessed.

My question: Is there any way to terminate the gpio.serout sequence (cleanly, before it is finished) and restart with a different sequence?

Ideally, I just need to change the data in the sequence array. I don't have to stop the actual loop. Once started, I have no need to stop the actual loop for the life of the application. Changing the variable doesn't change the sequence (I presume the data is copied at start time). I tried establishing a new serout, but an error is generated: "Already Freed". This does stop the sequence and I can restart it, but it doesn't seem very clean. I don't know if there is a way of accessing the internal counter and setting it to the end, or poking new values into the sequence buffer. Any ideas would be greatly appreciated.
User avatar
By gschulz
#63805 New information: I tried restarting the gpio.serout from a timer callback. If a WiFi access is in progress when the timer interrupt occurs, the system crashes. This could have been a solution to my above problem, but I can't even get this to work. Any ideas?
User avatar
By gschulz
#63810 Additional thoughts: It occurred to me that the WiFi services may be sharing the hardware timer with the SEROUT feature. It may actually be the setting of SEROUT that is crashing when it occurs during a WiFi event. If that is the case, it really limits my options. It may be that the only chance I have of using this is if I can change the contents of the timing sequence buffer without stopping the timer. I don't suppose there is an equivalent of PEEK and POKE is there? Is it possible to modify the behavior so it reloads the buffer after every iteration? What would it take to write my own equivalent? Still grasping at straws...