【发布时间】:2016-01-29 12:34:31
【问题描述】:
我正在尝试将 arduino lib 转换为通用 Windows 平台,但我在进行 byte[] 到 byte* 转换。
例如:
public bool readCardSerial()
{
byte status;
byte[] str = new byte[MAX_LEN];
status = anticoll(str);
Array.Copy(serNum, str, 5);
return (status == MI_OK);
}
public unsafe byte anticoll(byte* serNum)
{
byte status;
byte i;
byte serNumCheck = 0;
uint unLen;
writeMFRC522(BitFramingReg, 0x00);
serNum[0] = PICC_ANTICOLL;
serNum[1] = 0x20;
status = MFRC522ToCard(PCD_TRANSCEIVE, serNum, 2, serNum, &unLen);
if (status == MI_OK)
{
for (i = 0; i < 4; i++)
serNumCheck ^= serNum[i];
if (serNumCheck != serNum[i])
status = MI_ERR;
}
return status;
}
readCardSerial 函数上的 str var 就是这些错误之一。
如有必要,我在 github 上有我的代码 - https://github.com/watashimeandeu/rfid.uwp
谢谢
【问题讨论】:
-
您在哪一行得到错误?
status = MFRC522ToCard();?您确定返回byte而不是byte[]?
标签: c# c++ arduino rfid windows-10-iot-core