Results for “Serial protocols”
Small, practical examples. Search by task or narrow things down below.
Dispatch a one-character serial command
Arduino / C: A switch provides explicit handling for accepted and unknown commands.
Arduino / C✓ Tested
Handle incomplete serial input
Arduino / C: The returned byte count distinguishes a complete payload from a timed-out partial one.
Arduino / C✓ Tested
Read a decimal number from serial input
Arduino / C: parseFloat parses a signed decimal value from the input stream.
Arduino / C✓ Tested
Read a fixed-size serial payload
Arduino / C: readBytes returns the number of bytes actually received.
Arduino / C✓ Tested
Read an integer from serial input
Arduino / C: parseInt skips leading nonnumeric characters and reads the next integer.
Arduino / C✓ Tested
Read serial text up to a delimiter
Arduino / C: readBytesUntil excludes the delimiter and does not add a null terminator.
Arduino / C✓ Tested
Validate a complete numeric serial command
Arduino / C: Check for digits, an end pointer, and an application-specific range.
Arduino / C✓ Tested
Convert received ASCII letters to uppercase
Arduino / C: ctype functions should receive an unsigned character value.
Arduino / C✓ Tested
Inspect a byte without consuming it
Arduino / C: peek leaves the next byte available for a later read.
Arduino / C✓ Tested
Search the stream for a message marker
Arduino / C: find consumes input through a matching marker or until timeout.
Arduino / C✓ Tested
Collect a serial line in a fixed buffer
Read a short command without dynamic String allocation.
serial line✓ Tested
Combine several Serial.print calls
Arduino / C: Combine several Serial.print calls on an Uno with the Serial Monitor set to 9600 baud.
Arduino / C✓ Tested