示例#1
0
        public string GetInterfaceVersionCode()
        {
            ThrowWhenNotConnected();

            try
            {
                var requestInfoResponsePacket = new RequestInfoResponsePacket();
                TxCommunication.SendPacket(new RequestInfoPacket(), requestInfoResponsePacket);
                return(requestInfoResponsePacket.FirmwareVersion);
            }
            catch (Exception e)
            {
                HandleException(e);
            }
            return(string.Empty);
        }
示例#2
0
        /// <summary>
        /// Requests the controller name of the controller with the given address. It does not need an open connection
        /// <param name="address">The address which we want to connect to</param>
        /// <returns>The controller name as string. string.Empty when it failed</returns>
        /// </summary>
        public string RequestControllerName(string address)
        {
            // If we cached the address already: return the controller name
            if (_controllerNameCache.ContainsKey(address))
            {
                return(_controllerNameCache[address]);
            }


            try
            {
                // Open the connection
                _adapter.OpenConnection(address);

                // Write the packets bytes
                _adapter.Write(new RequestInfoPacket().GetByteArray());


                var responsePacket = new RequestInfoResponsePacket();

                // Read the response packet
                byte[] response = _adapter.Read(responsePacket.GetPacketLength());
                responsePacket.FromByteArray(response);

                // Close the connection and dispose the adapter
                _adapter.CloseConnection();
                _adapter.Dispose();


                _controllerNameCache.Add(address, responsePacket.ControllerName);

                return(responsePacket.ControllerName);
            }
            catch (Exception)
            {
                return(string.Empty);
            }
        }