示例#1
0
文件: DDI_HID.cs 项目: x893/WDS
        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
文件: DDI_TOOLSTICK.cs 项目: x893/WDS
 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;
     }
 }
示例#3
0
文件: DDI_HID.cs 项目: x893/WDS
 public int readAppend(DeviceHandle handle, DataBuffer data, int bytesToRead)
 {
     if (handle.HIDhnd.hnd == null)
     {
         return 0;
     }
     if (handle.HIDhnd.hnd.ReceiveBuffer.NumItems > 0)
     {
         if (bytesToRead <= handle.HIDhnd.hnd.ReceiveBuffer.NumItems)
         {
             data.append(handle.HIDhnd.hnd.ReceiveBuffer.Buf, bytesToRead);
             handle.HIDhnd.hnd.ReceiveBuffer.removeHeadBytes(bytesToRead);
             return bytesToRead;
         }
         int numItems = handle.HIDhnd.hnd.ReceiveBuffer.NumItems;
         data.append(handle.HIDhnd.hnd.ReceiveBuffer.Buf, numItems);
         handle.HIDhnd.hnd.ReceiveBuffer.removeHeadBytes(numItems);
         handle.HIDhnd.hnd.ReceiveBuffer.NumItems = 0;
         return numItems;
     }
     int num2 = this.readDevice(handle, handle.HIDhnd.hnd.ReceiveBuffer);
     if (num2 < 0)
     {
         return -1;
     }
     if (num2 == 0)
     {
         return 0;
     }
     return this.readAppend(handle, data, bytesToRead);
 }
示例#4
0
文件: DDI_TOOLSTICK.cs 项目: x893/WDS
 public int readAppend(DeviceHandle handle, DataBuffer data, int bytesToRead)
 {
     if (handle.TOOLSTICKhnd.hnd == null)
     {
         return 0;
     }
     if (bytesToRead == 0)
     {
         return 0;
     }
     if (handle.TOOLSTICKhnd.hnd.ReceiveBuffer.NumItems > 0)
     {
         if (bytesToRead <= handle.TOOLSTICKhnd.hnd.ReceiveBuffer.NumItems)
         {
             data.append(handle.TOOLSTICKhnd.hnd.ReceiveBuffer.Buf, bytesToRead);
             handle.TOOLSTICKhnd.hnd.ReceiveBuffer.removeHeadBytes(bytesToRead);
             return bytesToRead;
         }
         int numItems = handle.TOOLSTICKhnd.hnd.ReceiveBuffer.NumItems;
         data.append(handle.TOOLSTICKhnd.hnd.ReceiveBuffer.Buf, numItems);
         handle.TOOLSTICKhnd.hnd.ReceiveBuffer.removeHeadBytes(numItems);
         handle.TOOLSTICKhnd.hnd.ReceiveBuffer.NumItems = 0;
         return numItems;
     }
     uint bytesRead = 0;
     byte num3 = handle.TOOLSTICKhnd.hnd.Read(handle.TOOLSTICKhnd.hnd.ReceiveBuffer.Buf, (uint) bytesToRead, ref bytesRead);
     handle.TOOLSTICKhnd.hnd.ReceiveBuffer.NumItems = (int) bytesRead;
     if (num3 == 9)
     {
         return 0;
     }
     if (num3 != 0)
     {
         return -1;
     }
     return readAppend(handle, data, bytesToRead);
 }