iso15693WriteBlock appears to set the first byte to zero
I'm attempting to use iso15693WriteBlock to write blocks of 4 bytes to a ST25DV04K tag. Everything appears to work and I don't get an error. However, when I read back the memory, the first byte of each block has been set to zero, and bytes 1 through 3 contain bytes 0 through 2 of my data. It's like there's an off-by-one error, but without any documentation or source code for the library I have zero chance of working out where. Any ideas appreciated. For completeness, here is the code I'm using to write the block:
/// <summary>
/// Writes a single block of data to the specified NFC tag using passive communication. The block size is determined by
/// the tag's native block size.
/// </summary>
/// <param name="tag">The NFC tag to which the data will be written. Must be obtained from <see cref="InventoryRequest" />.</param>
/// <param name="blockNumber">The block number on the tag where the data will be written.</param>
/// <param name="bytes">The data to write, represented as a read-only span of bytes.</param>
/// <exception cref="NfcException">Thrown if the radio access layer reports an error during the operation.</exception>
public void PassiveWriteBlock(INfcTagType5 tag, int blockNumber, ReadOnlyMemory<byte> bytes)
{
var txLength = (uint)bytes.Length;
uint rxLength = 32; // unused but required by the API, leave plenty of overhead for things like CRCs.
var rxBuff = new sbyte[rxLength]; // unused but required by the API
SelectTag(tag);
try
{
var blockBuffer = bytes.ToArray(); // creates a new byte array and copies the bytes into it.
var error = ST25R391xNativeMethods
.iso15693WriteBlock(Handle, tag.Uid, (byte)blockNumber, blockBuffer, txLength, rxBuff, ref rxLength, false);
error.ThrowOnError();
}
finally
{
DeselectTag(tag);
}
}I'm attempting to write the ASCII equivalent to "1234" into block 40, so I'm sending in a byte array 0x31,0x32,0x33,0x34 and I have verified in the debugger that this is exactly what is getting passed into iso15693WriteBlock in the byte[] data parameter and that the data_size parameter is 4. So where's my first byte going?
