我正在为一些第三方硬件使用一些第三方库。库通过串行连接与硬件通信。使用库,我通过串行接口将数据发送到硬件并获得响应,该响应存储在数组中:
// This is the byte array declared in the third party libraries
// that stores data sent back from the external hardware
byte comm_buf[201];
/* I send data to hardware, comm_buf gets filled */
// Printing out the received data via a second serial line to which
// I have a serial monitor to see the data
for (int i = 0; i <= 50; i++) {
Serial.print(gsm.comm_buf[i]);
}
// This is printed via the second monitoring serial connection (without spaces)
13 10 43 67 82 69 71 58 32 48 44 51 13 10 13 10 79 75 13 10 00
// It is the decimal ascii codes for the following text
+CREG: 0,3
如何将字节数组转换为可以在代码中评估的格式,以便可以执行类似以下伪代码的操作;
byte comm_buf[201];
/* I send data to hardware, comm_buf gets filled */
if (comm_buf[] == "CREG: 0,3" ) {
// do stuff here
}
我是否需要以某种方式将其转换为字符串,或者与另一个 char 数组进行比较?