예제 #1
0
        public void Test()
        {
            Queue_buffer a = new Queue_buffer();

            a.qin(0x31);
            a.qin(0x32);
            a.qin(0x33);

            Console.WriteLine(a.ToString());
            Console.WriteLine(a.qsize());

            byte[] bf = new byte[a.qsize()];

            int    len = a.qout(bf, a.qsize());
            string b   = System.Text.Encoding.UTF8.GetString(bf, 0, len);

            Console.WriteLine(b);
            Console.WriteLine(a.qsize());
        }
예제 #2
0
        private void serial_rx_CallBack()
        {
            int len;

            // 예외처리 필요함

            try{
                lock (lock_threadCall)
                {
                    len = serial_port.BytesToRead;

                    if (len > 0)
                    {
                        byte[] rx_bf = new byte[len];

                        serial_port.Read(rx_bf, 0, len);
                        #region debug - display message
#if false
                        try
                        {
                            Debug.Write(Encoding.ASCII.GetString(rx_bf, 0, len));  // display
                        }
                        catch
                        {
                            try
                            {
                                string str1 = BitConverter.ToString(rx_bf).Replace("-", " ");
                                Debug.WriteLine("\nprint BUFFER[{0}]: ", len + str1);
                            }
                            catch
                            {
                            }
                        }
#endif
                        #endregion
                        rxq.qin(rx_bf);
                    }

                    if (DelayedRxCallback != null)
                    {
                        DelayedRxCallback(this);
                    }
                }
            }
            catch (Exception e)
            {
                //MessageBox.Show("{0} Exception caught.", e.ToString());
            }



            //Debug.WriteLine("Comm: {0}", len);
        }