mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-01-06 07:20:34 +00:00
fixing error handling when writing to a serial bus
This commit is contained in:
parent
18dfe81a71
commit
337dc3b2da
@ -173,21 +173,25 @@ bool Nmea_Printer::Print_Nmea_Line(const std::shared_ptr<Pvt_Solution>& pvt_data
|
||||
//write to serial device
|
||||
if (nmea_dev_descriptor!=-1)
|
||||
{
|
||||
try
|
||||
if(write(nmea_dev_descriptor, GPRMC.c_str(), GPRMC.length()) == -1)
|
||||
{
|
||||
int n_bytes_written;
|
||||
//GPRMC
|
||||
n_bytes_written = write(nmea_dev_descriptor, GPRMC.c_str(), GPRMC.length());
|
||||
//GPGGA (Global Positioning System Fixed Data)
|
||||
n_bytes_written = write(nmea_dev_descriptor, GPGGA.c_str(), GPGGA.length());
|
||||
//GPGSA
|
||||
n_bytes_written = write(nmea_dev_descriptor, GPGSA.c_str(), GPGSA.length());
|
||||
//GPGSV
|
||||
n_bytes_written = write(nmea_dev_descriptor, GPGSV.c_str(), GPGSV.length());
|
||||
DLOG(INFO) << "NMEA printer cannot write on serial device" << nmea_devname.c_str();
|
||||
return false;
|
||||
}
|
||||
catch(std::exception ex)
|
||||
if(write(nmea_dev_descriptor, GPGGA.c_str(), GPGGA.length()) == -1)
|
||||
{
|
||||
DLOG(INFO) << "NMEA printer can not write on serial device" << nmea_filename.c_str();;
|
||||
DLOG(INFO) << "NMEA printer cannot write on serial device" << nmea_devname.c_str();
|
||||
return false;
|
||||
}
|
||||
if(write(nmea_dev_descriptor, GPGSA.c_str(), GPGSA.length()) == -1)
|
||||
{
|
||||
DLOG(INFO) << "NMEA printer cannot write on serial device" << nmea_devname.c_str();
|
||||
return false;
|
||||
}
|
||||
if(write(nmea_dev_descriptor, GPGSV.c_str(), GPGSV.length()) == -1)
|
||||
{
|
||||
DLOG(INFO) << "NMEA printer cannot write on serial device" << nmea_devname.c_str();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -91,6 +91,7 @@ bool Rtcm_Printer::Print_Rtcm_MT1001(const Gps_Ephemeris& gps_eph, double obs_ti
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Rtcm_Printer::Print_Rtcm_MT1019(const Gps_Ephemeris & gps_eph)
|
||||
{
|
||||
std::string m1019 = rtcm->print_MT1019(gps_eph);
|
||||
@ -98,6 +99,7 @@ bool Rtcm_Printer::Print_Rtcm_MT1019(const Gps_Ephemeris & gps_eph)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Rtcm_Printer::Print_Rtcm_MT1045(const Galileo_Ephemeris & gal_eph)
|
||||
{
|
||||
std::string m1045 = rtcm->print_MT1045(gal_eph);
|
||||
@ -156,27 +158,25 @@ void Rtcm_Printer::close_serial()
|
||||
|
||||
bool Rtcm_Printer::Print_Message(std::string message)
|
||||
{
|
||||
//write to file
|
||||
try
|
||||
{
|
||||
rtcm_file_descriptor << message << std::endl;
|
||||
|
||||
}
|
||||
catch(std::exception ex)
|
||||
{
|
||||
DLOG(INFO) << "RTCM printer can not write on output file" << rtcm_filename.c_str();
|
||||
return false;
|
||||
}
|
||||
|
||||
//write to serial device
|
||||
if (rtcm_dev_descriptor != -1)
|
||||
{
|
||||
try
|
||||
if(write(rtcm_dev_descriptor, message.c_str(), message.length()) == -1)
|
||||
{
|
||||
int n_bytes_written;
|
||||
n_bytes_written = write(rtcm_dev_descriptor, message.c_str(), message.length());
|
||||
}
|
||||
catch(std::exception ex)
|
||||
{
|
||||
DLOG(INFO) << "RTCM printer can not write on serial device" << rtcm_filename.c_str();;
|
||||
DLOG(INFO) << "RTCM printer cannot write on serial device" << rtcm_devname.c_str();
|
||||
std::cout << "RTCM printer cannot write on serial device" << rtcm_devname.c_str() << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user