예제 #1
0
        /// <summary>
        /// 开始
        /// </summary>
        public override void StartWorking()
        {
            if (port == null)
            {
                port                = new BiuSerialPort();
                port.ETXStr         = EndChar;
                port.IsASTM         = IsASTM;
                port.IsNeedAck      = IsNeedAck;
                port.DataReceived  += port_DataReceived;
                port.AckReceived   += port_AckReceived;
                port.NakReceived   += port_NakReceived;
                port.EnqReceived   += port_EnqReceived;
                port.EotReceived   += port_EotReceived;
                port.SohReceived   += port_SohReceived;
                port.EtxReceived   += port_EtxReceived;
                port.RS232Received += port_RS232Received;
                //port.CreateTimer(Speed);
                port.log             = Logger;
                port.DefaultEncoding = this.DefaultEncoding;
            }


            if (!port.IsOpen)
            {
                port.Open();
            }
        }
예제 #2
0
        /// <summary>
        /// 停止
        /// </summary>
        public override void StopWork()
        {
            if (port == null)
            {
                return;
            }

            if (port.IsOpen)
            {
                port.Close();
            }


            port.Dispose();
            port = null;
        }