private void btnEEWrite_Click(object sender, EventArgs e) { ushort offset = ushort.Parse(txtOffset.Text, NumberStyles.HexNumber); byte num_bytes = byte.Parse(txtNumBytes.Text, NumberStyles.HexNumber); if (num_bytes > txtData.Text.Length / 2) { MessageBox.Show("Error: Not enough data"); return; } byte[] data = new byte[num_bytes]; for (int i = 0; i < num_bytes; i++) { data[i] = byte.Parse(txtData.Text.Substring(i * 2, 2), NumberStyles.HexNumber); } HiPerfTimer t1 = new HiPerfTimer(); t1.Start(); int val; //fixed(byte* ptr = &data[0]) val = Flex1500.WriteEEPROM(offset, data); t1.Stop(); Debug.WriteLine("EEWrite: " + val + " (" + t1.DurationMsec.ToString("f2") + ")"); }
} // buttonTS2_Click private void btnEEPROMRead1_Click(object sender, EventArgs e) { // if (txtEEPROMOffset.Text == "") return; // txtEEPROMRead.BackColor = Color.Red; Application.DoEvents(); // uint offset = uint.Parse(txtEEPROMOffset.Text, System.Globalization.NumberStyles.HexNumber); Debug.WriteLine("TRYING TO OPEN EEPROM TXT FILE TO WRITE TO "); string file_name2 = console.AppDataPath + "USBEEEPROMDATA.txt"; // save data for my mods FileStream stream2 = new FileStream(file_name2, FileMode.Create); // open file BinaryWriter writer2 = new BinaryWriter(stream2); Debug.WriteLine("OPENED EEPROM TXT FILE TO WRITE TO "); ushort offset; // 16bit int byte[] data; string datastring; string final; string offsetstring; int val; for (offset = 0x1800; offset < 0x2500; offset++) // valid data here (x1819 is Turf) { Debug.Write(" Reading offset-> " + offset); val = Flex1500.ReadEEPROM(offset, 1, out data); // MessageBox.Show("Error in ReadTRXEEPROM."); // if (FWC.ReadTRXEEPROMByte(offset, out data) == 0) Debug.WriteLine(" Data-> " + data[0]); // txtEEPROMRead.BackColor = SystemColors.Control; datastring = String.Format("{0:X4}", data[0]); // txtEEPROMRead.Text = datastring; offsetstring = String.Format("{0:X4}", offset); // txtEEPROMOffset.Text = offsetstring; final = offsetstring + " , " + datastring + "\n"; writer2.Write(final); } // for offset loop writer2.Close(); // close file stream2.Close(); // close stream } // btneepromread1_click
public static bool GetStatus() { uint status; int rtn = Flex1500.ReadOp(Opcode.USB_OP_GET_STATUS, 0, 0, out status); return(status != 0); }
private void btnEERead_Click(object sender, EventArgs e) { ushort offset = ushort.Parse(txtOffset.Text, NumberStyles.HexNumber); byte num_bytes = byte.Parse(txtNumBytes.Text, NumberStyles.HexNumber); byte[] data; HiPerfTimer t1 = new HiPerfTimer(); t1.Start(); int val; val = Flex1500.ReadEEPROM(offset, num_bytes, out data); t1.Stop(); txtEERead.Text = ""; for (int i = 0; i < num_bytes; i++) { txtEERead.Text += data[i].ToString("X").PadLeft(2, '0'); } Debug.WriteLine("EERead: " + val + " (" + t1.DurationMsec.ToString("f2") + ")"); }
public static int GetSerialNum(out uint sn) { int val = Flex1500.ReadOp(Opcode.USB_OP_GET_SERIAL_NUM, 0, 0, out sn); sn = SwapBytes(sn); return(val); }
public static int GetPASN(out uint sn) { int val = Flex1500.ReadOp(Opcode.USB_OP_GET_PA_SN, 0, 0, out sn); sn = SwapBytes(sn); return(val); }
public static int GetPARev(out uint rev) { int val = Flex1500.ReadOp(Opcode.USB_OP_GET_PA_REV, 0, 0, out rev); rev = SwapBytes(rev); return(val); }
unsafe public static int ReadTRXEEPROMByte(uint offset, out byte buf) { byte[] temp; int val = Flex1500.ReadEEPROM((ushort)offset, 1, out temp); buf = temp[0]; return(val); }
public static int ReadGPIO(out byte data) { uint x; int val = Flex1500.ReadOp(Opcode.USB_OP_READ_GPIO, 0, 0, out x); data = (byte)x; return(val); }
public static int ReadI2CValue(byte addr, byte data, out byte result) { uint val; int n = Flex1500.ReadOp(Opcode.USB_OP_I2C_READ_VALUE, (uint)addr, (uint)data, out val); result = (byte)val; return(n); }
} // buttonTS3_Click (TURF) //=============================================================================== private void buttonTS1_Click(object sender, EventArgs e) { DialogResult dr = MessageBox.Show("Warning: You must have Authorization as a MARS Licensed Operator.\n", "Do you have authorization?", MessageBoxButtons.YesNo, MessageBoxIcon.Question); int val = 0; byte[] data = new byte[1]; data[0] = 0x01; if (dr == DialogResult.Yes) { // val = Flex1500.WriteEEPROM(offset, data); // val = Flex1500.ReadEEPROM(offset, num_bytes, out data); val = Flex1500.WriteEEPROM(0x1818, data); // x1818, 181a-1f are all FF /* * if (FWC.WriteTRXEEPROMByte(0x0034, 0x2D) == 0) MessageBox.Show("Error in WriteEEPROM 34"); * txtEEPROMWrite.BackColor = SystemColors.Window; * btnEEPROMRead_Click(this, EventArgs.Empty); * if (FWC.WriteTRXEEPROMByte(0x0035, 0x05) == 0) MessageBox.Show("Error in WriteEEPROM 35"); * txtEEPROMWrite.BackColor = SystemColors.Window; * btnEEPROMRead_Click(this, EventArgs.Empty); * if (FWC.WriteTRXEEPROMByte(0x0036, 0x00) == 0) MessageBox.Show("Error in WriteEEPROM 36"); * txtEEPROMWrite.BackColor = SystemColors.Window; * btnEEPROMRead_Click(this, EventArgs.Empty); * if (FWC.WriteTRXEEPROMByte(0x0037, 0x00) == 0) MessageBox.Show("Error in WriteEEPROM 37"); * txtEEPROMWrite.BackColor = SystemColors.Window; * btnEEPROMRead_Click(this, EventArgs.Empty); * if (FWC.WriteTRXEEPROMByte(0x0038, 0x0D) == 0) MessageBox.Show("Error in WriteEEPROM 38"); * txtEEPROMWrite.BackColor = SystemColors.Window; * btnEEPROMRead_Click(this, EventArgs.Empty); * if (FWC.WriteTRXEEPROMByte(0x0039, 0x0B) == 0) MessageBox.Show("Error in WriteEEPROM 39"); * txtEEPROMWrite.BackColor = SystemColors.Window; * btnEEPROMRead_Click(this, EventArgs.Empty); * if (FWC.WriteTRXEEPROMByte(0x003A, 0x01) == 0) MessageBox.Show("Error in WriteEEPROM 3a"); * txtEEPROMWrite.BackColor = SystemColors.Window; * btnEEPROMRead_Click(this, EventArgs.Empty); * if (FWC.WriteTRXEEPROMByte(0x003B, 0x00) == 0) MessageBox.Show("Error in WriteEEPROM 3b"); * txtEEPROMWrite.BackColor = SystemColors.Window; * btnEEPROMRead_Click(this, EventArgs.Empty); * if (FWC.WriteTRXEEPROMByte(0x003C, 0x78) == 0) MessageBox.Show("Error in WriteEEPROM 3c"); * txtEEPROMWrite.BackColor = SystemColors.Window; * btnEEPROMRead_Click(this, EventArgs.Empty); */ } MessageBox.Show("You must cycle power to the radio", "Cycle Power", MessageBoxButtons.OK, MessageBoxIcon.Warning); } // buttonTS1_Click
unsafe public static int ReadTRXEEPROMFloat(uint offset, out float buf) { int val; byte[] temp = new byte[4]; val = Flex1500.ReadEEPROM((ushort)offset, 4, out temp); buf = BitConverter.ToSingle(temp, 0); return(val); }
unsafe public static int ReadTRXEEPROMUshort(uint offset, out ushort buf) { int val; byte[] temp = new byte[2]; val = Flex1500.ReadEEPROM((ushort)offset, 2, out temp); buf = BitConverter.ToUInt16(temp, 0); return(val); }
} // buttonTS1_Click private void buttonTS2_Click(object sender, EventArgs e) { DialogResult dr = MessageBox.Show("This will reset any MARS operate back to Normal Standard Operation\n", "Yes?", MessageBoxButtons.YesNo, MessageBoxIcon.Question); int val = 0; byte[] data = new byte[1]; data[0] = 0xff; if (dr == DialogResult.Yes) { // val = Flex1500.WriteEEPROM(offset, data); // val = Flex1500.ReadEEPROM(offset, num_bytes, out data); val = Flex1500.WriteEEPROM(0x1818, data); /* * if (FWC.WriteTRXEEPROMByte(0x0034, 0xff) == 0) MessageBox.Show("Error in WriteEEPROM 34"); * txtEEPROMWrite.BackColor = SystemColors.Window; * btnEEPROMRead_Click(this, EventArgs.Empty); * if (FWC.WriteTRXEEPROMByte(0x0035, 0xff) == 0) MessageBox.Show("Error in WriteEEPROM 35"); * txtEEPROMWrite.BackColor = SystemColors.Window; * btnEEPROMRead_Click(this, EventArgs.Empty); * if (FWC.WriteTRXEEPROMByte(0x0036, 0xff) == 0) MessageBox.Show("Error in WriteEEPROM 36"); * txtEEPROMWrite.BackColor = SystemColors.Window; * btnEEPROMRead_Click(this, EventArgs.Empty); * if (FWC.WriteTRXEEPROMByte(0x0037, 0xff) == 0) MessageBox.Show("Error in WriteEEPROM 37"); * txtEEPROMWrite.BackColor = SystemColors.Window; * btnEEPROMRead_Click(this, EventArgs.Empty); * if (FWC.WriteTRXEEPROMByte(0x0038, 0xff) == 0) MessageBox.Show("Error in WriteEEPROM 38"); * txtEEPROMWrite.BackColor = SystemColors.Window; * btnEEPROMRead_Click(this, EventArgs.Empty); * if (FWC.WriteTRXEEPROMByte(0x0039, 0xff) == 0) MessageBox.Show("Error in WriteEEPROM 39"); * txtEEPROMWrite.BackColor = SystemColors.Window; * btnEEPROMRead_Click(this, EventArgs.Empty); * if (FWC.WriteTRXEEPROMByte(0x003A, 0xff) == 0) MessageBox.Show("Error in WriteEEPROM 3a"); * txtEEPROMWrite.BackColor = SystemColors.Window; * btnEEPROMRead_Click(this, EventArgs.Empty); * if (FWC.WriteTRXEEPROMByte(0x003B, 0xff) == 0) MessageBox.Show("Error in WriteEEPROM 3b"); * txtEEPROMWrite.BackColor = SystemColors.Window; * btnEEPROMRead_Click(this, EventArgs.Empty); * if (FWC.WriteTRXEEPROMByte(0x003C, 0xff) == 0) MessageBox.Show("Error in WriteEEPROM 3c"); * txtEEPROMWrite.BackColor = SystemColors.Window; * btnEEPROMRead_Click(this, EventArgs.Empty); */ } } // buttonTS2_Click
public static int GetRegion(out FRSRegion region) { uint data; int rtn = Flex1500.ReadOp(Opcode.USB_OP_GET_REGION, 0, 0, out data); // get Flex-1500 TURF region if ((FRSRegion)data >= FRSRegion.LAST) { region = 0; return(rtn); } region = (FRSRegion)data; return(rtn); }
/* * private void PTT(bool state) * { * if (state) * { * butPTT.BackColor = Color.GreenYellow; * } * else * { * butPTT.BackColor = SystemColors.Control; * } * } * * private void FlexPTT(bool state) * { * if (state) * { * butFlexPTT.BackColor = Color.GreenYellow; * } * else * { * butFlexPTT.BackColor = SystemColors.Control; * } * } * * private void Dash(bool state) * { * if (state) * { * butDash.BackColor = Color.GreenYellow; * } * else * { * butDash.BackColor = SystemColors.Control; * } * ToggleTones(); * } * * private void Dot(bool state) * { * if (state) * { * butDot.BackColor = Color.GreenYellow; * } * else * { * butDot.BackColor = SystemColors.Control; * } * ToggleTones(); * } * * private void ToggleTones() * { * if (tone1 == 350.0f) * { * tone1 = 941.0f; * tone2 = 1209.0f; * } * else * { * tone1 = 350.0f; * tone2 = 440.0f; * } * } */ private void btnWrite_Click(object sender, EventArgs e) { uint op = uint.Parse(txtOpcode.Text); uint p1 = uint.Parse(txtParam1.Text, NumberStyles.HexNumber); uint p2 = uint.Parse(txtParam2.Text, NumberStyles.HexNumber); HiPerfTimer t1 = new HiPerfTimer(); t1.Start(); int val = Flex1500.WriteOp((USBHID.Opcode)op, p1, p2); t1.Stop(); Debug.WriteLine("WriteOp: " + val + " (" + t1.DurationMsec.ToString("f2") + ")"); }
private void btnReadEEFile_Click(object sender, EventArgs e) { FileStream fs = File.Create("firmware.dat"); BinaryWriter writer = new BinaryWriter(fs); byte[] data; for (ushort i = 0; i < 8192; i += 32) { Flex1500.ReadEEPROM(i, 32, out data); writer.Write(data); } writer.Close(); fs.Close(); }
public static void Scan1500() { foreach (IntPtr key in pending_1500_list) { string sn = ""; for (int i = 0; i < 20; i++) { sn = Flex1500.GetSerial(key); if (sn != "0000-0000" && sn != "") { break; } Thread.Sleep(200); } if (sn == "1234-1234") { continue; // ignore sig gen } if (sn == "0000-0000") { continue; // skip radio -- communication issue } bool found = false; foreach (Radio r in list) { if (sn == r.SerialNumber) { r.AccessObj = key; r.Present = true; found = true; break; } } if (!found) { AddRadio(new Radio(Model.FLEX1500, key, sn, true)); } } pending_1500_list.Clear(); }
//========================================================================== // TURF selector private void buttonTS3_Click(object sender, EventArgs e) { DialogResult dr = MessageBox.Show("Warning: You are changing your Turf Region.\n", "Do you have authorization?", MessageBoxButtons.YesNo, MessageBoxIcon.Question); int val = 0; byte[] data = new byte[1]; // 1 byte long if (dr == DialogResult.Yes) { data[0] = (byte)numericUpDown1.Value; Debug.WriteLine("Byte value " + (byte)numericUpDown1.Value); val = Flex1500.WriteEEPROM(0x1819, data); } MessageBox.Show("You must close PowerSDR and cycle power to the radio. Then go to setup->General->Options->BandText Udpate", "Cycle Power", MessageBoxButtons.OK, MessageBoxIcon.Warning); } // buttonTS3_Click (TURF)
private void btnEEReadFloat_Click(object sender, EventArgs e) { ushort offset = ushort.Parse(txtOffset.Text, NumberStyles.HexNumber); //byte num_bytes = 4; HiPerfTimer t1 = new HiPerfTimer(); t1.Start(); int val; byte[] temp = new byte[4]; val = Flex1500.ReadEEPROM((ushort)offset, 4, out temp); float f = BitConverter.ToSingle(temp, 0); t1.Stop(); txtEERead.Text = f.ToString("f6"); Debug.WriteLine("EERead Float: " + val + " (" + t1.DurationMsec.ToString("f2") + ")"); }
// =================================================================== //ke9ns this is the phones jack on the flex 1500 public static int SetSpkGain(int val) { return(Flex1500.WriteOp(Opcode.USB_OP_SET_SPK_GAIN, (uint)val, 0)); }
unsafe public static int WriteEEPROM(ushort addr, byte[] buf) // up to 32 bytes { return(Flex1500.WriteEEPROM(addr, buf)); }
unsafe public static int WriteEEPROM(ushort addr, byte num_bytes, byte[] buf) { byte[] b = new byte[num_bytes]; Array.Copy(buf, b, num_bytes); return(Flex1500.WriteEEPROM(addr, b)); }
unsafe public static int ReadEEPROM(ushort addr, byte num_bytes, out byte[] buf) { return(Flex1500.ReadEEPROM(addr, num_bytes, out buf)); }
public static int SetMonGain(byte b) { return(Flex1500.WriteOp(Opcode.USB_OP_SET_MON_GAIN, (uint)b, 0)); }
//================================================================ // ke9ns MON turned on here, public static int SetMon(bool b) { return(Flex1500.WriteOp(Opcode.USB_OP_SET_MON, Convert.ToUInt32(b), 0)); }
public static int SetLineOutGain(int val) { //Debug.WriteLine("SetLineOutGain(0x" + val.ToString("X").PadLeft(2, '0') + ")"); return(Flex1500.WriteOp(Opcode.USB_OP_SET_LINE_OUT_GAIN, (uint)val, 0)); }
public static int SetMicSel(bool b) { return(Flex1500.WriteOp(Opcode.USB_OP_SET_MIC_SEL, b?(uint)1:(uint)0, 0)); }
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); } }
public static int SetLineOutOn(bool b) { return(Flex1500.WriteOp(Opcode.USB_OP_SET_LINE_OUT_ON, Convert.ToUInt32(b), 0)); }