Пример #1
0
        private void queryDeviceComponentInfo(DeviceDescriptor deviceInfo, DeviceHandle handle)
        {
            if ((deviceInfo.DeviceComponentMask != 0) && (deviceInfo.DeviceType.TypeID == DeviceTypeID.UDP001))
            {
                EzDCP2 zdcp = new EzDCP2(handle);
                for (int i = 0; i < 8; i++)
                {
                    DeviceDescriptor descriptor;
                    byte[] buffer;
                    if ((deviceInfo.DeviceComponentMask & (((int) 1) << i)) != 0)
                    {
                        buffer = new byte[1];
                        switch (i)
                        {
                            case 0:
                                try
                                {
                                    descriptor = new DeviceDescriptor();
                                    DataBuffer buffer2 = new DataBuffer();
                                    buffer = new byte[1];
                                    zdcp.exchangeMessagese(new byte[] { 0x80, 0x55, 5, 0x18, 0x25, 80, 0, 0x68 }, ref buffer, 0, true, true);
                                    buffer2.appendFromStartIdx(buffer, 0x25, 14);
                                    if (buffer2.BufToStr == "UPMP-F960-EMIF")
                                    {
                                        descriptor.DeviceType = new DeviceType(DeviceTypeID.F960_MCU_EMIF);
                                        descriptor.DeviceVersion = new DeviceVersion("0.2r");
                                    }
                                    else if (buffer2.BufToStr == "UPMP-F960-MLCD")
                                    {
                                        descriptor.DeviceType = new DeviceType(DeviceTypeID.F960_MCU_LCD);
                                        descriptor.DeviceVersion = new DeviceVersion("0.2r");
                                    }
                                    else
                                    {
                                        descriptor.DeviceType = new DeviceType(DeviceTypeID.Unknown);
                                        descriptor.DeviceVersion = new DeviceVersion("0.0r");
                                        descriptor.DeviceName = "Unknown MCU board";
                                    }
                                    deviceInfo.ComponentList.Add(descriptor);
                                }
                                catch (Exception exception)
                                {
                                    _log.Error("Could not process MCU board EBID information. " + exception.Message);
                                }
                                break;

                            case 1:
                                goto Label_0162;

                            case 2:
                                goto Label_039F;

                            case 4:
                                goto Label_0467;
                        }
                    }
                    continue;
                Label_0162:
                    try
                    {
                        descriptor = new DeviceDescriptor();
                        DataBuffer buffer3 = new DataBuffer();
                        DataBuffer buffer4 = new DataBuffer();
                        buffer = new byte[1];
                        zdcp.exchangeMessagese(new byte[] { 0x80, 0x55, 5, 0x18, 0x25, 0x51, 1, 0x68 }, ref buffer, 0, true, true);
                        buffer3.appendFromStartIdx(buffer, 0x23, 4);
                        buffer4.appendFromStartIdx(buffer, 0x21, 6);
                        if (buffer3.BufToStr == "F960")
                        {
                            descriptor.DeviceType = new DeviceType(DeviceTypeID.PICO_F960);
                            descriptor.DeviceVersion = new DeviceVersion("0.2r");
                        }
                        else if (buffer4.BufToStr.StartsWith("Si10"))
                        {
                            descriptor.DeviceType = new DeviceType(DeviceTypeID.PICO_Si10xx);
                            descriptor.DeviceVersion = new DeviceVersion("0.2r");
                            if (buffer4.BufToStr.Contains("Si") && (deviceInfo.PnPEBID == null))
                            {
                                deviceInfo.PnPEBID = new CDTRecord();
                                deviceInfo.PnPEBID.ChipType = buffer4.BufToStr;
                                deviceInfo.PnPEBID.ChipRevision = "B2";
                            }
                        }
                        else
                        {
                            descriptor.DeviceType = new DeviceType(DeviceTypeID.Unknown);
                            descriptor.DeviceVersion = new DeviceVersion("0.0r");
                            descriptor.DeviceName = "Unknown PICO board";
                        }
                        if (descriptor.DeviceType.TypeID != DeviceTypeID.Unknown)
                        {
                            DataBuffer buffer5 = new DataBuffer();
                            buffer = new byte[1];
                            zdcp.exchangeMessagese(new byte[] { 0x80, 0x55, 3, 0x1c, 1, 30 }, ref buffer, 0, false, true);
                            if (buffer.Length > 0x1a)
                            {
                                buffer5.appendFromStartIdx(buffer, 6, 0x13);
                                if (buffer5.BufToStr.Substring(11, 2) == "L0")
                                {
                                    descriptor.FirmwareType = new FirmwareType(buffer5.BufToStr.Substring(11, 3));
                                    descriptor.FirmwareVersion = new FirmwareVersion(buffer5.BufToStr.Substring(14, 5));
                                }
                                else
                                {
                                    descriptor.FirmwareType = new FirmwareType("Unknown");
                                    descriptor.FirmwareVersion = new FirmwareVersion("Unknown");
                                }
                            }
                            else
                            {
                                descriptor.FirmwareType = new FirmwareType("Unknown");
                                descriptor.FirmwareVersion = new FirmwareVersion("Unknown");
                            }
                        }
                        deviceInfo.ComponentList.Add(descriptor);
                    }
                    catch (Exception exception2)
                    {
                        _log.Error("Could not process PICO Board EBID information. " + exception2.Message);
                    }
                    continue;
                Label_039F:
                    try
                    {
                        descriptor = new DeviceDescriptor();
                        DataBuffer buffer6 = new DataBuffer();
                        buffer = new byte[1];
                        zdcp.exchangeMessagese(new byte[] { 0x80, 0x55, 5, 0x18, 0x25, 0x53, 0, 0x6b }, ref buffer, 0, true, true);
                        buffer6.appendFromStartIdx(buffer, 0x27, 8);
                        if (buffer6.BufToStr == "UPIO-LCD")
                        {
                            descriptor.DeviceType = new DeviceType(DeviceTypeID.IO_LCD);
                            descriptor.DeviceVersion = new DeviceVersion("0.2r");
                        }
                        else
                        {
                            descriptor.DeviceType = new DeviceType(DeviceTypeID.Unknown);
                            descriptor.DeviceVersion = new DeviceVersion("0.0r");
                            descriptor.DeviceName = "Unknown IO board";
                        }
                        deviceInfo.ComponentList.Add(descriptor);
                    }
                    catch (Exception exception3)
                    {
                        _log.Error("Could not process I/O board EBID information. " + exception3.Message);
                    }
                    continue;
                Label_0467:
                    try
                    {
                        descriptor = new DeviceDescriptor();
                        DataBuffer buffer7 = new DataBuffer();
                        DataBuffer buffer8 = new DataBuffer();
                        buffer = new byte[1];
                        zdcp.exchangeMessagese(new byte[] { 0x80, 0x55, 4, 0x18, 0x31, 1, 0x2c }, ref buffer, 0, true, true);
                        buffer = new byte[1];
                        zdcp.exchangeMessagese(new byte[] { 0x80, 0x55, 5, 0x18, 0x25, 0x52, 0, 0x6a }, ref buffer, 0, true, true);
                        buffer7.appendFromStartIdx(buffer, 0x19, 6);
                        buffer8.appendFromStartIdx(buffer, 0x21, 2);
                        string str = buffer7.BufToStr.Replace("SI", "Si");
                        if (str.Contains("Si"))
                        {
                            if (str.StartsWith("Si446"))
                            {
                                zdcp.exchangeMessagese(new byte[] { 0x80, 0x55, 7, 0x1c, 0x10, 0, 0, 1, 0, 10 }, ref buffer, 0, true, true);
                                zdcp.exchangeMessagese(new byte[] {
                                    0x80, 0x55, 0x10, 0x1c, 0x10, 0, 0, 0x44, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
                                    0xff, 0xff, 0x58
                                 }, ref buffer, 0, true, true);
                                if (buffer[0x10] == 3)
                                {
                                    buffer8 = new DataBuffer(2);
                                    buffer8.append(new byte[] { 0x42, 0x31 }, 2);
                                }
                            }
                            if (deviceInfo.PnPEBID == null)
                            {
                                deviceInfo.PnPEBID = new CDTRecord();
                                deviceInfo.PnPEBID.ChipType = str;
                                deviceInfo.PnPEBID.ChipRevision = buffer8.BufToStr;
                            }
                            descriptor.DeviceType = new DeviceType(DeviceTypeID.Radio);
                            descriptor.DeviceVersion = new DeviceVersion(buffer8.BufToStr);
                            descriptor.DeviceName = str;
                        }
                        else
                        {
                            descriptor.DeviceType = new DeviceType(DeviceTypeID.Unknown);
                            descriptor.DeviceVersion = new DeviceVersion("0.0r");
                            descriptor.DeviceName = "Unknown Radion card";
                        }
                        deviceInfo.ComponentList.Add(descriptor);
                    }
                    catch (Exception exception4)
                    {
                        _log.Error("Could not process Radio EBID information. " + exception4.Message);
                    }
                }
                zdcp.initiateIcommand();
            }
        }
