Exemple #1
0
        /// <summary>
        /// Create a new connection towards a device
        /// </summary>
        /// <param name="serial"></param>
        /// <returns></returns>
        internal TcpSocket CreateConnection(string serial)
        {
            TcpSocket ts = new TcpSocket(this.Hostname, this.Port);

            // Redirect all commands to this device
            ts.Send($"host:transport:{serial}");
            return(ts);
        }
Exemple #2
0
 /// <summary>
 ///  Get a list of devices available for communication
 /// </summary>
 /// <returns></returns>
 public Device[] Devices()
 {
     using TcpSocket tc = new TcpSocket(this.Hostname, this.Port);
     return(tc.GetString("host:devices")
            .Split("\n")
            .Where(l => !string.IsNullOrWhiteSpace(l))
            .Select(l => new Device(this, l.Split()[0]))
            .ToArray());
 }
Exemple #3
0
 /// <summary>
 /// Execute a shell command with handling the reply
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="s"></param>
 /// <param name="handler"></param>
 /// <returns></returns>
 public T Shell <T>(string s, Func <NetworkStream, T> handler)
 {
     using TcpSocket ts = this.host.CreateConnection(this.Serial);
     return(ts.Get($"shell:{s}", handler));
 }
Exemple #4
0
 /// <summary>
 /// Execute a shell command without handling the reply
 /// </summary>
 /// <param name="s"></param>
 /// <returns></returns>
 public byte[] Shell(string s)
 {
     using TcpSocket ts = this.host.CreateConnection(this.Serial);
     return(ts.GetBytes($"shell:{s}"));
 }