Page 1 of 1

Select Class

Posted: Mon Jan 26, 2015 10:55 am
by cooper
Hello,

Excuse my ignorance but what is the difference between using uart.any() and the Select Class: http://docs.micropython.org/en/latest/l ... ule-select? To me it seems like a long winded way to achieve the same results?
Please correct me if I am wrong.

Thanks, Cooper

Re: Select Class

Posted: Mon Jan 26, 2015 2:16 pm
by blmorris
The uart.any() method tells you if there are characters waiting in the buffer for a specific serial port; the 'uart' object could be any one of 6 hardware serial ports on the pyboard or the USB_VCP virtual comm port.
As I understand it, the Select class allows you to register a set of these 6 available UART ports along with the USB_VCP port for polling through a single object - a single point to listen to a set of data streams, rather than polling each initialized UART separately.
(Disclaimer - I haven't tried to use Select in my code yet, but that is how I understand it.)

-Bryan