Пример #2
0
        private FDResult WriteFirmwareToDevice(ArrayList firmware, UpdateFirmwareCallback callback, ushort vid, ushort pid, string serial, string hexFileName)
        {
            BootloadStatus fail = BootloadStatus.Fail;
            int num = 0;
            int num2 = 0;
            m_hidApp = _adtRecord.PortAddress.handle;
            if (((m_hidApp.HIDhnd.hnd.IsOpened() != 0) || m_hidApp.HIDhnd.hnd.Connect(vid, pid, serial, 0x7d0, 0x7d0)) &&
                ((fail = LoadHexFile(hexFileName)) == BootloadStatus.Success))
            {
                bool[] flashPageModified = m_flashPageModified;
                for (int i = 0; i < flashPageModified.Length; i++)
                    if (flashPageModified[i])
                        num++;

                EzDCP2 zdcp = new EzDCP2(m_hidApp);
                fail = zdcp.initiateIcommand() ? BootloadStatus.Success : BootloadStatus.Fail;
                byte[] rxDara = new byte[1];
                callback(0, false, "", MessageBoxButtons.OK);
                fail = zdcp.exchangeMessagese(new byte[] { 0x80, 0x55, 4, 0x18, 0x2a, 0, 0x36 }, ref rxDara, 0x9c4, true, false) ? BootloadStatus.Success : BootloadStatus.Fail;
                if (fail != BootloadStatus.Success)
                    return FDResult.Error;

                for (int j = 0; j < m_flashPageModified.Length; j++)
                {
                    if (m_flashPageModified[j])
                    {
                        ushort num6;
                        ushort sourceIndex = (ushort)(j * 512);
                        for (ushort k = 0; k < 512; k = (ushort)(k + num6))
                        {
                            num6 = (ushort)(512 - k);
                            num6 = Math.Min(num6, (ushort)32);
                            byte[] destinationArray = new byte[num6];
                            Array.Copy(m_flashMemory, sourceIndex, destinationArray, 0, num6);
                            fail = zdcp.exchangeMessagese(zdcp.createDCP2Commands(destinationArray, sourceIndex), ref rxDara, 0, true, false) ? BootloadStatus.Success : BootloadStatus.Fail;
                            if (fail != BootloadStatus.Success)
                                return FDResult.Error;

                            sourceIndex = (ushort)(sourceIndex + num6);
                        }
                        num2++;
                        if (num > 0)
                        {
                            int percentageComplete = (num2 * 100) / num;
                            callback(percentageComplete, false, "", MessageBoxButtons.OK);
                        }
                        if (fail != BootloadStatus.Success)
                            return FDResult.Error;
                    }
                }
                fail = zdcp.exchangeMessagese(new byte[] { 0x80, 0x55, 4, 0x18, 0x29, 0, 0x35 }, ref rxDara, 0, true, false) ? BootloadStatus.Success : BootloadStatus.Fail;
                zdcp.initiateIcommand();
            }
            Thread.Sleep(500);
            return FDResult.OK;
        }
