Exemplo n.º 1
0
        private void writeToOfficalFirmware()
        {
            MainForm.CommsBuffer            = new byte[0x100000]; // 128k buffer
            CodeplugComms.CommunicationMode = CodeplugComms.CommunicationType.dataRead;
            CommPrgForm commPrgForm = new CommPrgForm(true);      // true =  close download form as soon as download is complete

            commPrgForm.StartPosition    = FormStartPosition.CenterParent;
            CodeplugComms.startAddress   = 0x50100;
            CodeplugComms.transferLength = 0x20;
            DialogResult result = commPrgForm.ShowDialog();

            Array.Copy(MainForm.CommsBuffer, 0x50100, DMRIDForm.DMRIDBuffer, 0, 0x20);
            if (!isInMemoryAccessMode(DMRIDForm.DMRIDBuffer))
            {
                MessageBox.Show(Settings.dicCommon["EnableMemoryAccessMode"]);
                return;
            }


            SIG_PATTERN_BYTES[3] = (byte)(0x4a + _stringLength + 4);

            byte[] uploadData = GenerateUploadData();
            Array.Copy(uploadData, 0, MainForm.CommsBuffer, 0x30000, (uploadData.Length / 32) * 32);
            CodeplugComms.CommunicationMode = CodeplugComms.CommunicationType.dataWrite;

            CodeplugComms.startAddress   = 0x30000;
            CodeplugComms.transferLength = (uploadData.Length / 32) * 32;
            commPrgForm.StartPosition    = FormStartPosition.CenterParent;
            result = commPrgForm.ShowDialog();
        }
Exemplo n.º 2
0
        private void btnWriteToGD77_Click(object sender, EventArgs e)
        {
            MainForm.CommsBuffer            = new byte[0x100000]; // 128k buffer
            CodeplugComms.CommunicationMode = CodeplugComms.CommunicationType.dataRead;
            CommPrgForm commPrgForm = new CommPrgForm(true);      // true =  close download form as soon as download is complete

            commPrgForm.StartPosition    = FormStartPosition.CenterParent;
            CodeplugComms.startAddress   = 0x50100;
            CodeplugComms.transferLength = 0x20;
            DialogResult result = commPrgForm.ShowDialog();

            Array.Copy(MainForm.CommsBuffer, 0x50100, DMRIDForm.DMRIDBuffer, 0, 0x20);
            if (!isInMemoryAccessMode(DMRIDForm.DMRIDBuffer))
            {
                MessageBox.Show(Settings.dicCommon["EnableMemoryAccessMode"]);
                return;
            }

            byte [] uploadData = GenerateUploadData();
            Array.Copy(uploadData, 0, MainForm.CommsBuffer, 0x30000, (uploadData.Length / 32) * 32);
            CodeplugComms.CommunicationMode = CodeplugComms.CommunicationType.dataWrite;

            CodeplugComms.startAddress   = 0x30000;
            CodeplugComms.transferLength = (uploadData.Length / 32) * 32;
            commPrgForm.StartPosition    = FormStartPosition.CenterParent;
            result = commPrgForm.ShowDialog();
        }
