Пример #1
0
        private bool LoadEpromIIC(string fwFile, bool isLargeEEprom)
        {
            // Need to do this here, since FwImage contains VendAX at this point.
            for (int i = 0; i < Util.MaxFwSize; i++)
            {
                FwImage[i] = 0xFF;
            }

            if (!ReadConfigData(fwFile))
            {
                return(false);
            }

            ControlEndPt.Target  = CyConst.TGT_DEVICE;
            ControlEndPt.ReqType = CyConst.REQ_VENDOR;

            // select variable is used as an indentifier to EEPROM... 1 for large EEPROM and 2 for small EEPROM

            //if(select==1)
            //    ControlEndPt.ReqCode = 0xA9;
            //else if(select==2)
            //    ControlEndPt.ReqCode = 0xA2;

            ControlEndPt.ReqCode = isLargeEEprom ? (byte)0xA9 : (byte)0xA2;

            ControlEndPt.Index = 0;

            uint toTemp = ControlEndPt.TimeOut;

            ControlEndPt.TimeOut = 25000;

            ushort chunk = 4096;

            byte[] buffer = new byte[chunk];

            for (ushort i = 0; i < ImageLen; i += chunk)
            {
                ControlEndPt.Value = i;
                int len = ((i + chunk) < ImageLen) ? chunk : ImageLen - i;

                Array.Copy(FwImage, i, buffer, 0, len);
                if (!ControlEndPt.Write(ref buffer, ref len))
                {
                    return(false);
                }
            }

            ControlEndPt.TimeOut = toTemp;

            return(true);
        }
Пример #2
0
        private bool VerifyFW(bool isLargeEEprom)
        {
            // The written .iic file data needs to still be in FwImage when
            // this function is invoked.
            ControlEndPt.Target  = CyConst.TGT_DEVICE;
            ControlEndPt.ReqType = CyConst.REQ_VENDOR;
            ControlEndPt.Index   = 0;
            if (isLargeEEprom)
            {
                ControlEndPt.ReqCode = CyConst.LARGEEEPROM_FW_VERIFIATIONCODE;
            }
            else
            {
                ControlEndPt.ReqCode = CyConst.SMALLEEPROM_FW_VERIFIATIONCODE;
            }

            uint toTemp = ControlEndPt.TimeOut;

            ControlEndPt.TimeOut = 25000;

            ushort chunk = 4096;

            byte[] buffer = new byte[chunk];

            for (ushort i = 0; i < ImageLen; i += chunk)
            {
                ControlEndPt.Value = i;
                int len = ((i + chunk) < ImageLen) ? chunk : ImageLen - i;

                if (!ControlEndPt.Read(ref buffer, ref len))
                {
                    return(false);
                }

                for (int b = 0; b < len; b++)
                {
                    if (buffer[b] != FwImage[b + i])
                    {
                        return(false);
                    }
                }
            }

            ControlEndPt.TimeOut = toTemp;

            return(true);
        }
Пример #3
0
        private bool LoadRamIIC(string fwFile)
        {
            // Need to do this here, since FwImage contains VendAX at this point.
            for (int i = 0; i < Util.MaxFwSize; i++)
            {
                FwImage[i] = 0xFF;
            }

            ReadConfigData(fwFile);

            // FwImage holds the file contents, suitable for the EEPROM
            // Now, parse it into FwBuf, putting each record at the right offset,
            // suitable for the FX2 RAM
            byte[] FwBuf = new byte[Util.MaxFwSize];
            for (int i = 0; i < Util.MaxFwSize; i++)
            {
                FwBuf[i] = 0xFF;
            }
            Util.ParseIICData(FwImage, FwBuf, ref ImageLen, ref FwOffset);

            ControlEndPt.Target  = CyConst.TGT_DEVICE;
            ControlEndPt.ReqType = CyConst.REQ_VENDOR;
            ControlEndPt.ReqCode = 0xA0;
            ControlEndPt.Index   = 0;

            Reset(1); // Halt

            ushort chunk = 2048;

            byte[] buffer = new byte[chunk];

            for (ushort i = FwOffset; i < ImageLen; i += chunk)
            {
                ControlEndPt.Value = i;
                int len = ((i + chunk) < ImageLen) ? chunk : ImageLen - i;
                Array.Copy(FwBuf, i, buffer, 0, len);

                if (!ControlEndPt.Write(ref buffer, ref len))
                {
                    return(false);
                }
            }

            Reset(0); // Run

            return(true);
        }
