Ejemplo n.º 1
0
        public Urb SubmitUrb(byte address, byte endpoint, uint requestedLength)
        {
            Urb ret = null;

            var d = new byte[1 + 1 + 4];

            d[0] = address;
            d[1] = endpoint;
            Utilities.SetBigEndianUint(d, 2, requestedLength);

            lock (_urbs)
            {
                var response = _SendRequest((byte)'U', d);
                _VerifyResponseLength(response, 5);
                var error = (VicarErrorCode)response.Data[0];
                if (error != VicarErrorCode.Success)
                {
                    throw new VicarException(error, string.Format("Error submitting URB for address {0}, endpoint {1}, length {2}",
                                                                  address.ToString("X02"), endpoint.ToString("X02"), requestedLength.ToString("X08")));
                }

                ret = new Urb(Utilities.ToLittleEndianUint(response.Data, 1), address, endpoint);
                _urbs.Add(ret.Id, ret);
            }

            return(ret);
        }
Ejemplo n.º 2
0
        public Urb SubmitUrb(byte address, byte endpoint, uint requestedLength)
        {
            Urb ret = null;

              var d = new byte[1 + 1 + 4];
              d[0] = address;
              d[1] = endpoint;
              Utilities.SetBigEndianUint(d, 2, requestedLength);

              lock (_urbs)
              {
            var response = _SendRequest((byte)'U', d);
            _VerifyResponseLength(response, 5);
            var error = (VicarErrorCode)response.Data[0];
            if (error != VicarErrorCode.Success)
            {
              throw new VicarException(error, string.Format("Error submitting URB for address {0}, endpoint {1}, length {2}",
            address.ToString("X02"), endpoint.ToString("X02"), requestedLength.ToString("X08")));
            }

            ret = new Urb(Utilities.ToLittleEndianUint(response.Data, 1), address, endpoint);
            _urbs.Add(ret.Id, ret);
              }

              return ret;
        }