Initial commit of files

This commit is contained in:
2021-01-22 10:16:20 -05:00
parent 32d165ec8f
commit ed92211680
534 changed files with 68563 additions and 19 deletions

4
tests/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
gps/ext_test
nmea/nmeatest
uri/uritest

11
tests/CMakeLists.txt Normal file
View File

@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.7)
project(Cnomicon)
# list of header files
set(SUB_DIRS
gps nmea uri
)
foreach(SUB_DIR ${SUB_DIRS})
add_subdirectory(${SUB_DIR})
endforeach()

12
tests/gps/CMakeLists.txt Normal file
View File

@ -0,0 +1,12 @@
cmake_minimum_required(VERSION 3.7)
set(NAME gps)
project(Cnomicon-Test)
set(TARGET ${NAME}_test)
# includes
include_directories(../include/libgps++ ../include)
link_directories(../lib)
link_libraries(gps++ net++ net kmlbase kmldom kmlengine pthread rt)
# executables
add_executable(${TARGET} ${TARGET}.cpp)

49
tests/gps/gps_test.cpp Normal file
View File

@ -0,0 +1,49 @@
//
// GPS Daemon
// Neal Probert
//
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <strings.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#include <time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/wait.h>
#include <arpa/inet.h>
#include "GpsPoint.h"
#include "GpsListener.h"
#include "netlib.h"
extern int optind, opterr, optopt;
int main(int argc, char **argv)
{
// point for extrapolations
GpsPoint Gps;
Gps.SetPosition( 42.0, -83.0, 0.0 );
// data from vehicle
GpsPoint CarFix;
CarFix.Speed = 25.0;
CarFix.Yaw = 45.0;
// time stamp, begin 100msec position extrapolations (9 of them)
for ( int i=1 ; i<11 ; i++ )
{
Gps.Extrapolate( CarFix.Speed, 0.0, CarFix.Yaw, 0.100 );
// new fix
double dist = GpsMath::Distance( 42.0, -83.0, Gps.GetLatitude(), Gps.GetLongitude() );
printf( "%.7g, %.7g, %g\n", Gps.GetLatitude(), Gps.GetLongitude(), dist );
}
}

1
tests/include Symbolic link
View File

@ -0,0 +1 @@
../include

1
tests/lib Symbolic link
View File

@ -0,0 +1 @@
../lib

12
tests/nmea/CMakeLists.txt Normal file
View File

@ -0,0 +1,12 @@
cmake_minimum_required(VERSION 3.10)
set(NAME nmea)
project(Cnomicon-Test)
set(TARGET ${NAME}_test)
# includes
include_directories(../include/libgps++ ../include)
link_directories(../lib)
link_libraries(gps++ net++ net kmlbase kmldom kmlengine pthread rt)
# executables
add_executable(${TARGET} ${TARGET}.cpp)

91
tests/nmea/nmea_test.cpp Normal file
View File