Пример #4
0
        public void Reset(int hold)
        {
            TTransaction m_FXaction = new TTransaction();

            byte[] dta = new byte[8];

            ControlEndPt.Target  = CyConst.TGT_DEVICE;
            ControlEndPt.ReqType = CyConst.REQ_VENDOR;
            ControlEndPt.Value   = 0xE600;
            ControlEndPt.Index   = 0x0000;

            ControlEndPt.ReqCode = 0xA0;
            dta[0] = (byte)hold;
            int len = 1;

            ControlEndPt.Write(ref dta, ref len);
            len = 1;
            if (m_bRecording && (m_script_file_name != null))
            {
                m_FXaction.AltIntfc  = m_AltIntfc;
                m_FXaction.ConfigNum = m_ConfigNum;
                m_FXaction.IntfcNum  = m_IntfcNum;
                m_FXaction.EndPtAddr = ControlEndPt.Address;
                m_FXaction.Tag       = 0;

                m_FXaction.bReqType   = (byte)(ControlEndPt.Direction | ControlEndPt.ReqType | ControlEndPt.Target);
                m_FXaction.CtlReqCode = ControlEndPt.ReqCode;
                m_FXaction.wValue     = ControlEndPt.Value;
                m_FXaction.wIndex     = ControlEndPt.Index;
                m_FXaction.DataLen    = (uint)len;
                m_FXaction.Timeout    = ControlEndPt.TimeOut / 1000;
                m_FXaction.RecordSize = (uint)len + TTransaction.TotalHeaderSize;

                //Write m_FXaction and buffer
                m_FXaction.WriteToStream(m_script_file_name);
                m_FXaction.WriteFromBuffer(m_script_file_name, ref dta, ref len);

                Thread.Sleep(0);
            }


            Thread.Sleep(500);
        }
