示例#1
0
        private byte[] SendAndReceive(DryveObject messageType, int wait = 50, ObjectAccess accessType = ObjectAccess.Read, byte[] dataValue = null, ResultFormat format = ResultFormat.Binary)
        {
            DryveMessage msg = new DryveMessage(_txnId, messageType, accessType, dataValue);

            byte[] message = msg.MessageBytes;
            _txnId++;

            _client.SendMessage(message);
            System.Threading.Thread.Sleep(wait);

            var msgLength = accessType == ObjectAccess.Read ? message.Length + (int)message[18] : 19;
            var result    = _client.ReceiveMessage(msgLength);

            if (!result.Take(2).SequenceEqual(message.Take(2)))
            {
                throw new Exception("Communication error - Transaction ID mismatch.");
            }
            return(result);
        }