Skip to content
This repository
Browse code

Added a lot of debugging output

  • Loading branch information...
commit 4da5e0d90d27c40da8adeca6fce2a2ed8387c835 1 parent c1a498b
Braden McDorman authored March 19, 2013

Showing 1 changed file with 28 additions and 4 deletions. Show diff stats Hide diff stats

  1. 32  src/ardrone.cpp
32  src/ardrone.cpp
@@ -41,6 +41,8 @@
41 41
 
42 42
 #include <stdint.h>
43 43
 
  44
+#define ARDRONE_DEBUG
  45
+
44 46
 struct navdata_option_t
45 47
 {
46 48
 	// Navdata block ('option') identifier
@@ -598,7 +600,12 @@ bool DroneController::fetchNavdata()
598 600
 
599 601
 bool DroneController::fetchVideo()
600 602
 {
601  
-	if(!m_videoSocket.isOpen()) return true;
  603
+	if(!m_videoSocket.isOpen()) {
  604
+#ifdef ARDRONE_DEBUG
  605
+		std::cout << "Video socket is not open. fetchVideo will silently fail." << std::endl;
  606
+#endif
  607
+		return true;
  608
+	}
602 609
 	
603 610
 	ssize_t readLength = 0;
604 611
 	unsigned char data[UVLC_MAX_SIZE];
@@ -606,15 +613,27 @@ bool DroneController::fetchVideo()
606 613
 		perror("recvfrom");
607 614
 		return false;
608 615
 	}
609  
-	if(readLength < 0) return true;
  616
+	if(readLength < 0) {
  617
+#ifdef ARDRONE_DEBUG
  618
+		std::cout << "Didn't read any data from video stream." << std::endl;
  619
+#endif
  620
+		return true;
  621
+	}
  622
+#ifdef ARDRONE_DEBUG
610 623
 	std::cout << "Read " << readLength << " bytes from video stream" << std::endl;
  624
+#endif
611 625
 	Private::UvlcVideoDecoder().decode(data, readLength, m_image);
612 626
 	return true;
613 627
 }
614 628
 
615 629
 bool DroneController::wakeupStream(Socket &socket, const Address &address)
616 630
 {
617  
-	if(!socket.isOpen()) return false;
  631
+	if(!socket.isOpen()) {
  632
+#ifdef ARDRONE_DEBUG
  633
+		std::cout << "Failed to wakeup stream using invalid socket." << std::endl;
  634
+#endif
  635
+		return false;
  636
+	}
618 637
 	
619 638
 	const static char dummy[4] = { 0x01, 0x00, 0x00, 0x00 };
620 639
 	if(socket.sendto(dummy, sizeof(dummy), address) != sizeof(dummy)) {
@@ -649,7 +668,12 @@ void DroneController::__enumerateOptions()
649 668
 bool DroneController::sendCurrentCommand()
650 669
 {
651 670
 	// Nothing to do.
652  
-	if(m_commandStack.empty() || !m_atSocket.isOpen()) return true;
  671
+	if(m_commandStack.empty() || !m_atSocket.isOpen()) {
  672
+#ifdef ARDRONE_DEBUG
  673
+		std::cout << "Waiting on valid socket and non-empty command stack" << std::endl;
  674
+#endif
  675
+		return true;
  676
+	}
653 677
 	
654 678
 	char realCommand[ARDRONE_MAX_CMD_LENGTH];
655 679
 	sprintf(realCommand, m_commandStack.top().data, m_seq.next());

0 notes on commit 4da5e0d

Please sign in to comment.
Something went wrong with that request. Please try again.