public Rly16Hal(string comPort) { if (comPort == string.Empty) { return; } _port = new SerialPort(comPort, 19200, Parity.None, 8, StopBits.Two) {ReadTimeout = 1500, WriteTimeout = 1500}; _port.Open(); _tempinputs = new byte[2]; _index = 0; _inUse = false; Info = new HardwareInfo() {Inputs = 8, Outputs = 8}; Log.Debug("Rly16Hal started"); }
public ConsoleHal() { Info = new HardwareInfo() { PwmMinValue = 0, PwmMaxValue = 1023, AnalogMinValue = 0, AnalogMaxValue = 1023 }; }
public GpioHal(IList<Pin> pins, string driverName = "", bool useProcessorPinsNames = false, PinResistor inputResistor = PinResistor.PullUp) { _inUse = false; _driver = GetDriver(driverName); // GPIO driver _inputResistor = inputResistor; // Pullup/pulldown input resistors _pins = new Dictionary<string, ProcessorPin>(); // Global pins foreach (var pin in pins) { ProcessorPin procPin; if (useProcessorPinsNames) { ConnectorPin userPin; if (!Enum.TryParse(pin.Source, true, out userPin)) { throw new HardwareException(string.Format("raspberry connector pin {0} not found", pin.Source)); } procPin = userPin.ToProcessor(); } else { if (!Enum.TryParse(pin.Source, true, out procPin)) { throw new HardwareException(string.Format("raspberry processor pin {0} not found", pin.Source)); } } switch (pin.Type) { case PinTypes.Input: case PinTypes.Counter: case PinTypes.Analog: //Allocate pin _driver.Allocate(procPin, PinDirection.Input); //Set pullup/pulldown resistor if (_inputResistor != PinResistor.None && (_driver.GetCapabilities() & GpioConnectionDriverCapabilities.CanSetPinResistor) > 0) _driver.SetPinResistor(procPin, _inputResistor); break; case PinTypes.Output: case PinTypes.Pwm: //Allocate output pin _driver.Allocate(procPin, PinDirection.Output); break; } //set input pins in global input pins _globalPins |= (ProcessorPins)((uint)1 << (int)procPin); //Add proessor pin _pins.Add(pin.Source, procPin); } Info = new HardwareInfo { Name = "Raspberry model " + Raspberry.Board.Current.Model + "GPIO HAL", Inputs = GpioConnectionSettings.ConnectorPinout == Raspberry.ConnectorPinout.Rev2 ? 26 : 17, Outputs = GpioConnectionSettings.ConnectorPinout == Raspberry.ConnectorPinout.Rev2 ? 26 : 17, Analogs = 0, Pwms = 0, Counters = 0, Vendor = "Raspberry foundation" }; }