Question
Can you provide me the code solution for this? Please and thank you Some Files: dlgps.cpp /** @file dlgps.cpp * @brief Data logger gps Functions
Can you provide me the code solution for this? Please and thank you
Some Files:
dlgps.cpp
/** @file dlgps.cpp * @brief Data logger gps Functions */ #include
#if SIMGPS // Global GPS Data File Pointer FILE * fpgps = NULL; #endif
/** @brief Initializes GPS Module * @author Paul Moggach * @date 25MAR2019 * @param None * @return void */ extern void DlGpsInit(void) { #if SIMGPS fpgps = fopen("gpstestdata.txt","r"); if(fpgps == NULL) { fprintf(stdout,"Unable to open gps test data file "); } #else // Serial GPS device or GPSD server serial_init(); serial_config(); #endif }
/** @brief Turns on GPS Module * @author Paul Moggach * @date 25MAR2019 * @param None * @return void */ extern void DlGpsOn(void) { //Write on }
/** @brief Compute the GPS location using decimal scale * @author Paul Moggach * @date 25MAR2019 * @param void * @return coord loc_t data structure */ loc_t DlGpsLocation(void) { loc_t cloc = {0.0}; char buffer[GPSDATASZ] = {0}; uint8_t status = _EMPTY; gpgga_t gpgga; gprmc_t gprmc;
while(status != _COMPLETED) { #if SIMGPS fgets(buffer,NMEAMSGSZ,fpgps); if(feof(fpgps)) { rewind(fpgps); } #else serial_readln(buffer,GPSDATASZ); #endif switch (nmea_get_message_type(buffer)) { case NMEA_GPGGA: nmea_parse_gpgga(buffer, &gpgga); cloc.utc = gpgga.utc; DlGpsConvertDegToDec(&(gpgga.latitude), gpgga.lat, &(gpgga.longitude), gpgga.lon); cloc.latitude = gpgga.latitude; cloc.longitude = gpgga.longitude; cloc.altitude = gpgga.altitude; status |= NMEA_GPGGA; break; case NMEA_GPRMC: nmea_parse_gprmc(buffer, &gprmc); cloc.speed = gprmc.speed; cloc.course = gprmc.course; cloc.date = gprmc.date; status |= NMEA_GPRMC; break; } } return cloc; }
/** @brief Turns Off GPS Module * @author Paul Moggach * @date 25MAR2019 * @param None * @return void */ extern void DlGpsOff(void) { #if SIMGPS fclose(fpgps); #endif // serial_close(); }
/** @brief Convert lat e lon to decimals (from deg) * @author Paul Moggach * @date 25MAR2019 * @param latitude double * * @param ns char * @param longitude double * * @param we char * @return void */ void DlGpsConvertDegToDec(double *latitude, char ns, double *longitude, char we) { double lat = (ns == 'N') ? *latitude : -1 * (*latitude); double lon = (we == 'E') ? *longitude : -1 * (*longitude);
*latitude = DlGpsDegDec(lat); *longitude = DlGpsDegDec(lon); }
/** @brief Convert GPS points to decimal * @author Paul Moggach * @date 25MAR2019 * @param deg_point double * @return double */ double DlGpsDegDec(double deg_point) { double ddeg; double sec = modf(deg_point, &ddeg)*60; int deg = (int)(ddeg/100); int min = (int)(deg_point-(deg*100));
double absmlat = round(min * 1000000.); double absslat = round(sec * 1000000.); double absdlat = round(deg * 1000000.);
return round(absdlat + (absmlat/60) + (absslat/3600)) /1000000; } makefile
vdl: vdl.o logger.o serial.o nmea.o dlgps.o g++ -g -o vdl vdl.o logger.o serial.o nmea.o dlgps.o -lm vdl.o: vdl.cpp vdl.h logger.h serial.h nmea.h dlgps.h g++ -g -c vdl.cpp logger.o: logger.cpp logger.h serial.h nmea.h dlgps.h g++ -g -c logger.cpp serial.o: serial.cpp serial.h g++ -g -c serial.cpp dlgps.o: dlgps.cpp dlgps.h g++ -g -c dlgps.cpp nmea.o: nmea.cpp nmea.h g++ -g -c nmea.cpp clean: touch * rm *.o
dlgps.h
/** @brief Serial port setup * @author Paul Moggach * @date 01JAN2019 */ void serial_init(void) { uart0_filestream = open(PORTNAME, O_RDWR | O_NOCTTY | O_NDELAY);
if (uart0_filestream == -1) { //TODO error handling... } }
/** @brief Serial port configuration * @author Paul Moggach * @date 01JAN2019 */ void serial_config(void) { struct termios options; tcgetattr(uart0_filestream, &options); options.c_cflag = B9600 | CS8 | CLOCAL | CREAD; options.c_iflag = IGNPAR; options.c_oflag = 0; options.c_lflag = 0; tcflush(uart0_filestream, TCIFLUSH); tcsetattr(uart0_filestream, TCSANOW, &options); }
/** @brief Writes a line to the serial port * @author Paul Moggach * @date 01JAN2019 * @param line char * to buffer * @param len number of characters to write */ void serial_println(const char *line, int len) { if (uart0_filestream != -1) { char *cpstr = (char *)malloc((len+1) * sizeof(char)); strcpy(cpstr, line); cpstr[len-1] = ' '; cpstr[len] = ' ';
int count = write(uart0_filestream, cpstr, len+1); if (count
/** @brief Reads a line from the serial port. * @author Paul Moggach * @date 01JAN2019 * @param buffer char * * @param len int number of characters to read */ void serial_readln(char *buffer, int len) { char c; char *b = buffer; int rx_length = -1; while(1) { rx_length = read(uart0_filestream, (void*)(&c), 1);
if (rx_length
/** @brief Closes serial port * @author Paul Moggach * @date 01JAN2019 */ void serial_close(void) { close(uart0_filestream); }
CENG252 Lab02 - Program Structure Vehicle data loggers are used in many settings such as robotics or cars. Our logger captures and displays environmental motion, attitude, directional and navigation data from a sensor package and gps hardware. As well interfaces there is an interface to an accessory controller (Arduino), and data sent to an IOT environment. Logger parameters include: Temperature / Humidity / Pressure. X,Y,Z axis accelerations. Pitch, Roll, Yaw positions. X,Y,Z magnetic field orientation. Latitude/ Longitude/ Altitude/ Speed/Heading . . In this project we integrate a number of third-party programs including: RTIMU sensor library. GPS/NMEA message parsing code. PAHO C++ MQTT Client Library Node-Red Dashboard. MOSQUITTO MQTT broker. . . . Additionally in this lab we use the GIT program for backing up our work and revision control. Task 1 -Adding the Modules From Uploads252W21L02.zip get the new makefile that supports building the GPS message functions dlgps.h/.cpp, nmea.hl.cpp, and serial.hl.cpp. Most of our custom code will be developed in the logger.hl.cpp: 1. In your Code:Blocks vdl project from the File-New-File menu, create new empty files logger.h and logger.cpp. Make sure you check the box that adds them to the Debug target. 2. In logger.h add in the Doxygen file comments changing the date and the author. /** @file logger.h sbrief Logger constants, structures, function prototypes @author Paul Moggach @date 260CT2020 */ 3. Create a Constants section and add in some default logger data. // Default Logger Data Values #define DTEMP 24.6 #define DHUMID 32 #define DPRESS 1013.5 #define DXA 1 #define DYA 1 #define DZA 1 #define DPITCH 10 #define DROLL 15 #define DYAW 20 #define DXM 1 #define DYM 1 #define DZM 1 #define DLAT 43.7289 #define DLONG -79.6074 #define DALT 166 #define DSPEED 99 #define DHEADING 320 4. Create a structure readings for the logger data with a typedef of reading_s with the following fields: time t float float float float float float float float float float float float float float float float float rtime; temperature; humidity; pressure; ; ; ya; za; pitch; roll; yaw; xm; ym; zm; latitude; longitude; altitude; speed; heading; 1//
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started