Beispiel #1
0
        public void CanReadStatusPacketForSensorData()
        {
            List<byte> receivedData = new List<byte>
                                          {
                                              0xFF, //bytes indicate the start of the packet
                                              0xFF, //bytes indicate the start of the packet
                                              0x05, //ID
                                              0x0A, //length
                                              0x00, //Error
                                              0x7F, //Present Position(L)
                                              0x02, //Present Position(H)
                                              0x04, //Present Speed(L)
                                              0x04, //Present Speed(H)
                                              0x05, //Present Load(L)
                                              0x04, //Present Load(H)
                                              0x7B, //Present Voltage
                                              0x26, //Present Temperature
                                              0xBD  //Checksum
                                          };

            StatusPacket statusPacket = new StatusPacket(receivedData);
            Assert.AreEqual(0xFF, statusPacket.StartByte1);
            Assert.AreEqual(0xFF, statusPacket.StartByte2);
            Assert.AreEqual(0x05, statusPacket.ServoId);
            Assert.AreEqual(0x0A, statusPacket.LengthOfResult);
            Assert.AreEqual(0x00, statusPacket.Error);
            Assert.AreEqual(37.39, statusPacket.Position, 0.01);
            Assert.AreEqual(1028, statusPacket.Speed);
            Assert.AreEqual(Direction.Clockwise, statusPacket.LoadDirection);
            Assert.AreEqual(5, statusPacket.Load);
            Assert.AreEqual(12.3, statusPacket.Voltage);
            Assert.AreEqual(38, statusPacket.Temperature);
            Assert.AreEqual(new byte[] { 0x7F, 0x02, 0x04, 0x04, 0x05, 0x04, 0x7B, 0x26 }, statusPacket.Parameters);
            Assert.AreEqual(0xBD, statusPacket.CheckSum);
            Assert.AreEqual(receivedData, statusPacket.ReceivedData);
        }
Beispiel #2
0
        public void CanReadStatusPacketForTemperature()
        {
            List<byte> corectResult = new List<byte> { 0XFF, 0XFF, 0X01, 0X03, 0X00, 0X20, 0XDB };

            StatusPacket statusPacket = new StatusPacket(corectResult);
            Assert.AreEqual(0xFF, statusPacket.StartByte1);
            Assert.AreEqual(0xFF, statusPacket.StartByte2);
            Assert.AreEqual(0x01, statusPacket.ServoId);
            Assert.AreEqual(0x03, statusPacket.LengthOfResult);
            Assert.AreEqual(0x00, statusPacket.Error);
            Assert.That(statusPacket.Parameters, Is.EquivalentTo(new List<byte> { 0x20 }));
            Assert.AreEqual(0xDB, statusPacket.CheckSum);
            Assert.AreEqual(corectResult, statusPacket.ReceivedData);
        }
Beispiel #3
0
        public void CanReadStatusPacketForPresentLoad()
        {
            List<byte> corectResult = new List<byte> { 0xFF, 0xFF, 0x05, 0x04, 0x00, 0x00, 0x00, 0xF6 };

            StatusPacket statusPacket = new StatusPacket(corectResult);
            Assert.AreEqual(0xFF, statusPacket.StartByte1);
            Assert.AreEqual(0xFF, statusPacket.StartByte2);
            Assert.AreEqual(0x05, statusPacket.ServoId);
            Assert.AreEqual(0x04, statusPacket.LengthOfResult);
            Assert.AreEqual(0x00, statusPacket.Error);
            Assert.That(statusPacket.Parameters, Is.EquivalentTo(new byte[] {0x00, 0x00}));
            Assert.AreEqual(0xF6, statusPacket.CheckSum);
            Assert.AreEqual(corectResult, statusPacket.ReceivedData);
        }