1 The question is: There is a Qstring string and a QBytearray array. I write the string to the array (QBytearray NN.append (nname);) and send to the COM port. I read the comport in an array (QBytearray) and try to print a line in lineedit; the data comes and is correct, but in the wrong encoding (xs is written that) that's what

what to do?

[ enter image description here ] in the comport are written (values ​​from above) and from the comport get these (below) what to do with it? how to avoid it?

PS: other data types (int) are quietly transmitted and correctly displayed.

  • one
    I would start by looking at what <b> bytes </ b> you get from the com port and which ones you send to it. - Vladimir Martyanov
  • one
    Try to write a string to the array without data transfer, from the array back to the string and output - will it be correct? I suspect that you have a problem where you convert it from an array back to a string. - nzeemin
  • one
    Checked, without data transfer, the array displays the correct result - Nikita Bondar
  • one
    "They come right, but not in the same encoding," is that right or not? Compare by the way what you send with what you get. - Cerbo
  • one
    Are you sure that on both sides you have the same com-port settings? There are quite a few options. - nzeemin

1 answer 1

The coding of the com port, and more specifically, the RS-242 transmission protocol (COM, UART, USART), regardless of the ANSII system. Judging by your log, most likely you have different settings on your devices, in Qt when using the QSerialPort class you need to take into account that there are predefined values, more info: http://doc.qt.io/qt-5/qserialport.html . you also need to take into account that there is no Cyrillic alphabet in ANSII, only Latin letters, numbers and specials. characters. I still had shoals when I emulated 2 com ports and connected one with the prog, the other with the terminal, and if I sent too much data, the emulator stupidly did not have time to process, there were packet losses and it turned out rubbish.

UPD. In response to your comment "what parameter .." - any, absolutely any, and the frequency and parity check and the addition of the control bit, all this can be wrong.

  • one
    Thanks, and really it was in the com port, with default settings everything is OK. (but did not solve the problem of the correct transfer of settings) - Nikita Bondar