Page 1 of 1

poll() versus spin on any()

Posted: Mon Oct 19, 2015 11:57 pm
by dbc
What is to be gained by calling poll() versus spinning on any() for the current PyBoard peripherals? Does it reduce latency?

Related, I note that the CAN peripheral is not enabled as a stream. It would be a little strange, in that it has two receive fifo's, but I guess there would be one CAN stream interface and then after poll() the user would call both can_instance.any(0) and can_instance.any(1) to see where data might be found.

Also, I presume the can.rxcallback function runs at interrupt level, correct?

Re: poll() versus spin on any()

Posted: Tue Oct 20, 2015 9:49 pm
by Damien
poll() will basically spin in a loop, calling any() on all the streams that you pass in, and executing a WFI if nothing is ready, before looping again.

poll() is useful when waiting on multiple streams. Otherwise you can just use any() in a loop (with a pyb.wif() if you like to reduce power consumption).

You can poll() a CAN object, but it does not have read/write methods. I don't think they are sensible, since send must specify an address as well as the data, and recv must specify the fifo.

CAN callbacks run at interrupt level, like all callbacks.