private static void DisplayPortCapabilities() { using (var session = new ArduinoSession(new EnhancedSerialConnection("COM4", SerialBaudRate.Bps_57600))) { session.StringReceived += (object sender, StringEventArgs eventArgs) => { Console.WriteLine(eventArgs.Text); }; BoardCapability cap = session.GetBoardCapability(); Console.WriteLine(); Console.WriteLine("Board Capability:"); foreach (var pin in cap.Pins) { Console.WriteLine("Pin {0}: Input: {1}, Output: {2}, Analog: {3}, Analog-Res: {4}, PWM: {5}, PWM-Res: {6}, Servo: {7}, Servo-Res: {8}, Serial: {9}, Encoder: {10}, Input-pullup: {11}", pin.PinNumber, pin.DigitalInput, pin.DigitalOutput, pin.Analog, pin.AnalogResolution, pin.Pwm, pin.PwmResolution, pin.Servo, pin.ServoResolution, pin.Serial, pin.Encoder, pin.InputPullup); } } }
} = null; //To be supplied externally public ArduinoDeviceManager(ArduinoSession firmata, Action <ADMMessage, ArduinoDeviceManager> listener, String port, String nodeID = null) { State = ADMState.CONNECTING; _devices = new Dictionary <String, ArduinoDevice>(); _device2boardID = new Dictionary <String, byte>(); _boardID2device = new Dictionary <byte, ArduinoDevice>(); _pin2device = new Dictionary <int, List <ArduinoDevice> >(); _portStates = new Dictionary <int, DigitalPortState>(); _session = firmata; _listener = listener; _session.MessageReceived += HandleFirmataMessageReceived; _session.ProcessMessageException += HandleFirmataProcessMessageException; Port = port; NodeID = nodeID; _session.ID = PortAndNodeID; _firmware = _session.GetFirmware(); #if DEBUG Debug.Print(String.Format("{0}: Firmware: {1} version {2}.{3}", PortAndNodeID, _firmware.Name, _firmware.MajorVersion, _firmware.MinorVersion)); #endif _protocolVersion = _session.GetProtocolVersion(); #if DEBUG Debug.Print(String.Format("{0}: Firmata protocol version {1}.{2}", PortAndNodeID, _protocolVersion.Major, _protocolVersion.Minor)); #endif _boardCapability = _session.GetBoardCapability(); State = ADMState.CONNECTED; //if here and no exceptions then the connection should be good //so initialise the board Initialise(); //and request board status RequestStatus(); }