Qt Serial Port Rs485

Posted on -

Terminal shows how to create a terminal for a simple serial interface by using Qt Serial Port. This example shows the main features of the QSerialPort class, like configuration, I/O implementation and so forth. Also, the class QSerialPortInfo is invoked to display information about the serial ports available in the system. Note: The serial port is always opened with exclusive access (that is, no other process or thread can access an already opened serial port). Use the close method to close the port and cancel the I/O operations. Having successfully opened, QSerialPort tries to determine the current configuration of the port and initializes itself.

  1. Qt Serial Port Rs485
Active2 years, 4 months ago

The example above shows how to open all available serial ports and then close them. But I want to open a given serial port, such as COM6, set its BaudRate,DataBits,Parity,StopBits ,FlowControl and then send a string of hexadecimal numbers.

K.RobertK.Robert

1 Answer

This video will definitely help you: https://www.youtube.com/watch?v=UD78xyKbrfk

You can also find similar code here: https://cboard.cprogramming.com/cplusplus-programming/169624-read-write-serial-port.html

Example code:

ni1ightni1ight

Qt Serial Port Rs485

Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.

Not the answer you're looking for? Browse other questions tagged qtserial-portqt5 or ask your own question.

I've successfully read data from EKM metering by using Python as in http://forum.ekmmetering.com/viewtopic.php?f=4&t=3472 link.Qt Serial Port Rs485
Rs485But before that I've tried to use C++ for a long time but it is unsuccessful. I follow this document http://www.chemie.fu-berlin.de/chemnet/ ... tml#SEC237, the below is my codeThe result is
pi@raspberrypi:~/solarD/src $ ./solar.out
Send result [17]
Read result [0]
pi@raspberrypi:~/solarD/src $ ./solar.out
Send result [17]
Read result [2] 30 30
But when I change code for canonical mode of POSIX There are not thing display because program is waiting data from serial port
And when I dump serial port, it show me that there are something has received as below
pi@raspberrypi:~ $ tail -f /dev/ttyUSB0
00000001766100000000000000000000000000000000000000000000000000000000000000000000000000000002320000000000000000000000000000000000000000000000000000C000C000C0000000000011512080313555702000000000000000000000000000000000000000000000000000000000000!
=00000001766100000000000000000000000000000000000000000000000000000000000000000000000000000002324000000000000000000000000000000000000000000000000000C000C000C0000000000011512080313560302000000000000000000000000000000000000000000000000000000000000!

Anyone can suggest me how can I fix it.