def _CommandStr(command):
  """Formats one-byte command with 0xFF format.

  Returns:
    One-byte command in 0x%02X format. For non one-byte-str input,
    returns 'invalid command' instead.
  """
  if isinstance(command, str):
    if len(command) == 1:
      return '0x%02X' % ord(command)
    return 'invalid command %r, len:%d != 1' % (command, len(command))
  return 'invalid command %r: not a string.' % command