Serial command byte encoding for display control

6 min read · Published November 1, 2026

Check the bytes leaving the serial port before changing media preparation. Binary command values must not become printable digit strings, and every argument must retain its documented width and byte order. Compare one complete transaction with a working reference, including port settings and responses.

A rejected serial media command often starts with a mismatch between the numbers in your application and the bytes leaving its serial port. Decimal byte value 255 must leave as one byte, FF, when the documented protocol is binary. Sending the characters 255 produces three different bytes. Check the final transmitted sequence, argument lengths and port settings before changing media preparation. Text appearing on a display does not establish that binary control commands are being encoded correctly.

What each symptom points to

Use the earliest failed operation to narrow the search:

  • Text appears, but control commands fail: the application may be converting command values into printable characters. Text output and binary commands need different handling.
  • A short command works, but commands with arguments fail: check field widths, byte order, length fields and any documented checksum.
  • The display returns 0x15: some protocols use this value as a negative acknowledgment. Confirm its meaning in the device documentation before treating it as a particular media error.
  • A later command produces an unexpected response: an earlier incomplete command may have left the receiver waiting for argument bytes.
  • The same media works through another supported application: preserve that media and compare the two transmission paths first.
  • Results change with serial settings: verify the complete port configuration. Apparent success does not establish that mismatched settings are acceptable.

These symptoms identify useful checks, not a diagnosis by themselves. A rejected transaction could involve encoding, framing, device state or media access. The response definition and a byte-level record help separate them.

Check binary bytes against printable digits

Decimal and hexadecimal are ways to write a number. ASCII is a mapping between characters and byte values. Confusing those roles changes what reaches the receiver.

For example, a byte with decimal value 255 has hexadecimal value FF. The character 2, however, has ASCII hexadecimal value 32. An application that formats the number 255 as text sends the characters 2, 5 and 5, not the byte FF.

Representation Transmitted bytes in hexadecimal Byte count
Binary values 255, 215 FF D7 2
ASCII text 255215 32 35 35 32 31 35 6
Binary values 255, 177 FF B1 2
ASCII text 255177 32 35 35 31 37 37 6

These sequences illustrate representation only. They are not a command reference for a particular display. Send only commands documented for the device you are diagnosing.

Spaces in a hexadecimal log normally separate displayed bytes. They are not necessarily transmitted. Conversely, spaces inserted into a text string are actual characters unless the sending application parses and removes them.

Inspect the last formatting stage before the serial write. An upstream list can be correct while a later conversion turns it into text. Look for number-to-string formatting, added separators and automatic line endings. Remove those transformations from a binary command path unless the protocol explicitly requires them.

Keep display text on a separate encoding path. A protocol can contain both binary command fields and text payloads, with different rules for each.

Count every argument byte

Correct command bytes are not enough if the arguments are incomplete. A field shown as 0000 in hexadecimal can represent two bytes, 00 00. Sending one numeric zero as one byte does not preserve that width.

Suppose a documented packet contains a two-byte command followed by two two-byte fields. Its expansion would look like this:

Packet representation Expanded bytes Total length
FF B9 0000 0000 FF B9 00 00 00 00 6 bytes
Two command bytes followed by only two zero bytes FF B9 00 00 4 bytes

The shorter packet is missing two bytes under that assumed format. The actual device documentation must establish whether those fields are addresses, coordinates, lengths or something else. Do not assign meanings from the appearance of the numbers.

Check each field for:

  • Its width in bytes.
  • Whether it is binary or textual.
  • The required byte order.
  • Any signed-value rules or scaling.
  • Whether it contributes to a length or checksum field.

All-zero arguments cannot reveal a byte-order mistake. For a documented two-byte field, the value 0x1234 becomes 12 34 in most-significant-byte-first order and 34 12 in least-significant-byte-first order. Use a valid, harmless nonzero value when checking byte order, and follow the device's specified order.

Match the port and electrical interface

Copy the complete serial configuration from the documented setup or a working reference connection. Check baud rate, data bits, parity, stop bits and flow control. Also check device addressing and command termination if the protocol uses them.

A readable response does not prove that every setting is correct. Compare settings explicitly instead of relying on a few apparently successful operations.