Exemplo n.º 3
0
        private void btnReadFromGD77_Click(object sender, EventArgs e)
        {
            MainForm.CommsBuffer            = new byte[0x100000]; // 128k buffer
            CodeplugComms.CommunicationMode = CodeplugComms.CommunicationType.dataRead;
            CommPrgForm commPrgForm = new CommPrgForm(true);      // true =  close download form as soon as download is complete

            commPrgForm.StartPosition    = FormStartPosition.CenterParent;
            CodeplugComms.startAddress   = 0xD0100;
            CodeplugComms.transferLength = 0x20;
            DialogResult result = commPrgForm.ShowDialog();

            Array.Copy(MainForm.CommsBuffer, 0xD0100, DMRIDForm.DMRIDBuffer, 0, 0x20);
            if (!isInMemoryAccessMode(DMRIDForm.DMRIDBuffer))
            {
                MessageBox.Show(Settings.dicCommon["EnableMemoryAccessMode"]);
                return;
            }

            CodeplugComms.startAddress   = 0x30000;
            CodeplugComms.transferLength = 0x20;
            result = commPrgForm.ShowDialog();
            Array.Copy(MainForm.CommsBuffer, 0x30000, DMRIDForm.DMRIDBuffer, 0, 0x20);


            int numRecords = BitConverter.ToInt32(DMRIDForm.DMRIDBuffer, 8);
            int stringLen  = (int)DMRIDForm.DMRIDBuffer[3] - 0x4a - 4;

            /*	if (stringLen!=8)
             *      {
             *              chkEnhancedFirmware.Checked=true;
             *      }*/
            cmbStringLen.SelectedIndex = stringLen - 6;

            CodeplugComms.startAddress   = 0x30000;
            CodeplugComms.transferLength = Math.Min(0xC0000, HEADER_LENGTH + (numRecords + 2) * (4 + _stringLength));


            CodeplugComms.CommunicationMode = CodeplugComms.CommunicationType.dataRead;
            result = commPrgForm.ShowDialog();
            Array.Copy(MainForm.CommsBuffer, 0x30000, DMRIDForm.DMRIDBuffer, 0, CodeplugComms.transferLength);

            radioToData();
            rebindData();
            //DataToCodeplug();
        }
        private void btnWrite_Click(object sender, EventArgs e)
        {
            if (DialogResult.Yes != MessageBox.Show("Writing the calibration data to Radio or any other compatible radio, could potentially damage your radio. By clicking 'Yes' you acknowledge that you use this feature entirely at your own risk", "WARNING", MessageBoxButtons.YesNo, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button2))
            {
                return;
            }

            // Pre-read to see if the Calibration area appears to be writable
            CodeplugComms.CommunicationMode = CodeplugComms.CommunicationType.dataRead;
            CommPrgForm commPrgForm = new CommPrgForm(true);            // true =  close download form as soon as download is complete

            commPrgForm.StartPosition    = FormStartPosition.CenterParent;
            CodeplugComms.startAddress   = 0x8f000;
            CodeplugComms.transferLength = 0x20;
            DialogResult result = commPrgForm.ShowDialog();

            if (MainForm.CommsBuffer[0x8f000] == 0x00 && MainForm.CommsBuffer[0x8f001] == 0x00)
            {
                MessageBox.Show(Settings.dicCommon["EnableMemoryAccessMode"]);
                return;
            }

            int calibrationDataSize = Marshal.SizeOf(typeof(CalibrationData));

            byte[] array = DataToByte(this.calibrationBandControlUHF.data);
            Array.Copy(array, 0, MainForm.CommsBuffer, 0x8F000, calibrationDataSize);

            array = DataToByte(this.calibrationBandControlVHF.data);
            Array.Copy(array, 0, MainForm.CommsBuffer, 0x8F070, calibrationDataSize);

            CodeplugComms.CommunicationMode = CodeplugComms.CommunicationType.calibrationWrite;

            commPrgForm = new CommPrgForm(true);            // true =  close download form as soon as download is complete
            commPrgForm.StartPosition = FormStartPosition.CenterParent;
            commPrgForm.ShowDialog();
        }
Exemplo n.º 5
0
        private void btnReadFromGD77_Click(object sender, EventArgs e)
        {
            MainForm.CommsBuffer            = new byte[0x100000]; // 128k buffer
            CodeplugComms.CommunicationMode = CodeplugComms.CommunicationType.dataRead;
            CommPrgForm commPrgForm = new CommPrgForm(true);      // true =  close download form as soon as download is complete

            commPrgForm.StartPosition    = FormStartPosition.CenterParent;
            CodeplugComms.startAddress   = 0x50100;
            CodeplugComms.transferLength = 0x20;
            DialogResult result = commPrgForm.ShowDialog();

            Array.Copy(MainForm.CommsBuffer, 0x50100, DMRIDForm.DMRIDBuffer, 0, 0x20);
            if (!isInMemoryAccessMode(DMRIDForm.DMRIDBuffer))
            {
                MessageBox.Show(Settings.dicCommon["EnableMemoryAccessMode"]);
                return;
            }

            CodeplugComms.startAddress   = 0x30000;
            CodeplugComms.transferLength = 0x20;
            result = commPrgForm.ShowDialog();
            Array.Copy(MainForm.CommsBuffer, 0x30000, DMRIDForm.DMRIDBuffer, 0, 0x20);


            int numRecords = BitConverter.ToInt32(DMRIDForm.DMRIDBuffer, 8);

            CodeplugComms.startAddress   = 0x30000;
            CodeplugComms.transferLength = Math.Min(0x20000, 12 + (numRecords + 2) * 12);

            CodeplugComms.CommunicationMode = CodeplugComms.CommunicationType.dataRead;
            result = commPrgForm.ShowDialog();
            Array.Copy(MainForm.CommsBuffer, 0x30000, DMRIDForm.DMRIDBuffer, 0, CodeplugComms.transferLength);
            radioToData();
            rebindData();
            //DataToCodeplug();
        }
