コード例 #1
0
 protected override void ProcessRecord()
 {
     if (this.ByteCount > 1)
     {
         this.Device.device.Write((byte)this.Register);
         byte[] value = this.Device.device.Read(this.ByteCount);
         if (this.Raw)
         {
             WriteObject(value);
         }
         else
         {
             I2CDeviceRegisterData result = new I2CDeviceRegisterData(this.Device, this.Register);
             result.Data = value;
             WriteObject(result);
         }
     }
     else
     {
         byte value = this.Device.device.ReadAddressByte(this.Register);
         if (this.Raw)
         {
             WriteObject(value);
         }
         else
         {
             I2CDeviceRegisterData result = new I2CDeviceRegisterData(this.Device, this.Register, new byte[1] {
                 value
             });
             WriteObject(result);
         }
     }
 }
コード例 #2
0
 protected override void ProcessRecord()
 {
     this.Device.device.WriteAddressByte(this.Register, this.Data[0]);
     if (this.PassThru)
     {
         I2CDeviceRegisterData result = new I2CDeviceRegisterData(this.Device, this.Register, this.Data);
         WriteObject(result);
     }
 }
コード例 #3
0
 protected override void ProcessRecord()
 {
     try
     {
         if (this.ByteCount > 1)
         {
             this.Device.device.Write((byte)this.Register);
             byte[] value = this.Device.device.Read(this.ByteCount);
             if (this.Raw)
             {
                 WriteObject(value);
             }
             else
             {
                 I2CDeviceRegisterData result = new I2CDeviceRegisterData(this.Device, this.Register);
                 result.Data = value;
                 WriteObject(result);
             }
         }
         else
         {
             byte value = this.Device.device.ReadAddressByte(this.Register);
             if (this.Raw)
             {
                 WriteObject(value);
             }
             else
             {
                 I2CDeviceRegisterData result = new I2CDeviceRegisterData(this.Device, this.Register, new byte[1] {
                     value
                 });
                 WriteObject(result);
             }
         }
     }
     catch (System.TypeInitializationException e) // Unosquare.RaspberryIO.Gpio.GpioController.Initialize throws this TypeInitializationException
     {
         if (!Unosquare.RaspberryIO.Computer.SystemInfo.Instance.IsRunningAsRoot)
         {
             throw new PlatformNotSupportedException(Resources.ErrNeedRootPrivileges, e);
         }
         throw;
     }
 }
コード例 #4
0
 protected override void ProcessRecord()
 {
     try
     {
         this.Device.device.WriteAddressByte(this.Register, this.Data[0]);
         if (this.PassThru)
         {
             I2CDeviceRegisterData result = new I2CDeviceRegisterData(this.Device, this.Register, this.Data);
             WriteObject(result);
         }
     }
     catch (System.TypeInitializationException e) // Unosquare.RaspberryIO.Gpio.GpioController.Initialize throws this TypeInitializationException
     {
         if (!Unosquare.RaspberryIO.Computer.SystemInfo.Instance.IsRunningAsRoot)
         {
             throw new PlatformNotSupportedException(Resources.ErrNeedRootPrivileges, e);
         }
         throw;
     }
 }