Пример #5
0
        unsafe internal FX3_FWDWNLOAD_ERROR_CODE DownloadUserIMGtoI2CE2PROM(ref byte[] buf, ref uint buflen)
        {
            int STAGE_SIZE = CyConst.CONTROLTFRER_DATA_LENGTH;

            byte[] downloadbuf     = new byte[STAGE_SIZE];
            int    NoOfStage       = ((int)buflen / STAGE_SIZE);
            int    LastStage       = ((int)buflen % STAGE_SIZE);
            uint   DownloadAddress = 0;
            int    FwImagePtr      = 0;
            int    StageSize       = STAGE_SIZE;
            int    maxpkt          = ControlEndPt.MaxPktSize;
            //Get the I2C addressing size
            byte ImgI2CSizeByte     = buf[2]; // the 2nd byte of the IMG file will tell us the I2EPROM internal addressing.
            uint AddresingStageSize = 0;

            ImgI2CSizeByte = (byte)((ImgI2CSizeByte >> 1) & 0x07); // Bit3:1 represent the addressing
            bool IsMicroShipE2Prom = false;

            switch (ImgI2CSizeByte)
            {
            case 0:
            case 1:
                return(FX3_FWDWNLOAD_ERROR_CODE.I2CEEPROM_UNKNOWN_I2C_SIZE);

            case 2:
                AddresingStageSize = (4 * 1024);     // 4KByte
                break;

            case 3:
                AddresingStageSize = (8 * 1024);     // 8KByte
                break;

            case 4:
                AddresingStageSize = (16 * 1024);     // 16KByte
                break;

            case 5:
                AddresingStageSize = (32 * 1024);     // 32KByte
                break;

            case 6:
                AddresingStageSize = (64 * 1024);     // 64KByte
                break;

            case 7:
                IsMicroShipE2Prom  = true;        // 128KByte Addressing for Microchip.
                AddresingStageSize = (64 * 1024); // 64KByte // case 7 represent 128Kbyte but it follow 64Kbyte addressing
                break;

            default:
                return(FX3_FWDWNLOAD_ERROR_CODE.I2CEEPROM_UNKNOWN_I2C_SIZE);
            }

            ControlEndPt.TimeOut   = 5000;
            ControlEndPt.Target    = CyConst.TGT_DEVICE;
            ControlEndPt.ReqType   = CyConst.REQ_VENDOR;
            ControlEndPt.Direction = CyConst.DIR_TO_DEVICE;
            ControlEndPt.ReqCode   = 0xBA;
            ControlEndPt.Value     = (ushort)(DownloadAddress & 0x0000FFFF); // Get 16-bit LSB
            ControlEndPt.Index     = (ushort)(DownloadAddress >> 16);        // Get 16-bit MSB

            for (uint i = 0; i < NoOfStage; i++)
            {
                //Copy data from main buffer to tmp buffer
                for (uint j = 0; j < STAGE_SIZE; j++)
                {
                    downloadbuf[j] = buf[FwImagePtr + j];
                }

                if (!ControlEndPt.XferData(ref downloadbuf, ref StageSize))
                {
                    return(FX3_FWDWNLOAD_ERROR_CODE.FAILED);
                }

                ControlEndPt.Index += (ushort)StageSize; //Starting address  withing I2C chunk size(for I2C size :32Kbyte the Index will go like 0,4,8,12,16 etc..)
                FwImagePtr         += STAGE_SIZE;        //post transfer increament of buffer pointer

                // Address calculation done in the below box
                if (IsMicroShipE2Prom)
                {//Microchip Addressing(0-(1-64),4(64 to 128),1(128 to 192 ),5(192 to 256))
                    if (FwImagePtr >= (128 * 1024))
                    {
                        if ((FwImagePtr % AddresingStageSize) == 0)
                        {
                            if (ControlEndPt.Value == 0x04)
                            {
                                ControlEndPt.Value = 0x01;
                            }
                            else
                            {
                                ControlEndPt.Value = 0x05;
                            }

                            ControlEndPt.Index = 0;
                        }
                    }
                    else if ((FwImagePtr % AddresingStageSize) == 0)
                    {
                        ControlEndPt.Value = 0x04;
                        ControlEndPt.Index = 0;
                    }
                }
                else
                {     //ATMEL addressing sequential
                    if ((FwImagePtr % AddresingStageSize) == 0)
                    { // Increament the Value field to represent the address and reset the Index value to zero.
                        ControlEndPt.Value += 0x01;
                        if (ControlEndPt.Value >= 8)
                        {
                            ControlEndPt.Value = 0x0; //reset the Address to ZERO
                        }
                        ControlEndPt.Index = 0;
                    }
                }
            }

            if (LastStage != 0)
            {//check for last stage
                for (uint j = 0; j < LastStage; j++)
                {
                    downloadbuf[j] = buf[FwImagePtr + j];
                }

                if ((LastStage % maxpkt) != 0)
                {// make it multiple of max packet size
                    int diff = (maxpkt - (LastStage % maxpkt));
                    for (int j = LastStage; j < (LastStage + diff); j++)
                    {
                        downloadbuf[j] = 0;
                    }

                    LastStage += diff;
                }

                if (!ControlEndPt.XferData(ref downloadbuf, ref LastStage))
                {
                    return(FX3_FWDWNLOAD_ERROR_CODE.FAILED);
                }

                /*Failure Case:
                 * The device does not return failure message when file size is more than 128KByte and only one 128Byte E2PROM on the DVK.
                 * Solution:
                 * Read back the last stage data to confirm that all data transferred successfully.*/
                ControlEndPt.ReqCode   = 0xBB;
                ControlEndPt.Direction = CyConst.DIR_FROM_DEVICE;
                if (!ControlEndPt.XferData(ref downloadbuf, ref LastStage))
                {
                    return(FX3_FWDWNLOAD_ERROR_CODE.FAILED);
                }
            }
            return(FX3_FWDWNLOAD_ERROR_CODE.SUCCESS);
        }
