Commits

Cliff Biffle committed 7e44c25

The AR.Drone Developer Guide contains an error on page 30: AT commands must be terminated by a carriage return, ASCII 13 -- not a line feed, ASCII 10. I determined this experimentally, though other places in the Developer Guide explicitly use the "\r" character escape, so I probably should have been suspicious.

  • Participants
  • Parent commits 6f1b4e1

Comments (0)

Files changed (4)

File src/org/mg8/ardrone/comms/AtCommand.java

       out.put(p.getBytes(Charsets.US_ASCII));
     }
     
-    out.put((byte) '\n');
+    out.put((byte) '\r');
   }
 }

File test/org/mg8/ardrone/comms/ControlMessageTest.java

     replayAll();
     
     unit.addModeMessage(42);
-    assertCommandText("AT*CTRL=1,42\n");
+    assertCommandText("AT*CTRL=1,42\r");
   }
 
   @Test public void testWriteFlyingStateCommand_landNormally() {
     replayAll();
     
     unit.addFlyingStateCommand(false, false);
-    assertCommandText("AT*REF=1,0\n");
+    assertCommandText("AT*REF=1,0\r");
   }
 
   @Test public void testWriteFlyingStateCommand_emergency() {
     replayAll();
     
     unit.addFlyingStateCommand(false, true);
-    assertCommandText("AT*REF=1,256\n");
+    assertCommandText("AT*REF=1,256\r");
   }
 
   @Test public void testWriteFlyingStateCommand_takeOff() {
     replayAll();
     
     unit.addFlyingStateCommand(true, false);
-    assertCommandText("AT*REF=1,512\n");
+    assertCommandText("AT*REF=1,512\r");
   }
   
   @Test public void testWriteHoldPositionCommand() {
     replayAll();
     
     unit.addHoldPositionCommand();
-    assertCommandText("AT*PCMD=1,0,0,0,0,0\n");
+    assertCommandText("AT*PCMD=1,0,0,0,0,0\r");
   }
   
   @Test public void testWriteAttitudeCommand_hover() {
     replayAll();
     
     unit.addAttitudeCommand(0,0,0,0);
-    assertCommandText("AT*PCMD=1,1,0,0,0,0\n");
+    assertCommandText("AT*PCMD=1,1,0,0,0,0\r");
   }
 
   @Test public void testWriteAttitudeCommand_forwardRightAndUp() {
     
     // Values computed using a test fixture and Float.floatToIntBits.
     unit.addAttitudeCommand(0.8f, -0.8f, 0.6f, 0);
-    assertCommandText("AT*PCMD=1,1,1061997773,-1085485875,1058642330,0\n");
+    assertCommandText("AT*PCMD=1,1,1061997773,-1085485875,1058642330,0\r");
   }
 
   @Test public void testWriteFlatTrimCommand() {
     replayAll();
     
     unit.addFlatTrimCommand();
-    assertCommandText("AT*FTRIM=1\n");
+    assertCommandText("AT*FTRIM=1\r");
   }
   
   @Test public void testWriteVideoSelectCommand_frontOnly() {
     replayAll();
     
     unit.addVideoSelectCommand(Camera.FRONT);
-    assertCommandText("AT*ZAP=1,0\n");
+    assertCommandText("AT*ZAP=1,0\r");
   }
 
   @Test public void testWriteVideoSelectCommand_bottomOnly() {
     replayAll();
     
     unit.addVideoSelectCommand(Camera.BOTTOM);
-    assertCommandText("AT*ZAP=1,1\n");
+    assertCommandText("AT*ZAP=1,1\r");
   }
 
   @Test public void testWriteConfigCommand_maxAltitude() {
     replayAll();
     
     unit.addConfigCommand("CONTROL:altitude_max", "5000");
-    assertCommandText("AT*CONFIG=1,\"CONTROL:altitude_max\",\"5000\"\n");
+    assertCommandText("AT*CONFIG=1,\"CONTROL:altitude_max\",\"5000\"\r");
   }
 
   void assertCommandText(String expected) {

File test/org/mg8/ardrone/comms/DroneControlSocketNetTest.java

     DatagramPacket inPacket = new DatagramPacket(inBytes, 1024);
     receiveSocket.receive(inPacket);
     
-    assertEquals("AT*CONFIG=42,\"foo\",\"bar\"\nAT*FTRIM=43\n",
+    assertEquals("AT*CONFIG=42,\"foo\",\"bar\"\rAT*FTRIM=43\r",
         new String(inBytes, 0, inPacket.getLength(), Charsets.US_ASCII));
     
     receiveSocket.close();

File test/org/mg8/ardrone/comms/DroneControlSocketTest.java

 
     unit.send(ImmutableList.of(new AtCommand("FTRIM")));
     
-    String expected = "AT*FTRIM=1\n";
+    String expected = "AT*FTRIM=1\r";
     assertEquals(expected.length(), captured.getLength());
     assertEquals(expected, capturedText());
 
         new AtCommand("PCMD", "0", "0", "0", "0", "0")
         ));
     
-    String expected = "AT*FTRIM=1\nAT*PCMD=2,0,0,0,0,0\n";
+    String expected = "AT*FTRIM=1\rAT*PCMD=2,0,0,0,0,0\r";
     assertEquals(expected.length(), captured.getLength());
     assertEquals(expected, capturedText());
     
 
     unit.send(ImmutableList.of(new AtCommand("FTRIM")));
 
-    assertEquals("AT*FTRIM=1\n", capturedText());
+    assertEquals("AT*FTRIM=1\r", capturedText());
     verifyAll();
     resetAll();
     
 
     unit.send(ImmutableList.of(new AtCommand("REF", "0")));
 
-    assertEquals("AT*REF=2,0\n", capturedText());
+    assertEquals("AT*REF=2,0\r", capturedText());
   }
 
   private String capturedText() {