hi all, i'm currently doing an application that will send and receive SMS messages using GSM Modem and by sending AT Commands. I used the QextSerialPort class. I connect to the port using this code:
Qt Code:
  1. port = new QextSerialPort("COM1");
  2. port->setBaudRate(BAUD19200);
  3. port->setFlowControl(FLOW_OFF);
  4. port->setParity(PAR_NONE);
  5. port->setDataBits(DATA_8);
  6. port->setStopBits(STOP_2);
  7. port->open(QIODevice::ReadWrite);
To copy to clipboard, switch view to plain text mode 

then send AT COMMANDS:

Qt Code:
  1. QString command ="AT\r\n"; //sample command - in Hyperterminal this returns OK
  2. QByteArray byte;
  3. byte.clear();
  4. byte.append(command);
  5. port->write(byte);
  6. port->waitForBytesWritten (500);
To copy to clipboard, switch view to plain text mode 

then try to read the response:
Qt Code:
  1. char buff[1024];
  2. int numBytes;
  3. numBytes = port->bytesAvailable(); //always returns -1
  4. if(numBytes > 0)
  5. {
  6. if(numBytes > 1024)
  7. numBytes = 1024;
  8. int i = port->read(buff, numBytes);
  9. buff[i] = '\0';
  10. QString msg = buff;
  11. qDebug(msg);
  12. qDebug("bytes available: %d", numBytes);
  13. qDebug("received: %d", i);
  14. }
To copy to clipboard, switch view to plain text mode 

i'm not sure if im doing it right cause when i read the response the bytesAvailable() always returns -1. Is there anybody here can help me or give me a piece of code on how to do it right? thnks in advance...