Home > other >  A serial port to send data, how can the sender guarantee received let the receiver will not repeat t
A serial port to send data, how can the sender guarantee received let the receiver will not repeat t

Time:09-26

As title, such as the sender to the receiver sends A command, call A command,

For the receiver to receive commands and receive article N A N + 1 command, has the different branches on the logical processing at the receiving end,

That is to say, can't repeat,

Standing in the sending end, I don't know how to solve this problem? , of course, this kind of question is probably need to code and the agreement between the two sides cooperate,
But what to do to solve it?


Thought the communication problem to network edition area could be better, but the support of network programming usually some libraries, there are a lot of middleware or have to weight function, so ask most of the past and I don't know to go to the principle of weight will only use, middleware or garage if it is going to find a principle, that may be more trouble,

Also please release a lot of friends to help, this kind of problem should not very special,

CodePudding user response:

A command on the sender and the next command cannot repeat, under the command to send the finished one line of code that needs to be saved just send the order, for the next to compare before sending, if the last command and send the need to send the command is the same, that it does not send any thing or send a not your specific signal of control command, if it is not the same as you send now need to send command, hope to help you,

CodePudding user response:

reference 1st floor qq_42020655 response:
sender, which is a command and a command cannot repeat, under the command to send the finished one line of code that needs to be saved just send the order, for the next to compare before sending, if the last command and send the need to send the command is the same, that it does not send any thing or send a not your specific signal of control command, if it is not the same as you send now need to send command, hope to help you,


Thank you for your reply!

It can save the receive commands, but to save will delete, delete what time? The next time send a different, is to delete it? Seems to be feasible,

In addition, the key is how to confirm this time the same function of command, send said is not the same time, how to get on command, you see that is not the same?

CodePudding user response:

Don't need that trouble, send the command is to bring a command ID can, this ID is sent a time, there are some occasions for reliable need retransmission times also can easily cope with

CodePudding user response:

Thanks invitation!

I still want specific see what kind of business,

Personal view:
If agreement still has the possibility of extension, then increase sends A random number inside A instruction, if is the same event, time, function or,,, as long as it is "the same" instruction, random number don't change, and if even A instruction, due to the event, time, function changes and to send, can send random number updated at this time A command,


In addition, the post title is already very clear, the sender is not to repeat, "to" receive personal understanding is: manipulation of the sender is the fundamental solution?


CodePudding user response:

Command to see a few bytes, and sending frequency, such as sending a frame, 1 SEC 4 bytes, then can simply use time for Unix commands

CodePudding user response:

Reasonable arrangements, do receive the reply and error/timeout retransmission mechanism

CodePudding user response:

reference 4 floor DigCore response:
thank invited!

I still want specific see what kind of business,

Personal view:
If agreement still has the possibility of extension, then increase sends A random number inside A instruction, if is the same event, time, function or,,, as long as it is "the same" instruction, random number don't change, and if even A instruction, due to the event, time, function changes and to send, can send random number updated at this time A command,


In addition, the post title is already very clear, the sender is not to repeat, "to" receive personal understanding is: manipulation of the sender is the fundamental solution?



Thank you for your reply!

Agreement itself is ok, but in fact project to do much, was in a new project, probably recessive design goal is to contain the generality, so ready to reduce the amount of code, and guarantee the stability, leakage in reference MQTT hair treatment and to weight function,

The sender is to do some processing, but the receiver also want to cooperate!


CodePudding user response:

Each time you can let the receiver receive, just back to the once

CodePudding user response:

A serial port interrupt service program receives a full command and check data, length, and CRC right, to set up a sign: for example RX_OK_Flag=1;

Then the main program:

If (RX_OK_Flag==1)
{
RX_OK_Flag=0;
//execute commands specific
}

Or:

The received command is: the RX1 [];
Last time receive commands as follows: RX0 [];
Next time receive orders: RX2 [];


Then comparing the receiver at a time, the same, are reset, the different, last time 0, the execution,

CodePudding user response:

A serial port will not be repeated receiving

You send an A, for example, the receiver will only receive an A,

If you cycle to send n A (if sending speed under control, or is through the interrupt), the communication under normal circumstances, the receiver can only receive n A, not more not less

CodePudding user response:

Why don't the receiver to ensure that received a repeat order, should be the sender don't send to repeat the command line, or worry about lost, each time to resend the command, you can use the serial number system, sending the same command sent many times using the same serial number, different order serial number since the increase in turn, the receiver must ensure that the current command when processing serial number than the last serial number, otherwise think repeat orders, discarded directly,

CodePudding user response:

Increase the response, the form of a question and answer sacrifice efficiency to ensure accurate treadoff first
  • Related