I am dealing with Serial connections between two system for testing my project.
Here's the implementation of the serial object:
(it is attached)
Here are the problem which are making me crazy, I would thank if you could also change the code for a better understanding:
1) Packets get lost, if I write a packet to the serial port, I may sometimes miss the ACK pakcet and I ReadData() fails.
the more packets I append and emit to the serial port the less probable the chance of success.
I tried to delay for quite some moments before sending or receiving another packets, but I came to the point now, that when I use delay between sending packet as you see in the object ReceiveData() SLOT, the chance of
success fails. When i removed it was better.
consider this:
if(data.at(4) == 0x01)
{
qDebug() << "Lower Sensor= 0x01";
qDebug() << "STARTING PUMP..";
command_startPump.append(FUEL_SYSTEM);
command_startPump.append(FUEL_PUMP);
command_startPump.append(0x01);
emit DSLFL_SendToRS485(command_startPump);
qDebug() << "OPENING SV_15";
command_SV15.append(FUEL_SYSTEM);
command_SV15.append(DSLFL_ST_SV_15);
command_SV15.append(0x01);
emit DSLFL_SendToRS485(command_SV15);
}
if(data.at(4) == 0x01)
{
qDebug() << "Lower Sensor= 0x01";
qDebug() << "STARTING PUMP..";
command_startPump.append(FUEL_SYSTEM);
command_startPump.append(FUEL_PUMP);
command_startPump.append(0x01);
emit DSLFL_SendToRS485(command_startPump);
qDebug() << "OPENING SV_15";
command_SV15.append(FUEL_SYSTEM);
command_SV15.append(DSLFL_ST_SV_15);
command_SV15.append(0x01);
emit DSLFL_SendToRS485(command_SV15);
}
To copy to clipboard, switch view to plain text mode
Here, if I send the first packet using a function like start_pump() and then send the second packets, the code would not work, But, when I pasted the code from the function here without using any delay between the two emits, it works, though ReadData often fails.!
2) When I use the singleShot function, it does not execute the SLOTS, it doesn't work at all!
I would thank if you could show me how to make this Object work correctly without any data loss, and with timer slots and serperate codes work.
Yours
Bookmarks