WriteAppFileRequest.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. public class WriteAppFileRequest : MessageBase
  8. {
  9. /// <summary>
  10. ///
  11. /// </summary>
  12. /// <param name="fileId">1-4</param>
  13. /// <param name="blockAddress">0-3</param>
  14. /// <param name="writeKey">16 bytes key</param>
  15. /// <param name="data">32 bytes data</param>
  16. public WriteAppFileRequest(byte fileId, byte blockAddress, byte[] writeKey, byte[] data)
  17. {
  18. if (fileId < 1 || fileId > 4)
  19. throw new ArgumentOutOfRangeException("fileId must be range from(include) 1 to 4");
  20. if (blockAddress > 3)
  21. throw new ArgumentOutOfRangeException("blockAddress must be range from(include) 0 to 3");
  22. if (writeKey.Length != 16)
  23. throw new ArgumentException("writeKey must has its length to 16");
  24. if (data.Length != 32)
  25. throw new ArgumentException("data must has its length to 32");
  26. base.命令代码 = CommandType.DesFireEV1操作命令_写数据_高级命令;
  27. base.RawDataAndCheck = new byte[] { fileId }.Concat(new byte[] { blockAddress }).Concat(writeKey).Concat(data).ToList();
  28. }
  29. }
  30. }