Пример #6
0
        private bool Ep0VendorCommand(ref byte[] buf, ref uint buflen, bool IsFromDevice, byte ReqCode, uint Value)
        {
            TTransaction m_Xaction = new TTransaction();

            ControlEndPt.TimeOut = 5000;
            ControlEndPt.Target  = CyConst.TGT_DEVICE;
            ControlEndPt.ReqType = CyConst.REQ_VENDOR;
            if (IsFromDevice)
            {
                ControlEndPt.Direction = CyConst.DIR_FROM_DEVICE;
            }
            else
            {
                ControlEndPt.Direction = CyConst.DIR_TO_DEVICE;
            }
            ControlEndPt.ReqCode = ReqCode;
            ControlEndPt.Value   = (ushort)(Value & 0x0000FFFF); // Get 16-bit LSB
            ControlEndPt.Index   = (ushort)(Value >> 16);        // Get 16-bit MSB
            int len = (int)buflen;

            // Handle the case where transfer length is 0 (used to send the Program Entry)
            if (buflen == 0)
            {
                if (m_bRecording && (m_script_file_name != null))
                {
                    m_Xaction.AltIntfc  = m_AltIntfc;
                    m_Xaction.ConfigNum = m_ConfigNum;
                    m_Xaction.IntfcNum  = m_IntfcNum;
                    m_Xaction.EndPtAddr = ControlEndPt.Address;
                    m_Xaction.Tag       = 0;

                    m_Xaction.bReqType   = (byte)(ControlEndPt.Direction | ControlEndPt.ReqType | ControlEndPt.Target);
                    m_Xaction.CtlReqCode = ControlEndPt.ReqCode;
                    m_Xaction.wValue     = ControlEndPt.Value;
                    m_Xaction.wIndex     = ControlEndPt.Index;
                    m_Xaction.DataLen    = (uint)len;
                    m_Xaction.Timeout    = ControlEndPt.TimeOut / 1000;
                    m_Xaction.RecordSize = (uint)len + TTransaction.TotalHeaderSize;

                    //Write m_Xaction and buffer
                    m_Xaction.WriteToStream(m_script_file_name);
                    m_Xaction.WriteFromBuffer(m_script_file_name, ref buf, ref len);
                }
                return(ControlEndPt.XferData(ref buf, ref len));
            }

            else
            {
                bool bRetCode = false;
                int  Stagelen = 0;
                int  BufIndex = 0;
                while (len > 0)
                {
                    if (len >= 65535)
                    {
                        Stagelen = 65535;
                    }
                    else
                    {
                        Stagelen = (len) % 65535;
                    }

                    // Allocate the buffer
                    byte[] StageBuf = new byte[Stagelen];
                    if (!IsFromDevice)
                    {//write operation
                        for (int i = 0; i < Stagelen; i++)
                        {
                            StageBuf[i] = buf[BufIndex + i];
                        }
                    }

                    bRetCode = ControlEndPt.XferData(ref StageBuf, ref Stagelen);
                    if (m_bRecording && (m_script_file_name != null))
                    {
                        m_Xaction.AltIntfc  = m_AltIntfc;
                        m_Xaction.ConfigNum = m_ConfigNum;
                        m_Xaction.IntfcNum  = m_IntfcNum;
                        m_Xaction.EndPtAddr = ControlEndPt.Address;
                        m_Xaction.Tag       = 0;

                        m_Xaction.bReqType   = (byte)(ControlEndPt.Direction | ControlEndPt.ReqType | ControlEndPt.Target);
                        m_Xaction.CtlReqCode = ControlEndPt.ReqCode;
                        m_Xaction.wValue     = ControlEndPt.Value;
                        m_Xaction.wIndex     = ControlEndPt.Index;
                        m_Xaction.DataLen    = (uint)len;
                        m_Xaction.Timeout    = ControlEndPt.TimeOut / 1000;
                        m_Xaction.RecordSize = (uint)len + TTransaction.TotalHeaderSize;

                        //Write m_Xaction and buffer
                        m_Xaction.WriteToStream(m_script_file_name);
                        m_Xaction.WriteFromBuffer(m_script_file_name, ref buf, ref len);
                    }
                    if (!bRetCode)
                    {
                        return(false);
                    }

                    if (IsFromDevice)
                    {//read operation
                        for (int i = 0; i < Stagelen; i++)
                        {
                            buf[BufIndex + i] = StageBuf[i];
                        }
                    }

                    len      -= Stagelen;
                    BufIndex += Stagelen;
                }
            }
            return(true);
        }
