protected override void ProcessRecord() { var spiChannel = Unosquare.RaspberryIO.Pi.Spi.Channel0; if (this.Channel == 1) { spiChannel = Unosquare.RaspberryIO.Pi.Spi.Channel1; Unosquare.RaspberryIO.Pi.Spi.Channel1Frequency = (int)this.Frequency; } else { Unosquare.RaspberryIO.Pi.Spi.Channel0Frequency = (int)this.Frequency; }; var response = spiChannel.SendReceive(this.Data); if (this.Raw) { WriteObject(response); } else { SPIData spiData = new SPIData(this.Channel, this.Frequency, this.Data, response); WriteObject(spiData); } }
protected override void ProcessRecord() { try { var spiChannel = Unosquare.RaspberryIO.Pi.Spi.Channel0; if (this.Channel == 1) { spiChannel = Unosquare.RaspberryIO.Pi.Spi.Channel1; Unosquare.RaspberryIO.Pi.Spi.Channel1Frequency = (int)this.Frequency; } else { Unosquare.RaspberryIO.Pi.Spi.Channel0Frequency = (int)this.Frequency; }; var response = spiChannel.SendReceive(this.Data); if (this.Raw) { WriteObject(response); } else { SPIData spiData = new SPIData(this.Channel, this.Frequency, this.Data, response); WriteObject(spiData); } } 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; } }