/// <summary>
        /// Write a single SV variable at the given index with the given value.
        /// </summary>
        internal bool WriteSV(LocoBuffer lb, int index, byte value)
        {
            var cmd = new PeerXferRequest1
            {
                Command        = PeerXferRequest.Commands.Write,
                SvAddress      = index,
                DestinationLow = address.Address,
                SubAddress     = address.SubAddress,
                Data1          = value,
            };
            var result = cmd.ExecuteAndWaitForResponse <PeerXferResponse>(
                lb,
                x => (address.Equals(x.Source) && (x.SvAddress == index) && (x.OriginalCommand == PeerXferRequest.Commands.Write)),
                timeout);

            return((result != null) && (result.Data1 == value));
        }
        /// <summary>
        /// Write a single SV variable at the given index with the given value.
        /// </summary>
        internal bool ChangeAddress(LocoBuffer lb, int address, int subAddress)
        {
            var cmd = new PeerXferRequest1
            {
                Command        = PeerXferRequest.Commands.Write,
                SvAddress      = 1,
                DestinationLow = this.address.Address,
                SubAddress     = this.address.SubAddress,
                Data1          = (byte)address,
            };
            var result = cmd.ExecuteAndWaitForResponse <PeerXferResponse>(
                lb,
                x => ((x.SvAddress == 1) && (x.OriginalCommand == PeerXferRequest.Commands.Write)),
                timeout);

            if (result == null)
            {
                throw new TimeoutException("Program index 1 failed");
            }

            cmd = new PeerXferRequest1
            {
                Command        = PeerXferRequest.Commands.Write,
                SvAddress      = 2,
                DestinationLow = this.address.Address,
                SubAddress     = this.address.SubAddress,
                Data1          = (byte)subAddress,
            };
            result = cmd.ExecuteAndWaitForResponse <PeerXferResponse>(
                lb,
                x => ((x.SvAddress == 2) && (x.OriginalCommand == PeerXferRequest.Commands.Write)),
                timeout);

            if (result == null)
            {
                throw new TimeoutException("Program index 2 failed");
            }

            return(true);
        }
        /// <summary>
        /// Read a single SV variable at the given index.
        /// </summary>
        internal bool TryReadSV(LocoBuffer lb, int index, out byte value)
        {
            var cmd = new PeerXferRequest1
            {
                Command        = PeerXferRequest.Commands.Read,
                SvAddress      = index,
                DestinationLow = address.Address,
                SubAddress     = address.SubAddress,
            };

            var result = cmd.ExecuteAndWaitForResponse <PeerXferResponse>(
                lb,
                x => (address.Equals(x.Source) && (x.SvAddress == index) && (x.OriginalCommand == PeerXferRequest.Commands.Read)),
                timeout);

            if (result != null)
            {
                value = result.Data1;
                return(true);
            }
            value = 0;
            return(false);
        }
        /// <summary>
        /// Write a single SV variable at the given index with the given value.
        /// </summary>
        internal bool ChangeAddress(LocoBuffer lb, int address, int subAddress)
        {
            var cmd = new PeerXferRequest1
            {
                Command = PeerXferRequest.Commands.Write,
                SvAddress = 1,
                DestinationLow =this.address.Address,
                SubAddress = this.address.SubAddress,
                Data1 = (byte)address,
            };
            var result = cmd.ExecuteAndWaitForResponse<PeerXferResponse>(
                lb,
                x => ((x.SvAddress == 1) && (x.OriginalCommand == PeerXferRequest.Commands.Write)),
                timeout);

            if (result == null)
                throw new TimeoutException("Program index 1 failed");

            cmd = new PeerXferRequest1
            {
                Command = PeerXferRequest.Commands.Write,
                SvAddress = 2,
                DestinationLow = this.address.Address,
                SubAddress = this.address.SubAddress,
                Data1 = (byte)subAddress,
            };
            result = cmd.ExecuteAndWaitForResponse<PeerXferResponse>(
                lb,
                x => ((x.SvAddress == 2) && (x.OriginalCommand == PeerXferRequest.Commands.Write)),
                timeout);

            if (result == null)
                throw new TimeoutException("Program index 2 failed");

            return true;
        }
 /// <summary>
 /// Write a single SV variable at the given index with the given value.
 /// </summary>
 internal bool WriteSV(LocoBuffer lb, int index, byte value)
 {
     var cmd = new PeerXferRequest1
     {
         Command = PeerXferRequest.Commands.Write,
         SvAddress = index,
         DestinationLow = address.Address,
         SubAddress = address.SubAddress,
         Data1 = value,
     };
     var result = cmd.ExecuteAndWaitForResponse<PeerXferResponse>(
         lb,
         x => (address.Equals(x.Source) && (x.SvAddress == index) && (x.OriginalCommand == PeerXferRequest.Commands.Write)),
         timeout);
     return (result != null) && (result.Data1 == value);
 }
        /// <summary>
        /// Read a single SV variable at the given index.
        /// </summary>
        internal bool TryReadSV(LocoBuffer lb, int index, out byte value)
        {
            var cmd = new PeerXferRequest1
                          {
                              Command = PeerXferRequest.Commands.Read,
                              SvAddress = index,
                              DestinationLow = address.Address,
                              SubAddress = address.SubAddress,
                          };

            var result = cmd.ExecuteAndWaitForResponse<PeerXferResponse>(
                lb,
                x => (address.Equals(x.Source) && (x.SvAddress == index) && (x.OriginalCommand == PeerXferRequest.Commands.Read)),
                timeout);
            if (result != null)
            {
                value = result.Data1;
                return true;
            }
            value = 0;
            return false;
        }