Пример #7
0
        private bool LoadRamHex(string fileName)
        {
            TTransaction m_Xaction = new TTransaction();
            // A .hex file is already in the correct format for the FX2 RAM
            bool rVal = false;

            if (fileName == "VendAX")
            {
                rVal = Util.ParseHexData(VendAX, FwImage, ref ImageLen, ref FwOffset);
            }
            else
            {
                rVal = Util.ParseHexFile(fileName, FwImage, ref ImageLen, ref FwOffset);
            }

            if (rVal)
            {
                ControlEndPt.Target  = CyConst.TGT_DEVICE;
                ControlEndPt.ReqType = CyConst.REQ_VENDOR;
                ControlEndPt.ReqCode = 0xA0;
                ControlEndPt.Index   = 0;

                Reset(1); // Halt

                ushort chunk  = 2048;
                byte[] buffer = new byte[chunk];

                for (ushort i = FwOffset; i < ImageLen; i += chunk)
                {
                    ControlEndPt.Value = i;
                    int len = ((i + chunk) < ImageLen) ? chunk : ImageLen - i;
                    Array.Copy(FwImage, i, buffer, 0, len);

                    ControlEndPt.Write(ref buffer, ref len);

                    if (m_bRecording && (m_script_file_name != null))
                    {
                        m_Xaction.AltIntfc  = m_AltIntfc;
                        m_Xaction.ConfigNum = m_ConfigNum;
                        m_Xaction.IntfcNum  = m_IntfcNum;
                        m_Xaction.EndPtAddr = ControlEndPt.Address;
                        m_Xaction.Tag       = 0;

                        m_Xaction.bReqType   = (byte)(ControlEndPt.Direction | ControlEndPt.ReqType | ControlEndPt.Target);
                        m_Xaction.CtlReqCode = ControlEndPt.ReqCode;
                        m_Xaction.wValue     = ControlEndPt.Value;
                        m_Xaction.wIndex     = ControlEndPt.Index;
                        m_Xaction.DataLen    = (uint)len;
                        m_Xaction.Timeout    = ControlEndPt.TimeOut / 1000;
                        m_Xaction.RecordSize = (uint)len + TTransaction.TotalHeaderSize;

                        //Write m_Xaction and buffer
                        m_Xaction.WriteToStream(m_script_file_name);
                        m_Xaction.WriteFromBuffer(m_script_file_name, ref buffer, ref len);
                    }
                }

                Reset(0); // Run

                return(true);
            }

            else
            {
                return(false);
            }
        }
