Exemple #1
0
        private void buttonMultiApply_Click(object sender, EventArgs e)
        {
            byte byAddr, bySize;

            try
            {
                if (textBoxMultiAddress.Text.Length <= 0 || textBoxMultiAddress.Text.Length > 2 ||
                    textBoxMultiSize.Text.Length <= 0 || textBoxMultiSize.Text.Length > 2)
                {
                    throw new FormatException();
                }

                byAddr = Convert.ToByte(textBoxMultiAddress.Text, 16);
                bySize = Convert.ToByte(textBoxMultiSize.Text, 16);
            }
            catch
            {
                MessageBox.Show("Format incorrect. Hex?", "Warning");
                return;
            }

            if (bySize < 1 || bySize > EEPROM_API.PAGE_SIZE)
            {
                MessageBox.Show("Incorrect Input. The range of the input should be 1 to "
                                + EEPROM_API.PAGE_SIZE.ToString(), "Warning");
                return;
            }

            byte isReadWrite = 0;

            byte[] byDataArray = new byte[bySize];
            if (radioButtonReadMulti.Checked == true)
            {
                LastErrCode = EEPROM_API.ReadMultiByte(byAddr, bySize, byDataArray, out isReadWrite);
                if (LastErrCode != IMCAPIErrCode.IMC_ERR_NO_ERROR)
                {
                    MessageBox.Show("Fails to ReadMultiByte EERPOM " + LastErrCode.ToString("X4"));
                    return;
                }

                textBoxMultiData.Text = ConvertByte2HexString(byDataArray, isReadWrite);
            }
            else
            {
                if (textBoxMultiData.Text.Length != bySize * 2)
                {
                    MessageBox.Show("Incorrect Input. The data not match the size", "Warning");
                    return;
                }

                byDataArray = String2ByteArray(textBoxMultiData.Text);
                LastErrCode = EEPROM_API.WriteMultiByte(byAddr, bySize, byDataArray, out isReadWrite);
                if (LastErrCode != IMCAPIErrCode.IMC_ERR_NO_ERROR)
                {
                    MessageBox.Show("Fails to WriteMultiByte EERPOM " + LastErrCode.ToString("X4"));
                    return;
                }
            }
            textBoxMultiNumReadWrite.Text = isReadWrite.ToString("X2");
        }
Exemple #2
0
        private void EEPROM_Load(object sender, EventArgs e)
        {
            byte[] byLibVersion = new byte[EEPROM_API.IMC_LIB_VERSION_SIZE];
            LastErrCode = EEPROM_API.GetLibVersion(byLibVersion);
            if (LastErrCode != IMCAPIErrCode.IMC_ERR_NO_ERROR)
            {
                MessageBox.Show("Fails to get library version " + LastErrCode.ToString("X4"));
                return;
            }

            int nRealSize;

            textBoxLibVersion.Text = ConvertByte2String(byLibVersion, byLibVersion.Length, out nRealSize);

            LastErrCode = EEPROM_API.GetEEPROMSize(out ROMSize);
            if (LastErrCode != IMCAPIErrCode.IMC_ERR_NO_ERROR)
            {
                MessageBox.Show("Fails to get EERPOM size version " + LastErrCode.ToString("X4"));
                return;
            }
            textBoxEEPROMSize.Text = ROMSize.ToString();

            LastErrCode = EEPROM_API.Initialize();
            if (LastErrCode != IMCAPIErrCode.IMC_ERR_NO_ERROR)
            {
                MessageBox.Show("Fails to Initialize the EEPROM library" + LastErrCode.ToString("X4"));
                return;
            }
        }
Exemple #3
0
 private void EEPROM_FormClosed(object sender, FormClosedEventArgs e)
 {
     LastErrCode = EEPROM_API.Deinitialize();
     if (LastErrCode != IMCAPIErrCode.IMC_ERR_NO_ERROR)
     {
         MessageBox.Show("Fails to Deinitialize the EEPROM library" + LastErrCode.ToString("X4"));
         return;
     }
 }
Exemple #4
0
        private void buttonByteApply_Click(object sender, EventArgs e)
        {
            byte byAddr;

            try
            {
                if (textBoxByteAddress.Text.Length <= 0 || textBoxByteAddress.Text.Length > 2)
                {
                    throw new FormatException();
                }

                byAddr = Convert.ToByte(textBoxByteAddress.Text, 16);
            }
            catch
            {
                MessageBox.Show("Address format incorrect. Hex?", "Warning");
                return;
            }

            if (radioButtonReadByte.Checked == true)
            {
                byte byData;
                LastErrCode = EEPROM_API.ReadByte(byAddr, out byData);
                if (LastErrCode != IMCAPIErrCode.IMC_ERR_NO_ERROR)
                {
                    MessageBox.Show("Fails to ReadByte EERPOM " + LastErrCode.ToString("X4"));
                    return;
                }
                textBoxByteData.Text = byData.ToString("X2");
            }
            else
            {
                byte byData;

                try
                {
                    if (textBoxByteData.Text.Length <= 0 || textBoxByteData.Text.Length > 2)
                    {
                        throw new FormatException();
                    }
                    byData = Convert.ToByte(textBoxByteData.Text, 16);
                }
                catch
                {
                    MessageBox.Show("Format incorrect. Hex?", "Warning");
                    return;
                }

                LastErrCode = EEPROM_API.WriteByte(byAddr, byData);
                if (LastErrCode != IMCAPIErrCode.IMC_ERR_NO_ERROR)
                {
                    MessageBox.Show("Fails to WriteByte EERPOM " + LastErrCode.ToString("X4"));
                    return;
                }
            }
        }