[英]cannot convert from 'byte[]' to 'byte*'
I'm trying converting arduino lib to universal windows platform but i'm stock on byte[] to byte* conversion. 我正在尝试将arduino lib转换为通用Windows平台,但我有将byte []转换为byte *的方法。
For example: 例如:
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;
}
The str var on readCardSerial function is one of those errors. readCardSerial函数上的str var是这些错误之一。
I have my code on github if necessary - https://github.com/watashimeandeu/rfid.uwp 如果需要,我在github上有我的代码-https: //github.com/watashimeandeu/rfid.uwp
Thank you 谢谢
Check the following links, they answer a similar question: 检查以下链接,他们回答类似的问题:
How to assign byte[] as a pointer in C# 如何在C#中将byte []分配为指针
C# byte array to fixed int pointer C#字节数组固定为int指针
You need something like, receive a byte[]
in the method and then do the assignment 您需要类似的方法,在方法中接收一个byte[]
,然后进行赋值
fixed(byte *packet = packetArray)
{
... etc
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.