hi everyone
i have write a simple code to read and display data that received from serial port with qextserialport ,i have compiler without any error but nothing was execute,plz solve it hep me
this's my code
Qt Code:
  1. #include "mainwindow.h"
  2. #include "ui_mainwindow.h"
  3. #include <qextserialport.h>
  4. #include "stdlib.h"
  5. #include "stdio.h"
  6.  
  7. MainWindow::MainWindow(QWidget *parent) :
  8. QMainWindow(parent),
  9. ui(new Ui::MainWindow)
  10. {
  11. ui->setupUi(this);
  12. QextSerialPort * port = new QextSerialPort("COM2");
  13. port->setBaudRate(BAUD115200);
  14. port->setDataBits(DATA_8);
  15. port->setParity(PAR_NONE);
  16. port->setStopBits(STOP_1);
  17. port->setFlowControl(FLOW_OFF);
  18. port->open(QextSerialPort::ReadWrite);
  19. //while(1)
  20. //{
  21. char buff[1024];
  22. int bytesToRead = port->bytesAvailable();
  23. int result = (int)port->read(buff,bytesToRead);
  24. buff[result];
  25. char byte1[3];
  26. char byte2[3];
  27. byte1[0] = buff[0];
  28. byte1[1] = buff[1];
  29. byte1[2] = buff[2];
  30. byte2[0] = buff[3];
  31. byte2[1] = buff[4];
  32. byte2[2] = buff[5];
  33. long int B1=byte1[0]<<16|byte1[1]<<8|byte1[2];
  34. long int B2=byte2[0]<<16|byte2[1]<<8|byte2[2];
  35. long int C1;
  36. long int C2;
  37. char * next;
  38. C1 = strtol(byte1,&next,16);
  39. C2 = strtol(byte2,&next,16);
  40. ui->lcdNumber->display(B1);
  41. ui->lcdNumber_2->display(B2);
  42. ui->lcdNumber_3->display(C1);
  43. ui->lcdNumber_4->display(C2);
  44. //}
  45. }
  46.  
  47. MainWindow::~MainWindow()
  48. {
  49. delete ui;
  50.  
  51. }
To copy to clipboard, switch view to plain text mode 

when i run it without send any data ,lcdnumber display is -6378 and lcdnumber2 dispaly is 4864 and lcdnumber 3,4 is 0,
but when i send data 0x10 0x20 0x30 0x40 0x50 0x60 ,it do have any changed in lcdnumber ...
please help me