Home > Software engineering >  After a serial port to send data packets to get multiple return packets what to write, please bosses
After a serial port to send data packets to get multiple return packets what to write, please bosses

Time:02-25


PC to the machine sends a packet, if the check digit is executed instructions correctly, and lower machine returns a packet to PC;

But now I need to multiple return data packets, return a start executing instructions, intermediate return once, instructions to complete and return a packet, the interval of how to write, how should do excuse me?


To lower place machine and the upper machine to send packets, the parity bit wrong will not execute instructions; the next bit machine returns to the upper machine data packet check digit is wrong? instructions are running over, will happen?

CodePudding user response:

The general design, long time of operation, will not use the response of the blocking mode,
{
//send the command
//wait for the command response

//set the timeout
Do
{
//query state
//if complete OK (command) break;

//to perform certain operations

} while (not timeout);
}

If it was blocking type of response (executive does not accept other instructions before completion), probably thinking
Do
{
//send the command

//wait & amp; Receive the response 1

//wait & amp; Receive the response 2

//wait & amp; Receive the response 3
} while (0);

General PC to do the host, the host will generally be responsible for the communication timeout, error handling,
Communication error and timeout generally should retry several times, in order to enhance the system robustness and fault tolerance, continuous error more than N can pop-up prompts the user intervention


  • Related