Exemplo n.º 6
0
        private void btnWrite_Click(object sender, EventArgs e)
        {
            //bool retVal;

            /*	if (DialogResult.Yes != MessageBox.Show("Writing the calibration data to Radioddity GD-77 or any other compatible radio, could potentially damage your radio. By clicking 'Yes' you acknowledge that you use this feature entirely at your own risk", "WARNING", MessageBoxButtons.YesNo, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button2))
             *      {
             *              return;
             *      }
             */
            String gd77CommPort = SetupDiWrap.ComPortNameFromFriendlyNamePrefix("OpenGD77");

            if (gd77CommPort != null)
            {
                OpenGD77CommsTransferData dataObj = new OpenGD77CommsTransferData(OpenGD77CommsTransferData.CommsAction.NONE);
                dataObj.dataBuff = new Byte[CALIBRATION_DATA_SIZE];

                _port             = new SerialPort(gd77CommPort, 115200, Parity.None, 8, StopBits.One);
                _port.ReadTimeout = 1000;



                int calibrationDataSize = Marshal.SizeOf(typeof(CalibrationData));

                byte[] array = DataToByte(this.calibrationBandControlUHF.data);
                Array.Copy(array, 0, dataObj.dataBuff, 0, calibrationDataSize);

                array = DataToByte(this.calibrationBandControlVHF.data);
                Array.Copy(array, 0, dataObj.dataBuff, VHF_OFFSET, calibrationDataSize);



                _port.Open();
                sendCommand(0);
                sendCommand(1);
                sendCommand(2, 0, 0, 3, 1, 0, "CPS");
                sendCommand(2, 0, 16, 3, 1, 0, "Restoring");
                sendCommand(2, 0, 32, 3, 1, 0, "Calibration");
                sendCommand(3);
                sendCommand(6, 4);                // flash red LED

                dataObj.mode = OpenGD77CommsTransferData.CommsDataMode.DataModeWriteFlash;

                dataObj.localDataBufferStartPosition = 0;
                dataObj.startDataAddressInTheRadio   = MEMORY_LOCATION;
                dataObj.transferLength = CALIBRATION_DATA_SIZE;
                //displayMessage("Restoring Flash");
                if (WriteFlash(dataObj))
                {
                    //displayMessage("Restore complete");
                }
                else
                {
                    MessageBox.Show("Error while restoring");
                    //displayMessage("Error while restoring");
                    dataObj.responseCode = 1;
                }
                sendCommand(6, 2);                // Save settings and VFO's
                sendCommand(6, 1);                // Reboot
                _port.Close();
                lblMessage.Text = "Calibration update completed";
                //MessageBox.Show("Calibration update completed");
            }
            else
            {
                // Pre-read to see if the Calibration area appears to be writable
                CodeplugComms.CommunicationMode = CodeplugComms.CommunicationType.dataRead;
                CommPrgForm commPrgForm = new CommPrgForm(true);                // true =  close download form as soon as download is complete
                commPrgForm.StartPosition    = FormStartPosition.CenterParent;
                CodeplugComms.startAddress   = CALIBRATION_MEMORY_LOCATION_OFFICIAL_USB_PROTOCOL;
                CodeplugComms.transferLength = 0x20;
                DialogResult result = commPrgForm.ShowDialog();

                int calibrationDataSize = Marshal.SizeOf(typeof(CalibrationData));

                byte[] array = DataToByte(this.calibrationBandControlUHF.data);
                Array.Copy(array, 0, MainForm.CommsBuffer, CALIBRATION_MEMORY_LOCATION_OFFICIAL_USB_PROTOCOL, calibrationDataSize);

                array = DataToByte(this.calibrationBandControlVHF.data);
                Array.Copy(array, 0, MainForm.CommsBuffer, CALIBRATION_MEMORY_LOCATION_OFFICIAL_USB_PROTOCOL + VHF_OFFSET, calibrationDataSize);

                CodeplugComms.CommunicationMode = CodeplugComms.CommunicationType.calibrationWrite;

                commPrgForm = new CommPrgForm(true);                // true =  close download form as soon as download is complete
                commPrgForm.StartPosition = FormStartPosition.CenterParent;
                commPrgForm.ShowDialog();
                MessageBox.Show("Calibration update completed");
            }
        }
