Modbus at 38400

In your read callback, you should be emptying the serial buffer; you don’t get a callback for every byte received, you get a callback when the buffer goes from being empty to non-empty.

ie replace this:

buffer.writen(hardware.uart57.read(),'b');

with:

local b=hardware.uart57.read(); while(b!=-1) { buffer.writen(b,'b'); b=hardware.uart57.read(); }

…btw, we will be adding a CRC API in squirrel as it’s a pretty common requirement.