I'm trying converting arduino lib to universal windows platform but i'm stock on byte[] to byte* conversion.
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.
I have my code on github if necessary - 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 array to fixed int pointer
You need something like, receive a byte[]
in the method and then do the assignment
fixed(byte *packet = packetArray)
{
... etc
}