Skip to content

Commit

Permalink
Add an interface for enabling and disabling TSIP interrupts by turnin…
Browse files Browse the repository at this point in the history
…g on and off SoftwareSerial as having GPS interrupts during RTTY send seemed to be causing garbled strings.
  • Loading branch information
jgrahamc committed Apr 5, 2011
1 parent 58794cf commit 652c1c8
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 9 deletions.
5 changes: 5 additions & 0 deletions gaga-1/flight/gaga1/rtty.cpp
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand All @@ -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();
}

35 changes: 26 additions & 9 deletions gaga-1/flight/gaga1/tsip.cpp
Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -219,3 +226,13 @@ void tsip_handle()
}
}

void tsip_enable()
{
gps.begin(9600);
}

void tsip_disable()
{
gps.end();
}

3 changes: 3 additions & 0 deletions gaga-1/flight/gaga1/tsip.h
Expand Up @@ -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.