コード例 #1
0
        /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
        /// <summary>
        /// Opens the port. Throws an exception on failure
        ///
        /// </summary>
        /// <history>
        ///    01 Dec 16  Cynic - Originally written
        /// </history>
        protected override void OpenPort()
        {
            string deviceFileName;

            // set up now
            deviceFileName = RPIDefinitions.I2CDEV_FILENAME;

            // set up the i2c port number
            if (I2CPort == I2CPortEnum.I2CPORT_1)
            {
                deviceFileName = deviceFileName.Replace("%port%", "1");
            }
            else
            {
                // should never happen
                throw new Exception("Unknown I2C Port:" + I2CPort.ToString());
            }

            // we open the file. We have to have an open file descriptor
            // note this is an external call. It has to be because the
            // ioctl needs an open file descriptor it can use
            i2CPortFD = ExternalFileOpen(deviceFileName, O_RDWR | O_NONBLOCK);
            if (i2CPortFD <= 0)
            {
                throw new Exception("Could not open i2c device file:" + deviceFileName);
            }
            portIsOpen = true;

            //   Console.WriteLine("I2CPort Port Device Enabled: "+ deviceFileName);
        }
コード例 #2
0
ファイル: StatusHandling.cs プロジェクト: robotdotnet/WPILib
 public static void I2CStatusCheck(int status, I2CPort handle)
 {
     StatusCheckForce(status);
 }
コード例 #3
0
ファイル: I2CLowLevel.cs プロジェクト: robotdotnet/WPILib
 public static int Write(I2CPort port, int deviceAddress, byte *dataToSend, int sendSize)
 {
     return(lowLevel.HAL_WriteI2C(port, deviceAddress, dataToSend, sendSize));
 }
コード例 #4
0
ファイル: I2CLowLevel.cs プロジェクト: robotdotnet/WPILib
 public static int Transaction(I2CPort port, int deviceAddress, byte *dataToSend, int sendSize, byte *dataReceived, int receiveSize)
 {
     return(lowLevel.HAL_TransactionI2C(port, deviceAddress, dataToSend, sendSize, dataReceived, receiveSize));
 }
コード例 #5
0
ファイル: I2CLowLevel.cs プロジェクト: robotdotnet/WPILib
 public static int Read(I2CPort port, int deviceAddress, byte *buffer, int count)
 {
     return(lowLevel.HAL_ReadI2C(port, deviceAddress, buffer, count));
 }
コード例 #6
0
ファイル: I2CLowLevel.cs プロジェクト: robotdotnet/WPILib
 public static void Initialize(I2CPort port)
 {
     lowLevel.HAL_InitializeI2C(port);
 }
コード例 #7
0
ファイル: I2CLowLevel.cs プロジェクト: robotdotnet/WPILib
 public static void Close(I2CPort port)
 {
     lowLevel.HAL_CloseI2C(port);
 }