コード例 #1
0
        public void Write(string data)
        {
            byte[] bytes = GetArrotOfBytes(data);
            bytes = ByteStuffing.Encode(bytes);
            Int32 count = bytes.Length;

            senderPort.Write(bytes, 0, count);
            //for (int offset = 0; offset < count; offset++)
            //{

            //}
        }
コード例 #2
0
        public string Read()
        {
            byte[] buffer = new byte[BUFFER_SIZE];
            Int32  offset = 0;
            Int32  count  = BUFFER_SIZE;
            int    readbytes;

            try
            {
                readbytes = receiverPort.Read(buffer, offset, count);
                buffer    = ByteStuffing.Decode(buffer);
            }
            catch (TimeoutException) { }
            return(Encoding.UTF8.GetString(buffer));
        }