We sample a triaxial accelerometer at 6666Hz over SPI. Because we don’t want to miss a sample we use the accelerometers internal buffer and when it is full enough we quickly dump samples into an SRAM memory chip. Sometimes IMP fails to connect to wifi (amber/red/off) and then the accelerometer XYZ axis suddenly come out in incorrect order. It looks like IMP OS is busy (re)connecting wifi and our code can not keep up with reading accelerometer samples. Do you have an idea what might go wrong?
In our code we disconnect from wifi to have a stable power supply for an analog sensor and reconnect before we sample the digital accelerometer. It may be that the connection is not yet established when the code for the digital accelerometer is running.
Are you using RETURN_ON_ERROR mode? Are you initiating a connect when reading your samples?
Yes, we use return on error. And we did a server.connect right before.
Understanding the wifi flow, setting time outs correctly and understanding behavior of all server calls in return_on_error mode is not for beginners…
@jrsikken : I think I have seen this issue too
With ‘return on error’ policy set and there is no connection (no server.connect or connection failed), what happens when the squirrell hits a server.*, agent.send?
Does it just fill the out buffer waiting for a connection? or is this another error state? Does squirrell stop? (sort of seems like that)
If the imp is currently not connected, and if RETURN_ON_ERROR is set, then server calls (except server.connect) return an error immediately, without attempting to reconnect.
Powering up wifi is “lumpy” as far as squirrel is concerned; I believe we block for abour 400ms as the wifi firmware is loaded, so if your required handler latency is shorter than that then you’ll likely have problems. Moving this onto another thread is still on the wishlist for us.
Can you just complete the samples then start the connection?
You first check the IMP is connected or not. If it is connected then its okay. but if it is not connected and if RETURN_ON-ERROR is set, then server will calls RETURN_AN_ERROR immediately, without attempting to reconnect to the wifi or server.