Don't send SSDV when no fix. Added nmea_t::seconds()

master
Michal Fratczak 2020-04-11 20:06:42 +02:00
rodzic a6d27c94d2
commit c7043e2956
5 zmienionych plików z 37 dodań i 11 usunięć

Wyświetl plik

@ -31,7 +31,7 @@ public:
float freqMHz = 0; //MegaHertz
baud_t baud = baud_t::kInvalid;
std::string ssdv_image; // ssdv encoded image path
int msg_num = 1; // number of telemetry sentences emitted between SSDV packets
int msg_num = 5; // number of telemetry sentences emitted between SSDV packets
int port = 6666; // zeroMQ server port
// hardware config

Wyświetl plik

@ -238,14 +238,13 @@ int main1(int argc, char** argv)
// READ SENSORS, CONSTRUCT TELEMETRY MESSAGE, RF SEND TEMEMETRY AND IMAGE
//
nmea_t valid_nmea;
ssdv_t ssdv_data;
ssdv_t ssdv_tiles;
int msg_id = 0;
while(G_RUN)
{
for(int i=0; i<G.cli.msg_num; ++i)
int msg_num = 0;
while( msg_num++ < G.cli.msg_num )
{
++msg_id;
const nmea_t current_nmea = G.nmea_get();
const bool gps_fix_valid =
current_nmea.fix_status == nmea_t::fix_status_t::kValid
@ -259,7 +258,7 @@ int main1(int argc, char** argv)
//
stringstream msg_stream;
msg_stream<<G.cli.callsign;
msg_stream<<","<<msg_id;
msg_stream<<","<<msg_id++;
msg_stream<<","<<valid_nmea.utc;
msg_stream<<","<<valid_nmea.lat<<","<<valid_nmea.lon<<","<<valid_nmea.alt;
msg_stream<<","<<valid_nmea.sats<<","<<gps_fix_valid;
@ -271,21 +270,29 @@ int main1(int argc, char** argv)
// emit telemetry msg RF
//
mtx2_write(radio_fd, msg_and_crc + '\n');
// if no GPS fix, keep sending telemetry instead of SSDV
//
// for some reason this loop-restart does not work with for() loop
if( !gps_fix_valid )
msg_num = 0;
}
// send SSDV image next packet
//
if( G.cli.ssdv_image.size() && !ssdv_data.size() )
cout<<"SSDV loaded "<<ssdv_data.load_file( G.cli.ssdv_image )<<" tiles"<<endl;
if( ssdv_data.size() )
if( !ssdv_tiles.size() & G.cli.ssdv_image.size() )
cout<<"SSDV loaded "<<ssdv_tiles.load_file( G.cli.ssdv_image )<<" packets from disk."<<endl;
if( ssdv_tiles.size() )
{
auto tile = ssdv_data.next_tile();
if(!ssdv_data.size()) // delete image after send
auto tile = ssdv_tiles.next_tile();
if(!ssdv_tiles.size()) // delete image when done
system( (string("rm -f ") + G.cli.ssdv_image).c_str() );
cout<<"SSDV"<<endl;
mtx2_write( radio_fd, tile.data(), sizeof(tile) );
}
}
// RELEASE RESOURCES
//
cout<<"Closing sensors thread"<<endl;
@ -301,6 +308,7 @@ int main1(int argc, char** argv)
cout<<"Closing zmq"<<endl;
zmq_thread.join(); // will return after next received message, or stuck forever if no messages come in
return 0;
}

Wyświetl plik

@ -281,3 +281,15 @@ std::string nmea_t::str() const
return s.str();
}
// convert utc HHMMSS to seconds
int nmea_t::seconds() const
{
int H=0;
int M=0;
int S=0;
sscanf(utc, "%02d%02d%02d", &H, &M, &S);
const int total_seconds = S + 60*M + 60*60*H;
return total_seconds;
}

Wyświetl plik

@ -36,6 +36,8 @@ public:
fix_quality_t fix_quality = fix_quality_t::kNoFix;
std::string str() const;
int seconds() const; // convert utc HHMMSS to seconds
};

Wyświetl plik

@ -49,4 +49,8 @@ int main()
B = A;
cout<<B.str()<<endl;
cout<<"\n\nnmea_t::seconds"<<endl;
cout<<A.seconds()<<endl;
}