Пример #1
0
        private bool CallState(SerialPort serialPort)
        {
            byte[] rxBytes   = { };
            bool   readstate = false;

            if (serialPort.IsOpen)
            {
                int count = 0;
                do
                {
                    count = serialPort.BytesToRead;
                } while (count == 0);

                if (count > 2)
                {
                    readstate = true;
                }
                int totBytesRead = 0;
                rxBytes = new byte[count];
                while (totBytesRead < count)
                {
                    int bytesRead = serialPort.Read(rxBytes, 0, count - totBytesRead);
                    totBytesRead += bytesRead;
                }
                getStatus get = new getStatus(StateInfo);
                get(ConvertByteToString(rxBytes));
            }
            return(readstate);
        }
Пример #2
0
        public getStatusResponse GetStatus()
        {
            GetBankCertificateIfRequired();

            var request          = new getStatus();
            var technicalAddress = new technicalAddress();
            var serviceHeader    = BuildServiceHeader();
            var client           = CreateClient();

            return(client.getStatus(ref technicalAddress, ref serviceHeader, request));
        }
Пример #3
0
        private void CallState(SerialPort serialPort)
        {
            if (serialPort.IsOpen)
            {
                int count = serialPort.BytesToRead;
                serialPort.ReadTimeout = 1000;
                int    totBytesRead = 0;
                byte[] rxBytes      = new byte[count];

                while (totBytesRead < count)
                {
                    int bytesRead = serialPort.Read(rxBytes, totBytesRead, count - totBytesRead);
                    totBytesRead += bytesRead;
                }
                getStatus get = new getStatus(GetState);
                get(ConvertByteToString(rxBytes));
            }
        }
Пример #4
0
 public System.IAsyncResult BegingetStatus(getStatus getStatus, System.AsyncCallback callback, object asyncState)
 {
     return this.BeginInvoke("getStatus", new object[] {
                 getStatus}, callback, asyncState);
 }