I downloaded qt-emb-2.3.10 and qt-x11-2.3.2 from network,in my application ,i must get date from serial and output date to serial.but when get date from serial(com1),when date length is bigger one ,My gui was destoryed .the application can't response to my mouse and keyboard.
if I run gui application or serial applictaion not in the same time,these work in good normal,when run then in the same time,the serial application can't get date from serial or the gui application can't diaplay in normal.
read function :
int CXcjp::ReadBuf(char *data, int datalength)
{
int retval = 0;
if(!m_fd)
return 0;
int readcount=0;
FD_ZERO (&fs_read);
FD_SET (m_fd, &fs_read);
tv_timeout.tv_sec = TimeOut_Sec (datalength, GetBaudrate ());
tv_timeout.tv_usec = TimeOut_uSec(datalength,GetBaudrate());
retval = select (m_fd + 1, &fs_read, NULL, NULL, &tv_timeout);
if (retval)
readcount=read (m_fd, data, datalength);
else
readcount=-1;
return readcount;
}
/*
* Write datalength bytes in buffer given by UINT8 *data,
* return value: bytes written
* Nonblock mode
*/
int CXcjp::WriteBuf(char * data, int datalength)
{
int retval, len = 0, total_len = 0;
if(!m_fd)
return -1;
FD_ZERO (&fs_write);
FD_SET (m_fd, &fs_write);
tv_timeout.tv_sec = TimeOut_Sec (datalength, GetBaudrate ());
tv_timeout.tv_usec = TimeOut_uSec(datalength,GetBaudrate());
retval = select (m_fd + 1, NULL, &fs_write, NULL, &tv_timeout);
for (total_len = 0, len = 0; total_len < datalength {
retval = select (m_fd + 1, NULL, &fs_write, NULL, &tv_timeout);
if (retval) {
len = write (m_fd, &data[total_len], datalength - total_len);
if (len > 0) {
total_len += len;
}
}
else {
tcflush (m_fd,TCOFLUSH);
break;
}
}
return total_len;
}
Bookmarks