Photon2 problems with Serial peripherals

I did a quick test of UART serial receiving on the Photon 2. The code is in the repository below.

It uses a FT232 USB to Serial adapter and a node.js program that sends a constant stream of 8-byte packets from the computer to the Photon 2 at 230400 baud.

With the test program sending 2 packets every millisecond, around 16000 bytes/sec, loss is minimal, with 99% of packets successfully transferred. At slightly slower rates, it's 100% successful, tested for hours.

There are two important caveats:

The serial port buffer size must be increased. It used 512 bytes for the test. It fails at much lower rates with the default buffer size.

If you are using 6.3.0 or earlier on the P2, Photon 2, or M-SoM, and have a USB serial logging messages, the slowness of that will completely throw off serial receiving. Once I upgraded to the latest develop (which will be in 6.3.1), the log message for a missed packet doesn't cause a cascade of errors which eventually causes all packets to fail, because the logging slows down the UART reading so much.

3 Likes