开发RFID读写程序软件
private void ReadOneBlock(int sectorIndex)
{
MWStatus mwStatus = new MWStatus();
MWCommand mwCommand = new MWCommand();
int ret;
int index = 0;
byte blockIndex;
mwCommand.TxSeq = seq ;
mwCommand.Command = 0x46;
mwCommand.Len = 0x01;
//块号
blockIndex = (byte)(sectorIndex Convert.ToByte(cmbSector.Text) * 4);
mwCommand.Parameters[index ] = blockIndex;
ret = DoMWCommand(com, mwCommand, mwStatus);
if (ret != 0)
MessageBox.Show("读数据块" blockIndex.ToString() "错误。");
else
{
if (mwStatus.Status == 0)
{
if (mwStatus.Len > 0)
{
byte[] cardSerial = new byte[mwStatus.Len];
for (int i = 0; i < mwStatus.Len; i ) cardSerial[i] = mwStatus.Parameters[mwStatus.Len - 1 - i];
MessageBox.Show("读数据块" blockIndex.ToString() "返回:" byteArrayToHex(cardSerial));
}
else
MessageBox.Show("读数据块" blockIndex.ToString() "成功。");
}
else MessageBox.Show("读数据块" blockIndex.ToString() "错误:" mwStatus.Status.ToString());
}
}