@ -0,0 +1,91 @@
//
// GPS Daemon
// Neal Probert
//
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <strings.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#include <time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/wait.h>
#include <arpa/inet.h>
#include "NmeaParser.h"
#include "netlib.h"
extern int optind, opterr, optopt;
//
// Written because gpsd (http://gpsd.berlios.de/) is too fat
//
static const char *msg[] = {
// from web examples
"$GPGLL,3751.65,S,14507.36,E*77\r\n",
"$GPGLL,4916.45,N,12311.12,W,225444,A\n",
"$GPGSA,A,3,,,,,,16,18,,22,24,,,3.6,2.1,2.2*3C\n",
"$GPGSA,A,3,19,28,14,18,27,22,31,39,,,,,1.7,1.0,1.3*34\n",
"$GPGST,024603.00,3.2,6.6,4.7,47.3,5.8,5.6,22.0*58\n",
"$GPGSV,3,1,11,03,03,111,00,04,15,270,00,06,01,010,00,13,06,292,00*74\n",
"$GPGSV,1,1,13,02,02,213,,03,-3,000,,11,00,121,,14,13,172,05*62\n",
"$GPRMC,081836,A,3751.65,S,14507.36,E,000.0,360.0,130998,011.3,E*62\n",
"$GPRMC,225446,A,4916.45,N,12311.12,W,000.5,054.7,191194,020.3,E*68\n",
"$GPRMC,220516,A,5133.82,N,00042.24,W,173.8,231.8,130694,004.2,W*70\n",
"$GPVTG,360.0,T,348.7,M,000.0,N,000.0,K*43\n",
"$GPZDA,024611.08,25,03,2002,00,00*6A\n",
// real examples (u-Blox)
"$GPRMC,195042.00,A,4227.99355,N,08323.70161,W,0.000,-69.23,270307,,,E*6A\n",
"$GPVTG,-69.23,T,,M,0.000,N,0.000,K,E*2A\n",
"$GPGGA,195042.00,4227.99355,N,08323.70161,W,6,6,1.43,262.3,M,-34.1,M,,*57\n",
"$GPGSA,A,E,24,29,26,18,09,10,,,,,,,2.58,1.43,2.15*73\n",
"$GPGSV,3,1,12,24,56,138,39,29,39,048,41,26,51,051,45,21,78,286,28*7A\n",
"$GPGSV,3,2,12,18,50,288,33,09,26,144,37,07,22,212,,22,19,274,*72\n",
"$GPGSV,3,3,12,10,07,082,37,06,15,198,,03,10,319,,33,08,105,34*72\n",
"$GPGLL,4227.99355,N,08323.70161,W,195042.00,A,E*7F\n",
"$GPGST,195042.00,1.9,,,,50,50,3.5*7C\n",
"$GPZDA,195042.00,27,",
"03,2007,00,00*6E\n",
NULL
};
int main(int argc, char **argv)
{
NmeaParser Nmea;
int failed = 0;
printf( "Starting NMEA Parser tests:\n" );
for ( int i=0 ; msg[i] ; i++ )
{
printf( "%s", msg[i] );
int flag = Nmea.NmeaParse( msg[i], strlen(msg[i]) );
if ( flag < 0 )
failed++;
if ( flag > 0 )
printf( "\tpassed\n" );
else if ( flag < 0 )
printf( "\tfailed\n" );
}
if ( failed )
printf( "FAILED: %d tests failed!\n", failed );
else
printf( "SUCCESS: All tests passed!\n" );
return 0;
}

12
tests/uri/CMakeLists.txt Normal file
View File

@ -0,0 +1,12 @@
cmake_minimum_required(VERSION 3.7)
set(NAME uri)
project(Cnomicon-Test)
set(TARGET ${NAME}_test)
# includes
include_directories(../include/libgps++ ../include/libnet++ ../include)
link_directories(../lib)
link_libraries(gps++ net++ net kmlbase kmldom kmlengine pthread rt)
# executables
add_executable(${TARGET} ${TARGET}.cpp)

35
tests/uri/uri_test.cpp Normal file
View File

@ -0,0 +1,35 @@
#include <stdio.h>
#include "UriParse.h"
int main( int argc, char *argv[] )
{
for ( int i=1 ; i<argc ; i++ )
{
UriParse uri;
printf( "Parsing: %s\n", argv[i] );
int n = uri.setUri( argv[i] );
if ( n > 0 )
{
printf( "\tparsed out %d fields\n", n );
printf( "\tproto: %s\n", uri.getProto() ); // scheme
printf( "\tuser: %s\n", uri.getUser() );
printf( "\tpass: %s\n", uri.getPassword() );
printf( "\thost: %s\n", uri.getHost() );
printf( "\tport: %s\n", uri.getService() );
printf( "\tpath: %s\n", uri.getPath() );
printf( "\trate: %d\n", uri.getRate() );
}
else
{
printf( "\tfailed!\n" );
}
printf( "\n" );
}
return 0;
}