Permalink
Browse files

Add an interface for enabling and disabling TSIP interrupts by turnin…

…g on and off SoftwareSerial as having GPS interrupts during RTTY send seemed to be causing garbled strings.
  • Loading branch information...
1 parent 58794cf commit 652c1c8ff3dda31aeb2fda0c89d80f55bab22ff8 @jgrahamc committed Apr 5, 2011
Showing with 34 additions and 9 deletions.
  1. +5 −0 gaga-1/flight/gaga1/rtty.cpp
  2. +26 −9 gaga-1/flight/gaga1/tsip.cpp
  3. +3 −0 gaga-1/flight/gaga1/tsip.h
@@ -6,6 +6,7 @@
// Radiometrix NTX2
#include "rtty.h"
+#include "tsip.h"
// These are the digital pins used to control the Radiometrix NTX2
// module. TX0/TX1 are for the two tones used for RTTY.
@@ -40,6 +41,8 @@ void rtty_bit(int b) // Send 0 if b is 0, 1 if otherwise
// rtty_send: sends a null-terminated string via radio to the ground trackers
void rtty_send( char * s ) // The null-terminated string to transmit
{
+ tsip_disable();
+
char c;
while ( c = *s++ ) {
int i;
@@ -59,5 +62,7 @@ void rtty_send( char * s ) // The null-terminated string to transmit
// Note that when idling RTTY specifies that it be in the 'mark' state (or 1). This
// is achieved by the stop bits that were sent at the end of the last character.
+
+ tsip_enable();
}
@@ -60,7 +60,6 @@ void tsip_send( BYTE * packet, // Packet data to send
++i;
--j;
}
- Serial.println();
}
// tsip_get: return the position structure containing the latest fix
@@ -78,7 +77,7 @@ void tsip_init()
last.vertical = 0;
last.fix = 0;
- gps.begin(9600);
+ tsip_enable();
// Tell the GPS how to report GPS position and time information. This will come in
// automatically and be handled by tsip_handle below.
@@ -119,6 +118,16 @@ void tsip_position( BYTE * packet, // Pointer to the data inside an 0x4A packet
COPY_SINGLE(longitude, &packet[4] )
COPY_SINGLE(altitude, &packet[8] )
COPY_SINGLE(fix, &packet[16] )
+
+ Serial.print( "TSIP Position:" );
+ Serial.print( last.latitude, 4 );
+ Serial.print( " " );
+ Serial.print( last.longitude, 4 );
+ Serial.print( " " );
+ Serial.print( last.altitude, 2 );
+ Serial.print( " " );
+ Serial.print( last.fix, 2 );
+ Serial.println();
}
// tsip_velocity: handle the reported GPS velocity
@@ -147,13 +156,11 @@ void tsip_packet( BYTE * packet, // The packet data
int length ) // Number of bytes in packet
{
BYTE function = packet[0];
-
- Serial.print( "tsip_packet: " );
- int i = 0;
- while ( i < length ) {
- Serial.print( packet[i], HEX );
- Serial.print( " " );
- ++i;
+
+ Serial.print( "TSIP packet: " );
+ for ( int i = 0; i < length; ++i ) {
+ Serial.print( packet[i], HEX );
+ Serial.print( " " );
}
Serial.println();
@@ -219,3 +226,13 @@ void tsip_handle()
}
}
+void tsip_enable()
+{
+ gps.begin(9600);
+}
+
+void tsip_disable()
+{
+ gps.end();
+}
+
@@ -23,4 +23,7 @@ struct position {
struct position tsip_get();
+void tsip_enable();
+void tsip_disable();
+
#endif // INCLUDED_TSIP

0 comments on commit 652c1c8

Please sign in to comment.