private static extern int ioctl(int descriptor, UInt32 request, SpiTransferControlStructure[] data);
 /// <summary>
 /// The function manipulates the underlying device parameters of special files. In particular, many operating characteristics of character special files (e.g. terminals) may be controlled with ioctl requests.
 /// </summary>
 /// <param name="request">A device-dependent request code.</param>
 /// <param name="data">The SPI control data structures to be transmitted.</param>
 /// <returns>Usually, on success zero is returned. A few ioctls use the return value as an output parameter and return a nonnegative value on success. On error, -1 is returned, and errno is set appropriately.</returns>
 public int Control(UInt32 request, SpiTransferControlStructure[] data)
 {
     var result = ioctl(file.Descriptor, request, data);
     return result;
 }
        protected override void EstablishContext()
        {
            // SPI control structure we expect to see during the P/Invoke call
            controlStructure = new SpiTransferControlStructure {
                BitsPerWord = BITS_PER_WORD,
                Length = 5,
                Delay = DELAY,
                ChipSelectChange = 1,
                Speed = SPEED_IN_HZ
            };

            controlDevice = A.Fake<ISpiControlDevice>();
            controlDevice
                .CallsTo(device => device.Control(A<uint>.Ignored, ref controlStructure))
                .WithAnyArguments()
                .Returns(IOCTL_PINVOKE_RESULT_CODE);

            connection = new NativeSpiConnection(controlDevice);

            buffer = A.Fake<ISpiTransferBuffer>();
            buffer
                .CallsTo(b => b.ControlStructure)
                .Returns(controlStructure);
        }
        protected override void EstablishContext()
        {
            controlDevice = A.Fake<ISpiControlDevice>();
            controlDevice
                .CallsTo(device => device.Control(A<uint>.Ignored, A<SpiTransferControlStructure[]>.Ignored))
                .Returns(IOCTL_PINVOKE_RESULT_CODE);

            connection = new NativeSpiConnection(controlDevice);

            // SPI control structure we expect to see during the P/Invoke call
            controlStructure = new SpiTransferControlStructure {
                BitsPerWord = BITS_PER_WORD,
                Length = 5,
                Delay = DELAY,
                ChipSelectChange = 1,
                Speed = SPEED_IN_HZ
            };

            buffer = A.Fake<ISpiTransferBuffer>();
            buffer
                .CallsTo(b => b.ControlStructure)
                .Returns(controlStructure);

            // setup fake collection to return our "prepared" fake buffer
            collection = A.Fake<ISpiTransferBufferCollection>();
            collection
                .CallsTo(c => c.Length)
                .Returns(1);
            collection
                .CallsTo(c => c.GetEnumerator())
                .ReturnsLazily(call => new List<ISpiTransferBuffer>{buffer}.GetEnumerator());
        }
예제 #5
0
        /// <summary>
        /// The function manipulates the underlying device parameters of special files. In particular, many operating characteristics of character special files (e.g. terminals) may be controlled with ioctl requests.
        /// </summary>
        /// <param name="request">A device-dependent request code.</param>
        /// <param name="data">The data to be transmitted.</param>
        /// <returns>Usually, on success zero is returned. A few ioctls use the return value as an output parameter and return a nonnegative value on success. On error, -1 is returned, and errno is set appropriately.</returns>
        public int Control(UInt32 request, ref SpiTransferControlStructure data)
        {
            var result = ioctl(file.Descriptor, request, ref data);

            return(result);
        }
예제 #6
0
 private static extern int ioctl(int descriptor, UInt32 request, ref SpiTransferControlStructure data);