示例#1
0
 /*!
  * Reads data from the FRAM.
  * @param data Address where read data will be stored, this location must be able to accommodate size bytes.
  * @param address Location in the FRAM from which the data should be read.
  * @param size Number of bytes to read.
  * @return -2 if the specified address and size are out of range of the FRAM space.
  * -1 if obtaining lock for FRAM access fails,
  * 0 on success.
  */
 public int FRAM_read(byte[] data, uint address, uint size)
 {
     if (fram == null)
     {
         return(OBCConstants.ACCESS_ERROR);
     }
     return(fram.Read(data, (int)address, (int)size));
 }
示例#2
0
        public void ReadFailedOutOfRangeTest()
        {
            FRAM ram = new FRAM(10);

            ram.Memory[0] = 0x12;
            ram.Memory[1] = 0x34;
            ram.Memory[2] = 0x56;
            ram.Memory[3] = 0x78;
            ram.Memory[4] = 0x21;
            ram.Memory[5] = 0x43;
            ram.Memory[6] = 0x65;
            int size = 3;

            byte[] data = new byte[size];
            Assert.AreEqual(-2, ram.Read(data, 10, size));
        }
示例#3
0
        public void ReadSuccessTest()
        {
            FRAM ram = new FRAM(10);

            ram.Memory[0] = 0x12;
            ram.Memory[1] = 0x34;
            ram.Memory[2] = 0x56;
            ram.Memory[3] = 0x78;
            ram.Memory[4] = 0x21;
            ram.Memory[5] = 0x43;
            ram.Memory[6] = 0x65;
            int size = 3;

            byte[] data = new byte[size];
            Assert.AreEqual(0, ram.Read(data, 4, size));
            Assert.AreEqual(0x21, data[0]);
            Assert.AreEqual(0x43, data[1]);
            Assert.AreEqual(0x65, data[2]);
        }