PDA

View Full Version : readyread for RS232 communication



giginjose
13th October 2010, 11:18
Hi ,

Is is possible that a readyread signal is emitted on an RS232 port once I send some data to the RS232 port.
I have connected the signal readyread to a slot, but the slot is not getting invoked once I send data to RS232 port . If I check the obj->bytesavailable() at the receiving port, I am able to get the bytes available, but, once I use the readyread signal, the corresponding slot is not invoked. Is it because the readyread signal is not detected by the receiver ?

void serialServer::serialServer()
{



sp = new QextSerialPort("/dev/ttyS0");

if(sp->open())
qDebug("port is open");
else
qDebug("port error");

frame_no = 1;
us = 31 ; //ASCII for uit seperator is 31
eot = 4 ; //ACSII for End of transmission

connect(&this, SIGNAL(readyRead()), &this, SLOT(requestframe()));
// connect(&this, SIGNAL(bytesWritten(qint64)), &this, SLOT(sendframe(qint64)));
}

void serialServer::requestframe()
{
QByteArray buffer;
while(sp->bytesAvailable()==0);
buffer +=sp->read(sp1->bytesAvailable());

if(buffer.toInt(&ok,10) == frame_no)
{
Load_Data();


qDebug("++complete++");
}

}

The code segment is attached. serialServer class is inherited from QIODevice. requestframe is declared as a public slot.

Please help. Thank You

marcvanriet
13th October 2010, 23:20
Hi,

I think you have to do

ps->setQueryMode(QextSerialBase::EventDriven);
before you open the port.

Also, you may have to use the 1.2 alpha version. I believe (but I'm not sure) that the earlier versions don't create a thread to wait for the comport events.

Best regards,
Marc