// 处理串口接收字节数组转换
String intToHex(int i, {int pad = 2}) {
  return i.toRadixString(16).padLeft(pad, '0').toUpperCase();
}

List<int> hexToUnits(String hexStr, {int combine = 2}) {
  hexStr = hexStr.replaceAll(" ", "");
  List<int> hexUnits = [];
  for (int i = 0; i < hexStr.length; i += combine) {
    hexUnits.add(hexToInt(hexStr.substring(i, i + combine)));
  }
  return hexUnits;
}

int hexToInt(String hex) {
  return int.parse(hex, radix: 16);
}

String formatReceivedData(recv) {
  return recv
      .map((List<int> char) => char.map((c) => intToHex(c)).join())
      .join();
}