コード例 #1
0
ファイル: TestHarpMessage.cs プロジェクト: bonsai-rx/harp
        public void FromByte_TimestampedValue_PayloadHasValue()
        {
            byte value     = 23;
            var  timestamp = GetTimestamp();
            var  message   = HarpMessage.FromByte(DefaultAddress, timestamp, MessageType.Write, value);

            AssertIsValid(message);
            var(payload, actualTimestamp) = message.GetTimestampedPayloadByte();
            AssertTimestamp(timestamp, actualTimestamp);
            Assert.AreEqual(value, payload);
        }
コード例 #2
0
ファイル: TestHarpMessage.cs プロジェクト: bonsai-rx/harp
        public void FromByte_TimestampedArray_PayloadHasValue()
        {
            var value     = new byte[] { 23, 17 };
            var timestamp = GetTimestamp();
            var message   = HarpMessage.FromByte(DefaultAddress, timestamp, MessageType.Write, value);

            AssertIsValid(message);
            var(payload, actualTimestamp) = message.GetTimestampedPayloadArray <byte>();
            AssertTimestamp(timestamp, actualTimestamp);
            AssertArrayEqual(value, payload);
            Assert.AreEqual(value[1], message.GetTimestampedPayloadByte(1).Value);
        }
コード例 #3
0
ファイル: HarpCommand.cs プロジェクト: bonsai-rx/harp
 /// <summary>
 /// Returns a <see cref="HarpMessage"/> write command with the specified address, and an
 /// array payload of 8-bit unsigned integers.
 /// </summary>
 /// <param name="address">The address of the register to which the Harp message refers to.</param>
 /// <param name="values">The values to be stored in the payload.</param>
 /// <returns>
 /// A valid <see cref="HarpMessage"/> write command with the specified address and payload.
 /// </returns>
 public static HarpMessage WriteByte(int address, params byte[] values)
 {
     return(HarpMessage.FromByte(address, MessageType.Write, values));
 }
コード例 #4
0
ファイル: HarpCommand.cs プロジェクト: bonsai-rx/harp
 /// <summary>
 /// Returns a <see cref="HarpMessage"/> read command for an 8-bit unsigned integer
 /// register with the specified address.
 /// </summary>
 /// <param name="address">The address of the register to read.</param>
 /// <returns>
 /// A valid <see cref="HarpMessage"/> read command for an 8-bit unsigned integer
 /// register with the specified address.
 /// </returns>
 public static HarpMessage ReadByte(int address)
 {
     return(HarpMessage.FromByte(address, MessageType.Read));
 }
コード例 #5
0
ファイル: HarpCommand.cs プロジェクト: bonsai-rx/harp
 /// <summary>
 /// Returns a <see cref="HarpMessage"/> write command with the specified address, and a
 /// single value 8-bit unsigned integer payload.
 /// </summary>
 /// <param name="address">The address of the register to which the Harp message refers to.</param>
 /// <param name="value">The value to be stored in the payload.</param>
 /// <returns>
 /// A valid <see cref="HarpMessage"/> write command with the specified address and payload.
 /// </returns>
 public static HarpMessage WriteByte(int address, byte value)
 {
     return(HarpMessage.FromByte(address, MessageType.Write, value));
 }