Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - The MCU sends an array to the pc. Why do the numbers in the array have a delay effect with the actual numbers and do not match the actual input numbers?
The MCU sends an array to the pc. Why do the numbers in the array have a delay effect with the actual numbers and do not match the actual input numbers?
Method 1: If you know the length of the array before the microcontroller sends it, you can set the first byte of the data returned by the microcontroller as the length of the data to be sent, and then send the data, so that the upper computer knows how much data to receive. Method 2: Don't send data for a period of time after MCU sends the array once. The upper computer receives data circularly, and if it times out, it is considered that the reception is over and the length is obtained. Method 3: Change the data type and leave a number as the ending symbol character. Recommended method 1.