Exemplo n.º 7
0
        public bool readDataFromRadio()
        {
            bool         retVal = true;
            DialogResult result = DialogResult.OK;

            lblMessage.Text = "";

            int calibrationDataSize = Marshal.SizeOf(typeof(CalibrationData));

            byte[] array = new byte[calibrationDataSize];

            String gd77CommPort = SetupDiWrap.ComPortNameFromFriendlyNamePrefix("OpenGD77");

            if (gd77CommPort != null)
            {
                _port             = new SerialPort(gd77CommPort, 115200, Parity.None, 8, StopBits.One);
                _port.ReadTimeout = 1000;

                OpenGD77CommsTransferData dataObj = new OpenGD77CommsTransferData(OpenGD77CommsTransferData.CommsAction.NONE);

                _port.Open();
                sendCommand(0);
                sendCommand(1);
                sendCommand(2, 0, 0, 3, 1, 0, "CPS");                // Write a line of text to CPS screen at position x=0,y=3 with font size 3, alignment centre
                sendCommand(2, 0, 16, 3, 1, 0, "Backup");
                sendCommand(2, 0, 32, 3, 1, 0, "Calibration");
                sendCommand(3);
                sendCommand(6, 3);                // flash green LED

                dataObj.mode     = OpenGD77CommsTransferData.CommsDataMode.DataModeReadFlash;
                dataObj.dataBuff = new Byte[CALIBRATION_DATA_SIZE];
                dataObj.localDataBufferStartPosition = 0;
                dataObj.startDataAddressInTheRadio   = MEMORY_LOCATION;
                dataObj.transferLength = CALIBRATION_DATA_SIZE;
                //displayMessage("Reading Calibration");
                if (!ReadFlashOrEEPROM(dataObj))
                {
                    //displayMessage("Error while reading calibration");
                    result = DialogResult.Abort;
                    retVal = false;
                    dataObj.responseCode = 1;
                }
                else
                {
                    //displayMessage("");
                }
                sendCommand(5);                // close CPS screen
                _port.Close();



                for (int p = 0; p < CALIBRATION_HEADER_SIZE; p++)
                {
                    if (dataObj.dataBuff[p] != CALIBRATION_HEADER[p])
                    {
                        MessageBox.Show("Calibration data could not be found. Please update your firmware");
                        return(false);
                    }
                }

                Array.Copy(dataObj.dataBuff, 0, array, 0, calibrationDataSize);
                this.calibrationBandControlUHF.data = (CalibrationData)ByteToData(array);

                array = new byte[calibrationDataSize];
                Array.Copy(dataObj.dataBuff, 0 + VHF_OFFSET, array, 0, calibrationDataSize);
                this.calibrationBandControlVHF.data = (CalibrationData)ByteToData(array);
            }
            else
            {
                CommPrgForm commPrgForm;
                MainForm.CommsBuffer = new byte[1024 * 1024];

                // Pre-read to see if the calibration area appears to be readable.
                CodeplugComms.CommunicationMode = CodeplugComms.CommunicationType.dataRead;
                commPrgForm = new CommPrgForm(true);                // true =  close download form as soon as download is complete
                commPrgForm.StartPosition    = FormStartPosition.CenterParent;
                CodeplugComms.startAddress   = CalibrationForm.CALIBRATION_MEMORY_LOCATION_OFFICIAL_USB_PROTOCOL;
                CodeplugComms.transferLength = 0x20;
                result = commPrgForm.ShowDialog();

                CodeplugComms.CommunicationMode = CodeplugComms.CommunicationType.calibrationRead;
                commPrgForm = new CommPrgForm(true);                // true =  close download form as soon as download is complete
                commPrgForm.StartPosition = FormStartPosition.CenterParent;
                result = commPrgForm.ShowDialog();

                if (DialogResult.OK == result)
                {
                    // Need to setup the VHF and UHF data storage class first, as its used when initialising the components

                    Array.Copy(MainForm.CommsBuffer, CALIBRATION_MEMORY_LOCATION_OFFICIAL_USB_PROTOCOL, array, 0, calibrationDataSize);
                    this.calibrationBandControlUHF.data = (CalibrationData)ByteToData(array);

                    array = new byte[calibrationDataSize];
                    Array.Copy(MainForm.CommsBuffer, CALIBRATION_MEMORY_LOCATION_OFFICIAL_USB_PROTOCOL + VHF_OFFSET, array, 0, calibrationDataSize);
                    this.calibrationBandControlVHF.data = (CalibrationData)ByteToData(array);
                }
                else
                {
                    lblMessage.Text = "Error";
                    retVal          = false;
                }
            }

            return(retVal);
        }