Confirm the electrical interface before attaching diagnostic equipment. A serial connector does not tell you whether the signals use logic-level serial, RS232 or another interface. Use a compatible adapter and the documented wiring. Do not attach a logic-level analyzer directly to an interface whose signal levels it cannot accept.

Keep only one application in control of the port during a comparison. Close the reference connection before opening the same port from the application under investigation. Otherwise, a connection conflict can obscure the encoding problem.

For equipment attached to a production machine, perform diagnostics under the approved maintenance procedure. Use an isolated bench setup where practical. Do not send exploratory commands to equipment whose output could affect machine operation or a safety function.

Correct the first failed transaction

You need the device's command reference, a known working setup if available, and a way to record transmitted and received bytes separately. Start with the simplest documented operation that is safe for the setup.

  1. Record the starting state. Note the device configuration, media selection, port settings and any required initialization. Keep working media unchanged.
  2. Capture the reference transaction. Record the outgoing bytes, their count and the response. Include any documented delay or readiness condition before the next command.
  3. Inspect the application's final output. View bytes after formatting and serialization, not just the values entered into a message field. A software log shows what that layer records; an interface-compatible capture can help establish what actually crosses the connection.
  4. Compare the sequences byte for byte. Check command identifiers, argument widths, byte order, terminators and any checksum. Compare length as well as content.
  5. Correct the serialization. For a binary protocol, construct a byte buffer or use the sending interface's documented raw-byte method. Check that byte values fall within 0 through 255; do not rely on silent truncation or text conversion.
  6. Send one complete transaction. Wait for the documented response or completion condition. Do not continue into playback after a rejected initialization.
  7. Restore the documented starting state when necessary. If an incomplete packet may have left the parser waiting for data, use the vendor-documented recovery or initialization procedure. Do not assume that an arbitrary extra byte or line ending will resynchronize it.

If the captured bytes match the working transaction but the result differs, check state and timing next. Media readiness, selection and initialization order may matter even when the packet itself is correct.

Only investigate media preparation after the transmission path and command sequence have been compared. Changing the card and the command builder together removes a useful reference.

Check that the correction holds

Repeat the corrected sequence from the same documented starting state. Check initialization, selection and playback separately. Confirm both the intended result and the expected responses; one successful screen change does not validate every command path.

Retain a short diagnostic record containing:

  • The applicable command-reference revision.
  • Port settings and electrical interface.
  • Expected and captured transmit bytes, including byte counts.
  • Received bytes with clear direction labels.
  • The required starting state and command order.
  • The first operation that succeeds or fails.

Keep that record beside the serialization code so a later text-formatting change is easier to spot.

For a new installation, also distinguish a factory status display from an operator HMI. A listed serial port does not establish a supported media-control protocol. Confirm the command set and intended control role before building the application around it.

Questions

Should serial commands use decimal, hexadecimal or ASCII?

Use the representation required by the documented protocol. In a binary protocol, decimal value 255 and hexadecimal value FF identify the same single byte. Formatting 255 as ASCII text sends three bytes instead. A text-based protocol may require printable digits, so inspect the command specification before choosing the conversion.

Does a 0x15 response mean the media card is faulty?

Some protocols use 0x15 as a negative acknowledgment, but that alone does not identify a media fault. Confirm the response definition for the device. Then check the first rejected transaction for command encoding, argument length, initialization state and any documented media requirements.

Why can sending zero arguments still produce an incomplete command?

A hexadecimal field written as 0000 may represent two bytes, while one numeric zero sent through a byte-oriented interface occupies only one byte. Preserve the documented field width, including leading zero bytes. Check byte order separately because an all-zero field cannot expose reversed ordering.

Does successful text output prove the serial command path is correct?

Not necessarily. Text characters can pass correctly through a text conversion path while binary command identifiers are changed into printable digits. Check the final outgoing bytes for a documented control command, including its arguments and any required framing, rather than treating readable text as a complete protocol check.

Planning information, not legal or engineering advice. Rules differ by place: check codes and permits with your local authority and your licensed trades.

Keep reading

Build your signAsk for a quote