Results for “pack”
Small, practical examples. Search by task or narrow things down below.
Calculate a simple packet XOR checksum
Arduino / C: XOR all payload bytes to produce a basic error-detection byte.
Arduino / C✓ Tested
Pack and unpack a network-order integer
Python: Use an explicit byte order so the binary format is independent of the host architecture.
Python✓ Tested
Pack two small values into one byte
Arduino / C: Mask each four-bit value before combining it.
Arduino / C✓ Tested
Unpack a tuple with structured bindings
C++: Structured bindings give names to the parts of a returned compound value.
C++✓ Tested
Append a new member to an uncompressed tar
Linux Commands: Use tar -r for an existing uncompressed archive; compressed tar files cannot be appended this way.
Linux Commands✓ Tested
Archive filenames safely with null delimiters
Linux Commands: Use find -print0 with tar --null to preserve spaces and embedded newlines in filenames.
Linux Commands✓ Tested
Assemble a big-endian 16-bit value
Arduino / C: Cast to an unsigned 16-bit type before shifting the high byte.
Arduino / C✓ Tested
Assign a bit from a Boolean state
Arduino / C: bitWrite accepts a bit position and a zero or nonzero value.
Arduino / C✓ Tested
Calculate a CRC-8 over a byte sequence
Arduino / C: This implementation uses polynomial 0x07, initial zero, and no reflection.
Arduino / C✓ Tested
Check the integrity of a gzip stream
Linux Commands: Use gzip -t to verify a compressed file without extracting it.
Linux Commands✓ Tested
Clear a flag without affecting neighboring bits
Arduino / C: bitClear resets only the selected bit.
Arduino / C✓ Tested
Compress a stream to a chosen filename
Linux Commands: Use gzip -c to leave the source file untouched and choose the destination explicitly.
Linux Commands✓ Tested