Beispiel #1
0
        public bool Initialize(string s, string s1)
        {
            if (ssCommApp == null)
            {
                ssCommApp = new SsCommApp();
            }

            if (!ssCommApp.com.IsOpen)
            {
                SsCommApp.Com_Struct comParam = new SsCommApp.Com_Struct();
                comParam.PortName = s;
                comParam.Baudrate = int.Parse(s1);
                comParam.Parity   = "不校验";
                comParam.StopBit  = "1位";
                comParam.ByteSize = 8;
                if (ssCommApp.InitPort(comParam))
                {
                    //ssCommApp.Handlers += new SsCommApp.HandleCommData(HandleCommData);
                }

                return(true);
            }
            else
            {
                ssCommApp.UnInitPort();
                ssCommApp = null;
            }

            return(false);
        }
Beispiel #2
0
        public bool Close()
        {
            if (ssCommApp != null)
            {
                ssCommApp.UnInitPort();
                ssCommApp = null;
                return(true);
            }

            return(false);
        }