Ejemplo n.º 1
0
Archivo: DCPFrame.cs Proyecto: x893/WDS
 public DCPRetCodes CopyDCPmsgToDataBuffer(DataBuffer DataToSend)
 {
     if (DataToSend != null)
     {
         int num = 0;
         DataToSend.NumItems = 3;
         DataToSend[num++] = this._DCPSOFByte;
         DataToSend[num++] = this.Len;
         DataToSend[num++] = this.Ctrl;
         DataToSend.appendFromStartIdx(this.Data, 0, this.Len - 2);
         num += this.Len - 2;
         DataToSend.NumItems++;
         DataToSend[num] = this.EDC;
         DataToSend.DType = Data_Type.Binary;
         return DCPRetCodes.DCP_OK;
     }
     return DCPRetCodes.DCP_FATAL;
 }
Ejemplo n.º 2
0
Archivo: DDI_TEST.cs Proyecto: x893/WDS
 public int readAppend(DeviceHandle handle, DataBuffer data, int len)
 {
     if (handle == null)
     {
         return -1;
     }
     if (handle.isInvalid())
     {
         GlobalServices.ErrMsg("DDI_TEST.readAppend()", "called with INVALID handle");
         return -1;
     }
     int num = data.appendFromStartIdx(handle.TestDevHnd.readBuff, handle.TestDevHnd.readBuffIdx, len);
     TestDeviceHandle testDevHnd = handle.TestDevHnd;
     testDevHnd.readBuffIdx += num;
     if (handle.TestDevHnd.readBuffIdx == handle.TestDevHnd.readBuff.NumItems)
     {
         handle.TestDevHnd.readBuffIdx = 0;
         handle.TestDevHnd.readBuff.NumItems = 0;
     }
     return num;
 }
Ejemplo n.º 3
0
Archivo: DDI_HID.cs Proyecto: 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();
            }
        }
