コード例 #1
0
        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()
        }
コード例 #2
0
ファイル: StartupTask.cs プロジェクト: jpda/iot-obd
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            //used to hold process after this thread has moved past the publisher
            var deferral = taskInstance.GetDeferral();

            //todo: replace with confi setting builders: port type and ID data
            Logger.DebugWrite("Trying to connect...");
            var btp      = new ObdBluetoothPort("Port");
            var provider = new ObdDevice(btp);

            var debug = new DebugSubscriber();
            var iot   = new IotSubscriber("<YOUR IOT HUB>", "<IOT HUB DEVICE NAME>", "<HUB DEVICE KEY>");

            provider.Subscribe(debug);
            provider.Subscribe(iot);
            provider.Startup();
        }
コード例 #3
0
        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;
        }
コード例 #4
0
ファイル: MainPage.xaml.cs プロジェクト: jpda/iot-obd
        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();
        }
コード例 #5
0
ファイル: Master.cs プロジェクト: chris070121/Car_Gauges
    // 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);
            }
        }
    }