Good morning,
I have to communicate with a commercial device via UART. I have no access to the device software, nor any way to modify its behavior.
This device is old and it already does this communication with an old DOS pc. I want to replace this old pc with a micro controller that does the same.
I tapped the communication between the two with a logic analyzer and got all the messages I have to send to emulate the pc.
I decided to use a STM32G0B1KCT. The device actually outputs the data in RS232 so I used a MAX3232 to convert it back to TTL UART.
In the pc's software when it's communicating with the device it says that the baud rate is 19200. Which the logic analyzer baud rate detector confirms.
So I set up the STM to 19200 and tried the communication. The device responds a 11 byte data chain
but my STM only get the first one and then times out.
I checked the communication between the STM and the device and I noticed that the bit length of the
stop bit of the device response is a little bit off (pictures)
For a 19200 baud rate it should be around 52us (the STM is) but the stop bit width of the device is around from 68 to 72us. I don't know if that could make the STM to time out after the first byte.
I tried setting a stop bit length of 1.5 but the result is the same. Anyway, a stop bit of 1.5 would be around 78us. That is quite far from the 68 that the device sometime sends.
I tried receiving all bytes at once:
uint8_t response1[11] = {0};
uint8_t r1 = HAL_UART_Receive(&huart1, response1, 11, 1000);
'
r1' is
3 after execution meaning
HAL_TIMEOUTI also tried to receive byte by byte:
uint8_t response1[11] = {0};
for(uint8_t i = 0; i < 11; i++)
{
uint8_t db = 0;
HAL_UART_Receive(&huart1, &db, 1, 100);
response1[i] = db;
}
But the result is the same,
response1[0] has the first data byte and all other bytes in
response1 are '0';
The image below shows the response of the device after the conversion to TTL. As you can see the data bit length is 52us (consistent with 19200bit/s baud rate)
But the stop bit is quite longer.

Am I doing something wrong? Is there a way I can go around this problem and get all the data correctly?
Thank you!
Edit: STM UART config:

(Full disclosure) I don't understand many of this setting, so I might have something configured wrong. If you see something off please advice
Edit2:
I sent the same 11 bytes from the STM to the device, I then captured both and put them side by side to compare.
As shown in the image, the data is quite similar, the only difference is that the device's stop bit is a bit longer, causing the message end to drift a little bit to the right.
