hello, everyone. i use qextserialport in my application to realize serial communication.
i can write data using writeData(const char * data, qint64 maxSize). But the function bytesAvailable () returns '0' while reading, so i can't get any data through readData(char * data, qint64 maxSize). But i can see the answer data from serial port monitor. WHY??
my code:
{
RS232->writeData(Data,13);
//usleep(500);
int i= RS232->QIODevice::bytesAvailable();
if(i > 0)
{
char *pStr=NULL;
RS232->readData(pStr,25);
}
RS232->close();
}
if(RS232->open(QIODevice::ReadWrite))
{
RS232->writeData(Data,13);
//usleep(500);
int i= RS232->QIODevice::bytesAvailable();
if(i > 0)
{
char *pStr=NULL;
RS232->readData(pStr,25);
}
RS232->close();
}
To copy to clipboard, switch view to plain text mode
adding the "usleep(500);" has no use.
thanks very much for any advice!
Bookmarks