Beispiel #1
0
        public byte[] WriteDriverSFP(int deviceIndex, int deviceAddress, int StartAddress, int regAddress, byte Length, byte chipset, int dataToWrite, bool LittleEndian)
        {
            lock (syncRoot)
            {
                byte[] ReturnArray = new byte[1];

                try
                {
                    byte[] WriteDacByteArray;

                    if (chipset == 4)
                    {
                        WriteDacByteArray = Algorithm.ObjectTOByteArray(dataToWrite, 2, LittleEndian);
                        EEPROM.ReadWriteDriverSFP(DUT.deviceIndex, deviceAddress, StartAddress, regAddress, 0x02, chipset, WriteDacByteArray);
                    }
                    else
                    {
                        WriteDacByteArray = Algorithm.ObjectTOByteArray(dataToWrite, Length, LittleEndian);

                        for (int i = Length - 1; i > -1; i--)
                        {
                            byte[] WriteData = Algorithm.ObjectTOByteArray(WriteDacByteArray[i], 2, LittleEndian);
                            EEPROM.ReadWriteDriverSFP(DUT.deviceIndex, deviceAddress, StartAddress, regAddress + i, 0x02, chipset, WriteData);
                        }
                    }
                    ReturnArray[0] = 0xAA;

                    return(ReturnArray);
                }
                catch
                {
                    return(ReturnArray);
                }
            }
        }
Beispiel #2
0
        public byte[] StoreDriverSFP_old(int deviceIndex, int deviceAddress, int StartAddress, int regAddress, int Length, byte chipset, byte[] dataToWrite)
        {
            lock (syncRoot)
            {
                byte[] ReturnArray = new byte[1];

                try
                {
                    for (int i = 0; i < Length; i++)
                    {
                        byte[] WriteDacByteArray = Algorithm.ObjectTOByteArray(dataToWrite[i], DriverStruct[i].Length, DriverStruct[i].Endianness);

                        EEPROM.ReadWriteDriverSFP(DUT.deviceIndex, deviceAddress, StartAddress, regAddress, 0x06, chipset, dataToWrite);
                    }
                    ReturnArray[0] = 0xAA;

                    return(ReturnArray);
                }
                catch
                {
                    return(ReturnArray);
                }
            }
            //  return EEPROM.ReadWriteDriverSFP(DUT.deviceIndex, deviceAddress, StartAddress, regAddress, 0x06, chipset, dataToWrite);
        }
Beispiel #3
0
        public int ReadDriverSFP(int deviceIndex, int deviceAddress, int StartAddress, int regAddress, byte Length, byte chipset)// 有问题,但是需要确认,默认写长度为2符合FW接口协议 Leo 2016-10-25
        {
            lock (syncRoot)
            {
                int[] ReturnArray = new int[Length];
                int   ReadData    = 0;
                try
                {
                    if (chipset == 4)
                    {
                        byte[] ReadArray = EEPROM.ReadWriteDriverSFP(DUT.deviceIndex, deviceAddress, StartAddress, regAddress, 0x01, chipset, new byte[2]);

                        ReadData = ReadArray[0] * 256 + ReadArray[1];
                    }
                    else
                    {
                        for (int i = 0; i < Length; i++)
                        {
                            byte[] ReadArray = EEPROM.ReadWriteDriverSFP(DUT.deviceIndex, deviceAddress, StartAddress, regAddress + i, 0x01, chipset, new byte[2]);

                            ReturnArray[i] = ReadArray[0] * 256 + ReadArray[1];
                        }

                        for (int i = Length - 1; i > -1; i--)
                        {
                            ReadData += Convert.ToInt16(ReturnArray[i] * Math.Pow(256, Length - 1 - i));
                        }
                    }


                    return(ReadData);
                }
                catch
                {
                    return(ReadData);
                }
            }
            //  return EEPROM.ReadWriteDriverSFP(DUT.deviceIndex, deviceAddress, StartAddress, regAddress, 0x01, chipset, new byte[2]);
        }