QExtSerialPort readyRead Signal
-
Hello Team,
I am working on the serial port communication on Windows 7 and using QExtSerialPort library to handle the communication. After defining the port I connect the readyRead signal to my slot ReadPaket, as shown below.
@
pPort = new QextSerialPort();
pPort->setPortName("COM1");
pPort->setBaudRate( BAUD9600 );
pPort->setDataBits( DATA_8 );
pPort->setStopBits( STOP_1 );
pPort->setParity( PAR_NONE );
pPort->setFlowControl( FLOW_OFF );
pPort->setDtr( true );
pPort->setRts( true );
pPort->setQueryMode( QextSerialBase::EventDriven );connect( pPort, SIGNAL(readyRead()), this, SLOT(ReadPacket()) );
@
When I write data to the port, it is triggering the ReadPacket() slot for every byte in the data. I want the slot to be triggered only once when the new data is arrived. How can I achieve this? Is there some thing wrong in the port settings?Thanks in advance
[edit: code highlighted / Denis Kormalev] -
please don't forget about @ tags around your code
-
[quote author="kruvva" date="1306436734"]
When I write data to the port, it is triggering the ReadPacket() slot for every byte in the data. I want the slot to be triggered only once when the new data is arrived. How can I achieve this? Is there some thing wrong in the port settings?[/quote]
How would the class know that all your data (or all the data you are interested in) has arrived?If you get your data in bursts (a block of data, then nothing for a little while, then another block of data), you may look into "this wiki entry":http://developer.qt.nokia.com/wiki/Delay_action_to_wait_for_user_interaction. I explain how to fix this issue when related to UI's, but the code is equally applicable to this case. Or alternatively, you can simply check how many bytes are available when the slot is triggered, and if that number is too low, don't do anything.