Ejemplo n.º 4
0
 private DeviceDescriptor queryDeviceInfo_EBID(DeviceHandle dh)
 {
     DeviceDescriptor descriptor = new DeviceDescriptor();
     DeviceDescriptor item = new DeviceDescriptor();
     try
     {
         byte[] destinationArray = new byte[0x100];
         byte[] ptrMem = new byte[0x100];
         byte[] buffer3 = new byte[0x100];
         DataBuffer buffer4 = new DataBuffer();
         DataBuffer buffer5 = new DataBuffer();
         DataBuffer buffer6 = new DataBuffer();
         DataBuffer buffer7 = new DataBuffer();
         DataBuffer buffer8 = new DataBuffer();
         DataBuffer buffer9 = new DataBuffer();
         DataBuffer buffer10 = new DataBuffer();
         int deviceName = 0;
         _disableDecivePortActiveCheck = true;
         dh.TOOLSTICKhnd.hnd.Close();
         deviceName = ToolStickDebugUtil.ConnectUSB(new StringBuilder(dh.TOOLSTICKhnd.hnd.ADT.PortAddress.toolstickAddr.Serial), 1, 1, 0);
         if (deviceName != 0)
         {
             throw new Exception("Could not connect to the " + dh.TOOLSTICKhnd.hnd.ADT.PortAddress.toolstickAddr.Serial + " device! Error code: " + deviceName.ToString("X2"));
         }
         deviceName = ToolStickDebugUtil.SetPinMode(2, 2, 0);
         if (deviceName != 0)
         {
             throw new Exception("Could not set Pin mode: " + deviceName.ToString("X2"));
         }
         deviceName = ToolStickDebugUtil.SetPinLatch(7, 7);
         if (deviceName != 0)
         {
             throw new Exception("Could not Set Pin Latch: " + deviceName.ToString("X2"));
         }
         deviceName = ToolStickDebugUtil.SetMultiConnectMode(1);
         if (deviceName != 0)
         {
             throw new Exception("Could not Set Multi Connect Mode 1: " + deviceName.ToString("X2"));
         }
         _isMultiConnectModeOn = true;
         deviceName = ToolStickDebugUtil.ConnectUSB(new StringBuilder(dh.TOOLSTICKhnd.hnd.ADT.PortAddress.toolstickAddr.Serial), 1, 1, 0);
         if (deviceName != 0)
         {
             throw new Exception("Could not connect to the " + dh.TOOLSTICKhnd.hnd.ADT.PortAddress.toolstickAddr.Serial + " device! Error code: " + deviceName.ToString("X2"));
         }
         deviceName = ToolStickDebugUtil.GetCodeMemory(ptrMem, 0xc00, (uint) ptrMem.Length);
         if (deviceName != 0)
         {
             throw new Exception("Could not read EBID Code memory! RetCode: " + deviceName.ToString("X2"));
         }
         if (((ptrMem[0] != 1) || (ptrMem[1] != 0)) || (ptrMem[2] != 1))
         {
             StringBuilder psDeviceName = new StringBuilder();
             deviceName = ToolStickDebugUtil.GetDeviceName(ref psDeviceName);
             if (deviceName != 0)
             {
                 throw new Exception("Could not read device name! RetCode: " + deviceName.ToString("X2"));
             }
             if ((psDeviceName.ToString() == "C8051F983") && (_ebidFixRetryCnt < 2))
             {
                 _ebidFixRetryCnt++;
                 deviceName = ToolStickDebugUtil.Download(new StringBuilder(@"WDS_Resources\files\4x55_LED_xxx_MCU_EBID.hex"), 1, 1, 0, -1, 0, false);
                 if (deviceName != 0)
                 {
                     throw new Exception("Could not Download EBID fixing code! RetCode: " + deviceName.ToString("X2"));
                 }
                 deviceName = ToolStickDebugUtil.SetTargetGo();
                 if (deviceName != 0)
                 {
                     throw new Exception("Could not start the EBID MCU after fixing! RetCode: " + deviceName.ToString("X2"));
                 }
                 Thread.Sleep(250);
                 deviceName = ToolStickDebugUtil.SetPinLatch(0, 7);
                 if (deviceName != 0)
                 {
                     throw new Exception("Could not Set Pin Latch after fixing EBID MCU! RetCode: " + deviceName.ToString("X2"));
                 }
                 deviceName = ToolStickDebugUtil.SetMultiConnectMode(0);
                 if (deviceName != 0)
                 {
                     throw new Exception("Could not Set Multi Connect Mode 0 after fixing EBID MCU. RetCode: " + deviceName.ToString("X2"));
                 }
                 _isMultiConnectModeOn = false;
                 deviceName = ToolStickDebugUtil.DisconnectUSB();
                 if (deviceName != 0)
                 {
                     throw new Exception("Could not Disconnect the device after fixing EBID MCU! RetCode: " + deviceName.ToString("X2"));
                 }
                 return queryDeviceInfo_EBID(dh);
             }
             deviceName = ToolStickDebugUtil.GetCodeMemory(ptrMem, 0x1800, (uint) ptrMem.Length);
             if (deviceName != 0)
             {
                 throw new Exception("Could not read EBID Code memory! RetCode: " + deviceName.ToString("X2"));
             }
         }
         deviceName = ToolStickDebugUtil.GetXRAMMemory(buffer3, 0, (uint) buffer3.Length);
         if (deviceName != 0)
         {
             throw new Exception("Could not read Radio EBID Code memory(XRAM)! RetCode: " + deviceName.ToString("X2"));
         }
         Array.Reverse(buffer3, 0, buffer3.Length);
         Array.ConstrainedCopy(buffer3, 0x80, destinationArray, 0, 0x80);
         try
         {
             EBID_Data data = new EBID_Data(ptrMem);
             EBID_Data data2 = new EBID_Data(buffer3);
             descriptor.boardEbidData = data;
             descriptor.frEbidData = data2;
         }
         catch (Exception exception)
         {
             _log.Error("Could not create EBID object. " + exception.Message);
         }
         buffer4.appendFromStartIdx(ptrMem, 30, 8);
         buffer5.appendFromStartIdx(ptrMem, 0x22, 8);
         buffer6.appendFromStartIdx(ptrMem, 0x20, 10);
         if (buffer4.BufToStr == "4x55-LED")
         {
             descriptor.DeviceType = new DeviceType(DeviceTypeID.ToolStick);
             descriptor.DeviceVersion = new DeviceVersion("1.0r");
             descriptor.FirmwareType = new FirmwareType("TSF");
             descriptor.FirmwareVersion = new FirmwareVersion("1.0b");
             descriptor.DeviceComponentMask = (byte) (descriptor.DeviceComponentMask | 1);
             descriptor.DevicePhoto = RFStick.RFStickWToolStick;
             descriptor.MarketingName = ToolStick.MarketingName;
             descriptor.PartNumber = ToolStick.PartNumber;
             descriptor.UnAssignedDeviceText = ToolStick.UnAssignedDeviceText;
             descriptor.WarningText = ToolStick.WarningText;
             descriptor.DeviceName = ToolStick.McuInfo;
             item = new DeviceDescriptor {
                 DeviceType = new DeviceType(DeviceTypeID.RFSTICK_F930)
             };
             buffer8.appendFromStartIdx(ptrMem, 20, 3);
             item.DeviceVersion = new DeviceVersion(buffer8.BufToStr + "r");
             item.FirmwareType = new FirmwareType("Unknown");
             item.FirmwareVersion = new FirmwareVersion("Unknown");
             descriptor.ComponentList.Add(item);
         }
         else if (buffer5.BufToStr == "LCDBB930")
         {
             descriptor.DeviceType = new DeviceType(DeviceTypeID.LCDBB_F930);
             descriptor.DeviceVersion = new DeviceVersion("1.1r");
             descriptor.FirmwareType = new FirmwareType("Unknown");
             descriptor.FirmwareVersion = new FirmwareVersion("Unknown");
             descriptor.DevicePhoto = LCDBaseBoard.LCDBB_F930;
             descriptor.MarketingName = LCDBaseBoard.MarketingName;
             descriptor.PartNumber = LCDBaseBoard.PartNumber;
             descriptor.UnAssignedDeviceText = LCDBaseBoard.UnAssignedDeviceText;
             descriptor.WarningText = LCDBaseBoard.WarningText;
             descriptor.DeviceName = LCDBaseBoard.McuInfo;
         }
         else if (buffer6.BufToStr == "MSC-WMB930")
         {
             descriptor.DeviceType = new DeviceType(DeviceTypeID.WIMB930);
             descriptor.DeviceVersion = new DeviceVersion("1.0r");
             descriptor.FirmwareType = new FirmwareType("Unknown");
             descriptor.FirmwareVersion = new FirmwareVersion("Unknown");
             descriptor.DevicePhoto = WirelessMotherboard8.WIMB930;
             descriptor.MarketingName = WirelessMotherboard8.MarketingName;
             descriptor.PartNumber = WirelessMotherboard8.PartNumber;
             descriptor.UnAssignedDeviceText = WirelessMotherboard8.UnAssignedDeviceText;
             descriptor.WarningText = WirelessMotherboard8.WarningText;
             descriptor.DeviceName = WirelessMotherboard8.McuInfo;
         }
         item = new DeviceDescriptor();
         byte num2 = 0;
         if (((buffer3[0x10] != 0x53) || (buffer3[0x11] != 0x49)) && ((buffer3[0x10] != 0x53) || (buffer3[0x11] != 0x69)))
         {
             num2 = 0x30;
         }
         buffer9.appendFromStartIdx(buffer3, 0x10 + num2, 6);
         buffer10.appendFromStartIdx(buffer3, 0x18 + num2, 2);
         if (buffer9.BufToStr.ToUpper().StartsWith("SI"))
         {
             try
             {
                 item.DeviceType = new DeviceType((DeviceTypeID) Enum.Parse(typeof(DeviceTypeID), "Radio_" + buffer9.BufToStr.Replace('I', 'i')));
                 item.DeviceName = buffer9.BufToStr;
             }
             catch
             {
                 item.DeviceType = new DeviceType(DeviceTypeID.Radio);
             }
             if (item.DeviceType.TypeID == DeviceTypeID.Radio_Si4012)
             {
                 item.DeviceVersion = new DeviceVersion("C2");
             }
             else
             {
                 item.DeviceVersion = new DeviceVersion(buffer10.BufToStr);
             }
             descriptor.ComponentList.Add(item);
             if (descriptor.PnPEBID == null)
             {
                 descriptor.PnPEBID = new CDTRecord();
                 descriptor.PnPEBID.ChipType = buffer9.BufToStr.Replace('I', 'i');
                 descriptor.PnPEBID.ChipRevision = item.DeviceVersion.Name.ToString();
             }
         }
         if (descriptor.DeviceType.TypeID == DeviceTypeID.WIMB930)
         {
             buffer7.appendFromStartIdx(destinationArray, 70, 9);
             if (buffer7.BufToStr == "C8051F930")
             {
                 item = new DeviceDescriptor {
                     DeviceType = new DeviceType(DeviceTypeID.PICO_F930),
                     DeviceVersion = new DeviceVersion("1.0r")
                 };
                 descriptor.ComponentList.Add(item);
             }
         }
         deviceName = ToolStickDebugUtil.SetPinLatch(0, 7);
         if (deviceName != 0)
         {
             throw new Exception("Could not Set Pin Latch: " + deviceName.ToString("X2"));
         }
         deviceName = ToolStickDebugUtil.ConnectUSB(new StringBuilder(dh.TOOLSTICKhnd.hnd.ADT.PortAddress.toolstickAddr.Serial), 1, 1, 0);
         if (deviceName != 0)
         {
             throw new Exception("Could not connect to the " + dh.TOOLSTICKhnd.hnd.ADT.PortAddress.toolstickAddr.Serial + " device! Error code: " + deviceName.ToString("X2"));
         }
         deviceName = ToolStickDebugUtil.SetTargetGo();
         if (deviceName != 0)
         {
             throw new Exception("Could not start the code! Error code = " + deviceName.ToString("X2"));
         }
         deviceName = ToolStickDebugUtil.SetMultiConnectMode(0);
         if (deviceName != 0)
         {
             throw new Exception("Could not Set Multi Connect Mode 0: " + deviceName.ToString("X2"));
         }
         _isMultiConnectModeOn = false;
         deviceName = ToolStickDebugUtil.DisconnectUSB();
         if (deviceName != 0)
         {
             throw new Exception("Could not disconnect the device! Error code = " + deviceName.ToString("X2"));
         }
         if (dh.TOOLSTICKhnd.hnd.ReOpen() != 0)
         {
             throw new Exception("Could not reopen the device with SLABToolStickDevice.dll");
         }
         if ((dh.TOOLSTICKhnd.hnd.IsUartEnabled() != 1) && (dh.TOOLSTICKhnd.hnd.EnableUart() != 0))
         {
             throw new Exception("Could not enable UART");
         }
         if (dh.TOOLSTICKhnd.hnd.SetTimeouts(20, 20) != 0)
         {
             throw new Exception("Could not set UART timeouts");
         }
         _disableDecivePortActiveCheck = false;
         return descriptor;
     }
     catch (Exception exception2)
     {
         _log.Error("Could not query device EBID content\n" + exception2.Message);
         if (_isMultiConnectModeOn)
         {
             ToolStickDebugUtil.SetMultiConnectMode(0);
         }
         ToolStickDebugUtil.DisconnectUSB();
         dh.TOOLSTICKhnd.hnd.Open(0);
         _disableDecivePortActiveCheck = false;
         return new DeviceDescriptor { DeviceType = new DeviceType(DeviceTypeID.Unknown), DeviceVersion = new DeviceVersion("Unknown"), FirmwareType = new FirmwareType("Unknown"), FirmwareVersion = new FirmwareVersion("Unknown") };
     }
 }
Ejemplo n.º 5
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;
     }
 }
Ejemplo n.º 6
0
Archivo: DDI_USB.cs Proyecto: x893/WDS
 public int readAppend(DeviceHandle handle, DataBuffer data, int len)
 {
     int bytesReturned = 0;
     byte[] readBuff = new byte[len];
     if (handle.isInvalid())
     {
         GlobalServices.ErrMsg("DDI_USB.readAppend()", "called with INVALID handle");
         return -1;
     }
     int readTimeoutMs = ((int) (len * 0.7)) + 20;
     if (FTDIWrapper.ReadWait(handle.USBhnd.hnd, readBuff, len, ref bytesReturned, readTimeoutMs) != 0)
     {
         GlobalServices.ErrMsg("DDI_USB.read()", "FTDIWrapper.Write() returned:" + FTDIWrapper.GetErrorString());
         return -1;
     }
     data.appendFromStartIdx(readBuff, 0, bytesReturned);
     return bytesReturned;
 }