ProtocolZig.readWords()
ProtocolZig.readWords(uint8_t *_cmd, uint16_t *_data, uint8_t _len)
描述 读取数据,将读取到的长度为_len的数据放到数组_data[]中,数组为uint16_t类型,将指令数据赋给_cmd
参数
返回值 函数无返回值
示例 /*
[head,2byte,0xAA 0xBB] [type,1byte,TYPE_NUM] [data,16byte] [body,1byte,getChecksum()]
Example:
AA BB C8 DC 05 DC 05 D0 07 EF 03 DC 05 DC 05 DC 05 DC 05 E3
*/
#include <Microduino_Protocol.h>
ProtocolZig protocolA(16); //数据长度为16个字节
uint16_t recData[8];
uint8_t recCmd;
void setup() {
Serial.begin(9600);
protocolA.begin(11); //括号内参数为CoreRF通道号
}
void loop() {
if(protocolA.available())
{
protocolA.readWords(&recCmd, recData, 8);
Serial.println("protocolB Received !");
Serial.print("recCmd: ");
Serial.print(recCmd);
Serial.print(" Data:");
for(uint8_t i=0; i<8; i++)
{
Serial.print(" ");
Serial.print(recData[i]);
}
Serial.println();
}
delay(10);
}
其他 |