Exemplo n.º 1
0
        /// <summary>
        /// Sends a request to a module and then polls the module to get the response.
        /// </summary>
        /// <param name="addr">Module address.</param>
        /// <param name="buffer">I2C data to be sent, I2C data received after method returns.</param>
        /// <returns>Status of communication. True if response is valid, false otherwise.</returns>
        protected virtual bool RequestToModuleFromBuffer(int addr, ref byte[] buffer)
        {
            var m = new I2CManager();

            CRC16.PutCRC(ref buffer);

            LogBuffer(buffer, "I2C data sent");

            int fd = GetFDFromAddress(addr);
            int l  = m.I2CWriteBlock(fd, ref buffer);

            for (int i = 0; i < ICCConstants.PACKETSIZE; i++)
            {
                buffer[i] = 0;
            }

            return(PollModuleForResponse(addr, ref buffer));
        }
Exemplo n.º 2
0
        public static int RequestToModuleFromBuffer(int addr, ref byte[] buffer)
        {
            var m = new I2CManager();

            CRC16.PutCRC(ref buffer);
            int fd = GetFDFromAddress(addr);

            Console.WriteLine(string.Format("RequestToModuleFromBuffer : File descriptor : {0}", fd));
            int l = m.I2CWriteBlock(fd, ref buffer);

            //int l = m.I2CWriteBlockAddr(addr, ref buffer);

            PrintBuffer(buffer, "RequestToModuleFromBuffer");

            for (int i = 0; i < ICCConstants.PACKETSIZE; i++)
            {
                buffer[i] = 0;
            }

            return(PollModuleForResponse(addr, ref buffer));
        }