private void PollRadios() { bool pal_init = false; while (!closing) { if (!pal_init) { pal_init = Pal.Init(); } else { pal_init = RadiosAvailable.ScanPal(); } RadiosAvailable.Scan1500(); Thread.Sleep(1000); } }
public static bool ScanPal() { Radio[] radios = Pal.Scan(); if (radios == null) { foreach (Radio r in list) { if (r.Model == Model.FLEX5000 || r.Model == Model.FLEX3000) { r.Present = false; } } return(false); } RadiosAvailable.AddRadios(radios); foreach (Radio r in list) { if (r.Model == Model.FLEX5000 || r.Model == Model.FLEX3000) { bool match = false; for (int i = 0; i < radios.Length; i++) { if (r.SerialNumber == radios[i].SerialNumber) { match = true; break; } } if (!match) { r.Present = false; } } } return(true); }
public static Radio[] Scan() { int devs = Pal.GetNumDevices(); // get numer of radios found // System.Diagnostics.Trace.WriteLine("pal============================="); if (devs == 0) { return(null); } Radio[] radios = new Radio[devs]; for (uint i = 0; i < devs; i++) { uint model; uint sn; if (!Pal.GetDeviceInfo(i, out model, out sn)) { return(null); } Model m = Model.FLEX5000; if (model == 3) { m = Model.FLEX3000; } string serial = FWCEEPROM.SerialToString(sn); // radios serial# radios[i] = new Radio(m, i, serial, true); } return(radios); } // Scan()
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex < 0) { return; } Radio r = RadiosAvailable.RadioList[e.RowIndex]; //DataGridViewRow row = dataGridView1.Rows[e.RowIndex]; if (e.ColumnIndex == dataGridView1.Columns["Use"].Index) // Use clicked { if (r.Present) { //MessageBox.Show("Use " + r.Model.ToString() + " " + r.SerialNumber); switch (r.Model) { case Model.FLEX5000: case Model.FLEX3000: Pal.SelectDevice((uint)r.AccessObj); break; case Model.FLEX1500: Flex1500.SetActiveRadio((IntPtr)r.AccessObj); break; case Model.SDR1000: case Model.SOFTROCK40: case Model.DEMO: break; } console.DBFileName = console.AppDataPath + r.GetDBFilename(); console.RadioToUse = r; this.Close(); } } if (e.ColumnIndex == dataGridView1.Columns["Remove"].Index) // Remove clicked { if (r.Model == Model.DEMO) { return; } DialogResult dr = MessageBox.Show("Are you sure you want to remove " + r.Model.ToString() + ": " + r.SerialNumber + " from the list?", "Remove radio?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (dr == DialogResult.No) { return; } Master.RemoveRadio(r); RadiosAvailable.RadioList.Remove(r); } }