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") + ")"); }
} // 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
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); }
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); }
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(); }
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") + ")"); }
unsafe public static int ReadEEPROM(ushort addr, byte num_bytes, out byte[] buf) { return(Flex1500.ReadEEPROM(addr, num_bytes, out buf)); }