Пример #3
0
 private DeviceDescriptor queryDeviceInfo(DeviceHandle dh)
 {
     try
     {
         DeviceDescriptor descriptor = queryDeviceInfo_EBID(dh);
         if ((descriptor.DeviceType != null) && ((descriptor.DeviceType.TypeID == DeviceTypeID.LCDBB_F930) || (descriptor.DeviceType.TypeID == DeviceTypeID.WIMB930)))
         {
             Thread.Sleep(0x3e8);
             EzDCP2 zdcp = new EzDCP2(dh);
             DataBuffer buf = new DataBuffer();
             byte[] rxDara = new byte[1];
             zdcp.exchangeMessagese(new byte[] { 0x55, 3, 0, 1, 2 }, ref rxDara, 0, true, false);
             buf.append(rxDara, rxDara.Length);
             if (((buf.NumItems < 4) || (buf.Buf[0] != 0x55)) || (buf.NumItems < buf.Buf[1]))
             {
                 return descriptor;
             }
             DataBuffer buffer3 = new DataBuffer();
             buffer3.appendFromStartIdx(buf, 4, 7);
             if ((buffer3.BufToStr == "LCDBB93") || (buffer3.BufToStr == "WIMB930"))
             {
                 buffer3 = new DataBuffer();
                 buffer3.appendFromStartIdx(buf, 0x10, 3);
                 descriptor.FirmwareType = new FirmwareType(buffer3.BufToStr);
                 buffer3 = new DataBuffer();
                 buffer3.appendFromStartIdx(buf, 0x13, 5);
                 descriptor.FirmwareVersion = new FirmwareVersion(buffer3.BufToStr);
             }
         }
         return descriptor;
     }
     catch (Exception exception)
     {
         _log.Error("Device info query problem: " + exception.Message);
         return null;
     }
 }