Home > other >  Based on the qt serial communication program on the arm can only send data cannot receive
Based on the qt serial communication program on the arm can only send data cannot receive

Time:05-20

The following part is the main program, the window is also very simple, only one send window, a window, a send button, the program under Linux system can run normally, the computer can send and receive functions, but on the arm development board can only send cannot receive, your advice please! Be very grateful! Void serialport: : sendButtonClicked () {QString STR=m_sendEdit - & gt; The text (); : : write (m_fd, STR toLatin1 (), STR. The length ()); } int serialport: : openSerialPort () {int fd=1; Const char * devName="/dev/ttyS0"; Fd=: : open (devName, O_RDWR | O_NONBLOCK); If (fd & lt; 0 {return - 1; } termios serialAttr; Memset (& amp; SerialAttr, 0, sizeof serialAttr); SerialAttr. C_iflag=IGNPAR; SerialAttr. C_cflag=B115200 | HUPCL | CS8 gives | CREAD | CLOCAL; SerialAttr. C_cc [VMIN]=1; If (tcsetattr (fd, TCSANOW, & amp; SerialAttr)!=0) {return - 1; } return fd; } void serialport: : remoteDataIncoming () {char c; If (read (m_fd, & amp; C, sizeof c)!=1) {QMessageBox: : warning (this, tr (" Error "), tr (" the Receive Error!" )); return; } m_receiveEdit - & gt; InsertPlainText (QString (QChar (c))); }

CodePudding user response:

Ask 171480405 QT group

CodePudding user response:

Can you tell me the solution
  • Related