public MainWindow() { InitializeComponent(); obd = new ObdDevice(); obd.ObdChanged += _obd_ObdChanged; obd.Connect("COM1", 115200, ObdDevice.UnknownProtocol, true); Dictionary <int, List <int> > sPids = obd.GetSupportedPids(); foreach (var sp in sPids.Keys) { log.Text += "Key : " + sp.ToString() + Environment.NewLine; List <int> keyValues = new List <int>(); if (sPids.TryGetValue((int)sp, out keyValues)) { foreach (var kv in keyValues) { log.Text += "Value : " + kv.ToString() + Environment.NewLine; } } } //obd.GetPidData() }
void UserControl_Loaded(object sender, RoutedEventArgs e) { _obd = new ObdDevice(); _obd.ObdConnectionChanged += _obd_ObdConnectionChanged; _obd.ObdChanged += _obd_ObdChanged; SetMessage("Connecting to OBD..."); if (!DesignerProperties.GetIsInDesignMode(this) && !string.IsNullOrEmpty(Properties.Settings.Default.ComPort)) { try { Task.Factory.StartNew(() => _obd.Connect(Properties.Settings.Default.ComPort, Properties.Settings.Default.Baud, ObdDevice.UnknownProtocol, true)) .ContinueWith(action => { Exception ex = action.Exception.Flatten(); SetMessage("Unable to connect to OBD device: " + ex.Message); Debug.WriteLine(ex); }, TaskContinuationOptions.OnlyOnFaulted); } catch (Exception ex) { SetMessage("Unable to connect to OBD device: " + ex.Message); Debug.WriteLine(ex); } } uxSkin1967.uxSettings.Click += uxSettings_Click; uxSkin2011.uxSettings.Click += uxSettings_Click; uxSkinMetro.uxSettings.Click += uxSettings_Click; _skins[0] = uxSkin2011; _skins[1] = uxSkin1967; _skins[2] = uxSkinMetro; uxSkin1967.Visibility = Visibility.Collapsed; uxSkinMetro.Visibility = Visibility.Collapsed; }
public async void Startup() { //todo: replace with confi setting builders: port type and ID data Logger.DebugWrite("Trying to connect..."); var devices = await DeviceInformation.FindAllAsync(RfcommDeviceService.GetDeviceSelector(RfcommServiceId.SerialPort)); var device = devices[0].Id; var btd = await BluetoothDevice.FromIdAsync(device); await btd.RequestAccessAsync(); var btp = new ObdBluetoothPort("Port"); var provider = new ObdDevice(btp); await provider.Connect(); var debug = new DebugSubscriber(); var iot = new IotSubscriber("<YOUR IOT HUB NAME>", "<YOUR DEVICE>", "<YOUR DEVICE KEY>"); provider.Subscribe(debug); provider.Subscribe(iot); provider.Startup(); }
// Use this for initialization void Start() { Application.targetFrameRate = 30; if (Display.displays.Length > 1) { Display.displays[1].Activate(); Display.displays[2].Activate(); } if (testingInUnity == false) { try { obd = new ObdDevice(); obd.ObdChanged += obd_ObdChanged; obd.Connect("COM6", 115200, ObdDevice.UnknownProtocol, true); GetSettings(); } catch (Exception e) { Debug.Log(e.Message); } } }