Serial output differs between PC and Pi

I’m trying to send R to a scale to set it to zero. The code works fine when run on a PC in the XOJO IDE, but not when the same code is run compiled on a Pi. Using an oscilloscope I see the the PC and the Pi generating quite different signals. The data stream lasts 1 ms on a PC (about what I expect at 9600 baud), but only 320 us on the Pi, suggesting the Pi is sending data 3 times faster. And the bit pattern is not the same, there are 4 transitions from -5 to 6V on the PC and 6 on the Pi. What’s going on? I’m using Xojo 2017 r3, because 2018 r1.1 still does not stop at breakpoints reliably. The scale is continuously sending data during these tests, and the PC displays the incoming data, but the Pi is not seeing anything, which makes sense if it is expecting data at a different baud rate for some reason.
I had Pi serial communications working a week ago, could I have done something to change a clock that controls the baud rate? Not that I’m aware of doing anything to the Pi other than installing this compiled Xojo code.

Update: I added code to select the baudrate, and find that the pattern and length of the signal for the letter R on the PC matches the Pi pattern when the PC is set for 57600 baud and the Pi is set for any baud from 3600 to 57600. The code reports what the baud rate is, and on the PC it matches what I select it to be. On the Pi it always reports it to be 4097, no matter what I set it to be.

Did you try baud 115200 on the pi?

Not sure it this is anything to do with your issue, but may be worth a look:-

Same result at 115200 as all the lower speeds, a 320 usec long pulse train, unlike the inversely proportional length expected. I did neglect to mention that I am using a USB port and a USB-serial converter both on the PC and on the Pi, so I’m not sure Chris’s link is relevant, but I’ll look more into that.

I switched to a new Pi, and my excitement to see it working was short-lived. It too is now stuck at 57k baud, and won’t send any TX data if the scale is streaming data, as if it is too busy dealing with the data stream coming from the scale to send anything out. Is there a limit on the data voltage? Could 12V signals from the scale into the serial-USB converter be damaging the Pi?


You might want to try this:

Sorry, two different threads I started have converged to the same problem. I was setting baud with serial1.baud=9600 instead of serial1.baud=8. What threw me off was that the first setting worked under Windows, and only very occasionally under Linux, so I thought the problem was with the Pi.