Serial Communication Data Formats

Data bits in a serial transmission may consist of following type of information

  • Commands
  • Sensor readings
  • Status information
  • Error codes
  • Configuration data
  • Files that contain text
  • Executable code or other information

In general, software that manages serial-port communications treats the data being transmitted as either binary or text data.

Binary Data

With binary data, each transmitted byte is a value from 00h to FFh. The bits in each byte are numbered 0 through 7, with each bit representing the bit’s value (0 or 1) multiplied by a power of 2. For example, a byte of 11111111b translates to FFh, or 255. A byte of 00010001b translates to 11h, or 17.

In asynchronous links, bit zero, the least-significant bit (LSb), arrives first. A serial port can transmit values that have 16, 32, or any number of bits by dividing the value into bytes and transmitting the bytes in sequence. For multi-byte values, the transmitting and receiving computers must agree on the order that the bytes transmit.

Text Data

Some software treats data as text, with each text character expressed as a code. Treating data as text is an ease for programmers. Most programming languages enable storing text in two ways:

As strings: Strings can contain one or more characters. Source code can request to transmit a string such as “hello” and the compiler or interpreter generates code that causes the individual character codes to transmit

As arrays: Arrays are made up of individual characters Source code can request to transmit an array, with each item in the array containing a character code.

At the receiving computer, software can store received character codes in a string or array. For applications that send and receive only basic U.S. English text, encoding generally isn’t an issue. When sending or receiving special characters or characters in other alphabets or scripts, the computers must agree on an encoding method.