Modbus responses to Photon 2 being misread (fine on Argon)

Hey there,

I was using an Argon to successfully communicate over Modbus with a number of subnodes. I switched to using a Photon 2 and despite the requests and responses looking almost identical over a logic analyzer, the Photon 2 is unable to read the response. It prepends 00 to each response.

For example,

Argon:
Request: C906000200003842
Response: C906000200003842

Photon 2:
Request: C906000200003842
Response: 00C9060002

I'm using the ParticleModbusClient library and the code has no changes between the Argon and Photon 2 that aren't pin swaps. Schematics, as they relate to Modbus, were a copy + paste.

Any advice?

Thanks,

Julia

What version of Device OS are you using on the Photon 2? I'd recommend 5.6.0. I'm not aware of any known bug that would cause extra bytes on UART serial, though prior to 5.6.0 there was a situation where the UART could lose data.

Is your RS485 transceiver auto-direction sensing or does it use a GPIO to change directions? If it's manual, there is a possibility that the RTL872x is reporting transmit buffer empty before all of the bits have been transmitted. I hadn't heard of this in UART serial, but it does happen with SPI DMA because there are two FIFOs, and the completion is indicated when the first FIFO is empty, not the second one that actually transfers the bits out via SPI. The same thing could be happening for UART. If this is occurring, the extra receive 00s are the end of the transmission. You could test this theory by adding a delay after detecting transmit buffer empty before changing the state of the direction line.