Beispiel #1
0
        public void InitFunc()
        {
            try
            {
                CommConfig cfg = new CommConfig();

                cfg.commType = CommType.RS232;
                cfg.PortName = comboBox1.SelectedItem.ToString();
                cfg.BaudRate = 115200;
                cfg.DataBit  = 8;
                cfg.parity   = System.IO.Ports.Parity.None;
                cfg.stopbit  = System.IO.Ports.StopBits.One;

                L2Handler = new L2Process(cfg);
                L2Handler.CallbackFunc     = new L2CallbackDataReceived(DataRecvFunc);
                L2Handler.bIsNeedACK       = 0;
                L2Handler.bIsEnableEncrypt = 0;
                L2Handler.u8NumResend      = 2;

                L2Handler.L2Start();
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
                throw ex;
            }
            // Test();
        }
Beispiel #2
0
        public static int L1Object_BuildFromData(L2Process L2Handler, byte[] u8Buff, byte eMinorCMD, byte u8Seq, ref sL1Object_t retL1Obj)
        {
            retL1Obj.u8MajorCmd         = DEFAULT_MAJOR_CMD;
            retL1Obj.u8MinorCmd         = eMinorCMD;
            retL1Obj.bIsNeedFeedBackACK = L2Handler.bIsNeedACK;
            retL1Obj.bIsEnableEncrypt   = L2Handler.bIsEnableEncrypt;
            retL1Obj.u8Seq      = u8Seq;
            retL1Obj.u16DataLen = u8Buff.Length;

            Buffer.BlockCopy(u8Buff, 0, retL1Obj.aPayLoad, 0, retL1Obj.u16DataLen);

            return(1);
        }
Beispiel #3
0
        public static int L1Object_BuildCMDPkg(L2Process L2Handler,
                                               byte eMinorCMD,
                                               byte u8Seq,
                                               ref sL1Object_t retL1Obj)
        {
            //    ASSERT(retL1Obj);
            //    ASSERT(eMinorCMD == ACK_PKG || eMinorCMD == NAK_PKG || eMinorCMD == PING_PKG);

            retL1Obj.u8MajorCmd         = DEFAULT_MAJOR_CMD;
            retL1Obj.u8MinorCmd         = eMinorCMD;
            retL1Obj.bIsNeedFeedBackACK = L2Handler.bIsNeedACK;
            retL1Obj.bIsEnableEncrypt   = L2Handler.bIsEnableEncrypt;
            retL1Obj.u8Seq      = u8Seq;
            retL1Obj.u16DataLen = 0;

            return(1);
        }