ReadAppFileRequest.cs 1.3 KB

12345678910111213141516171819202122232425262728293031
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace ShengJu_CUT100_DES.MessageEntity.Outgoing
  6. {
  7. /// <summary>
  8. /// 读数据文件 读取长度固定 32 字节(1 块)
  9. /// </summary>
  10. public class ReadAppFileRequest : MessageBase
  11. {
  12. /// <summary>
  13. ///
  14. /// </summary>
  15. /// <param name="fileId">1-4</param>
  16. /// <param name="blockAddress">0-3</param>
  17. /// <param name="readKey">16 bytes key,密钥值需要与制定文件的读写密钥相对应</param>
  18. public ReadAppFileRequest(byte fileId, byte blockAddress, byte[] readKey)
  19. {
  20. if (fileId < 1 || fileId > 4)
  21. throw new ArgumentOutOfRangeException("fileId must be range from(include) 1 to 4");
  22. if (blockAddress > 3)
  23. throw new ArgumentOutOfRangeException("blockAddress must be range from(include) 0 to 3");
  24. if (readKey.Length != 16)
  25. throw new ArgumentException("readKey must has its length to 16");
  26. base.命令代码 = CommandType.DesFireEV1操作命令_读数据_高级命令;
  27. base.RawDataAndCheck = new byte[] { fileId }.Concat(new byte[] { blockAddress }).Concat(readKey).ToList();
  28. }
  29. }
  30. }