Пример #8
0
        private bool LoadRamHex(string fname, bool blow)
        {
            TTransaction m_Xaction = new TTransaction();

            list.Clear();
            list1.Clear();

            string line, sOffset, tmp;
            int    v;

            FileStream   fs = new FileStream(fname, FileMode.Open, FileAccess.Read);
            StreamReader sr = new StreamReader(fs);

            while (!sr.EndOfStream)
            {
                list.Add(sr.ReadLine());
            }
            sr.Close();
            fs.Close();

            int Ramsize = 0x4000;

            // Delete non-data records
            for (int i = list.Count - 1; i >= 0; i--)
            {
                line = (string)list[i];
                if (line.Length > 0)
                {
                    tmp = line.Substring(7, 2);   // Get the Record Type into v
                    v   = (int)Util.HexToInt(tmp);
                    if (v != 0)
                    {
                        list.Remove(list[i]);           // Data records are type == 0
                    }
                }
            }

            for (int i = 0; i < list.Count; i++)
            {
                line = (string)list[i];

                // Remove comments
                v = line.IndexOf("//");
                if (v > -1)
                {
                    line = line.Substring(0, v - 1);
                }

                // Build string that just contains the offset followed by the data bytes
                if (line.Length > 0)
                {
                    // Get the offset
                    sOffset = line.Substring(3, 4);

                    // Get the string of data chars
                    tmp = line.Substring(1, 2);
                    v   = (int)Util.HexToInt(tmp) * 2;
                    string s = line.Substring(9, v);

                    list1.Add(sOffset + s);
                }
            }

            if (blow)
            {
                Reset(1);
            }

            byte   Reqcode = blow ? (byte)0xA0 : (byte)0xA3;
            ushort windex  = 0;

            int    iindex     = 0;
            string Datastring = "";
            int    nxtoffset  = 0;
            int    xferLen    = 0;
            ushort wvalue     = 0;

            foreach (string lines in list1)
            {
                line = lines.Substring(0, 4);
                ushort offset = (ushort)Util.HexToInt(line);

                int slen = lines.Length;

                int no_bytes = (slen - 4) / 2;
                int lastaddr = offset + no_bytes;

                //if (blow && (offset < Ramsize) && (lastaddr > Ramsize))
                //    no_bytes = Ramsize - offset;

                //if (!blow && (offset < Ramsize) && (lastaddr > Ramsize))
                //{
                //    no_bytes = lastaddr - (int)Ramsize;
                //    string s = "xxxx" + lines.Substring(slen - (no_bytes * 2), no_bytes * 2);

                //    list1[iindex] = s;
                //    offset = (ushort)Ramsize;
                //    line = "4000";
                //}

                //if ((blow && (offset < Ramsize)) || (!blow && (offset >= Ramsize)))
                if ((blow && (lastaddr < Ramsize)) || (!blow && (lastaddr >= Ramsize)))
                {
                    xferLen += no_bytes;

                    if ((offset == nxtoffset) && (xferLen < 0x1000))
                    {
                        Datastring += lines.Substring(4, no_bytes * 2);
                    }
                    else
                    {
                        int len = Datastring.Length;


                        if (!len.Equals(0))
                        {
                            int    bufLen = len / 2;
                            byte[] buf    = new byte[bufLen];
                            string d;

                            for (int j = 0; j < bufLen; j++)
                            {
                                d      = Datastring.Substring(j * 2, 2);
                                buf[j] = (byte)Util.HexToInt(d);
                            }

                            ControlEndPt.Target    = CyConst.TGT_DEVICE;
                            ControlEndPt.ReqType   = CyConst.REQ_VENDOR;
                            ControlEndPt.Direction = CyConst.DIR_TO_DEVICE;
                            ControlEndPt.ReqCode   = Reqcode;
                            ControlEndPt.Value     = wvalue;
                            ControlEndPt.Index     = windex;

                            ControlEndPt.Write(ref buf, ref bufLen);
                            if (m_bRecording && (m_script_file_name != null))
                            {
                                m_Xaction.AltIntfc  = m_AltIntfc;
                                m_Xaction.ConfigNum = m_ConfigNum;
                                m_Xaction.IntfcNum  = m_IntfcNum;
                                m_Xaction.EndPtAddr = ControlEndPt.Address;
                                m_Xaction.Tag       = 0;

                                m_Xaction.bReqType   = (byte)(ControlEndPt.Direction | ControlEndPt.ReqType | ControlEndPt.Target);
                                m_Xaction.CtlReqCode = ControlEndPt.ReqCode;
                                m_Xaction.wValue     = ControlEndPt.Value;
                                m_Xaction.wIndex     = ControlEndPt.Index;
                                m_Xaction.DataLen    = (uint)bufLen;
                                m_Xaction.Timeout    = ControlEndPt.TimeOut / 1000;
                                m_Xaction.RecordSize = (uint)bufLen + TTransaction.TotalHeaderSize;

                                //Write m_Xaction and buffer
                                m_Xaction.WriteToStream(m_script_file_name);
                                m_Xaction.WriteFromBuffer(m_script_file_name, ref buf, ref bufLen);
                            }
                        }

                        wvalue     = (ushort)Util.HexToInt(line);
                        Datastring = lines.Substring(4, no_bytes * 2);
                        xferLen    = no_bytes;
                    }

                    nxtoffset = offset + no_bytes;
                }
                iindex++;
            }

            int len1 = Datastring.Length;

            if (!len1.Equals(0))
            {
                int    bufLen = len1 / 2;
                byte[] buf1   = new byte[bufLen];
                string d;

                for (int j = 0; j < bufLen; j++)
                {
                    d       = Datastring.Substring(j * 2, 2);
                    buf1[j] = (byte)Util.HexToInt(d);
                }


                ControlEndPt.Target    = CyConst.TGT_DEVICE;
                ControlEndPt.ReqType   = CyConst.REQ_VENDOR;
                ControlEndPt.Direction = CyConst.DIR_TO_DEVICE;
                ControlEndPt.ReqCode   = Reqcode;
                ControlEndPt.Value     = wvalue;
                ControlEndPt.Index     = windex;

                ControlEndPt.Write(ref buf1, ref bufLen);

                if (m_bRecording && (m_script_file_name != null))
                {
                    m_Xaction.AltIntfc  = m_AltIntfc;
                    m_Xaction.ConfigNum = m_ConfigNum;
                    m_Xaction.IntfcNum  = m_IntfcNum;
                    m_Xaction.EndPtAddr = ControlEndPt.Address;
                    m_Xaction.Tag       = 0;

                    m_Xaction.bReqType   = (byte)(ControlEndPt.Direction | ControlEndPt.ReqType | ControlEndPt.Target);
                    m_Xaction.CtlReqCode = ControlEndPt.ReqCode;
                    m_Xaction.wValue     = ControlEndPt.Value;
                    m_Xaction.wIndex     = ControlEndPt.Index;
                    m_Xaction.DataLen    = (uint)bufLen;
                    m_Xaction.Timeout    = ControlEndPt.TimeOut / 1000;
                    m_Xaction.RecordSize = (uint)bufLen + TTransaction.TotalHeaderSize;

                    //Write m_Xaction and buffer
                    m_Xaction.WriteToStream(m_script_file_name);
                    m_Xaction.WriteFromBuffer(m_script_file_name, ref buf1, ref bufLen);
                }
            }

            if (blow)
            {
                Reset(0);
            }

            return(true);
        }