Bladeren bron

debugging

clementinecomputing 6 jaren geleden
bovenliggende
commit
940b09f509

+ 3 - 0
.gitignore

@@ -11,3 +11,6 @@ paddlemgr
 passdb
 
 *.o
+*.a
+*.so
+*.so.1

+ 4 - 1
server/daemons/avls_server/avls_server.pl

@@ -129,7 +129,8 @@ sub StoreAvls
 
 	my $dbh = DBI->connect($database_path, $database_user, $database_pass)
 		or die "Couldn't connect to database: " . DBI->errstr;
-	my $sth_avls = $dbh->prepare('INSERT INTO avls_data (equip_num, driver, paddle, route, trip, stop, chirp_time, latitude, longitude, heading, velocity) VALUES (?, ?, ?, ?, ?, ?, FROM_UNIXTIME(?), ?, ?, ?, ?)')
+	#my $sth_avls = $dbh->prepare('INSERT INTO avls_data (equip_num, driver, paddle, route, trip, stop, chirp_time, latitude, longitude, heading, velocity) VALUES (?, ?, ?, ?, ?, ?, FROM_UNIXTIME(?), ?, ?, ?, ?)')
+	my $sth_avls = $dbh->prepare('INSERT INTO avls_data (equip_num, driver, paddle, route, trip, stop, chirp_time, latitude, longitude, heading, velocity) VALUES (?, ?, ?, ?, ?, ?, datetime(?, "unixepoch"), ?, ?, ?, ?)')
 		or die "Couldn't prepare statement: " . $dbh->errstr;
 	#store avls data
 	$sth_avls->execute(split("\t", $client_query))  # Execute the query
@@ -205,6 +206,8 @@ my $retry_count = $max_retries;	#number of retries left...
 my $retry_delay = 3;		#number of seconds to wait between retries at binding to our designated IPC address
 my $got_network = 0;		#flag to let us know that we can quit retrying once we have gotten a valid listening socket
 
+$|=1;
+
 while( ($retry_count > 0) && (!$got_network) )
 {
 	try	#Try and allocate a socket, bind it to our IPC address, and set it to listen for connections

+ 13 - 5
server/daemons/billing_server/billing_server.pl

@@ -33,18 +33,20 @@ use POSIX;
 
 use Data::Dumper;
 
-use OrgDB;
+#use OrgDB;
 
 my $ORG = "ORG";
 
-my $database_path = 'DBI:mysql:busdb';
+#my $database_path = 'DBI:mysql:busdb';
+my $database_path = 'DBI:SQLite:dbname=../bus.sqlite';
 my $database_user = '';
 my $database_pass = '';
 
 my $bind_ip  	  = '127.0.0.1';
 my $bind_port	  = 2455;
 
-my $logfile       = '/home/bus/log/billing_log.log';
+#my $logfile       = '/home/bus/log/billing_log.log';
+my $logfile       = './billing_log.log';
 
 sub unix_to_readable_time {
   my $unix_time = shift;
@@ -502,13 +504,15 @@ sub ServerReply
 		
                 my $duplicate_billing_entry=0;
 		try {
-                        $sth = $dbh->prepare('select count(*) num from billing_log where ride_time = FROM_UNIXTIME(?) and conf_checksum = ?') or die "Couldn't prepare statement: " . $dbh->errstr;
+                        #$sth = $dbh->prepare('select count(*) num from billing_log where ride_time = FROM_UNIXTIME(?) and conf_checksum = ?') or die "Couldn't prepare statement: " . $dbh->errstr;
+                        $sth = $dbh->prepare('select count(*) num from billing_log where ride_time = datetime(?, "unixepoch") and conf_checksum = ?') or die "Couldn't prepare statement: " . $dbh->errstr;
                         $sth->execute($client_values[6], $client_query_md5) or die "Couldn't execute statement: " . $sth->errstr;
 
                         $duplicate_billing_entry=1 if ($sth->fetchrow_arrayref->[0] > 0);
 
                         if (!$duplicate_billing_entry) {
-			        $sth = $dbh->prepare('REPLACE INTO billing_log (conf_checksum, equip_num, driver, paddle, route, trip, stop, ride_time, latitude, longitude, action, rule, ruleparam, reason, credential, logical_card_id, cash_value, stop_name) VALUES (?, ?, ?, ?, ?, ?, ?, FROM_UNIXTIME(?), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)')
+			        #$sth = $dbh->prepare('REPLACE INTO billing_log (conf_checksum, equip_num, driver, paddle, route, trip, stop, ride_time, latitude, longitude, action, rule, ruleparam, reason, credential, logical_card_id, cash_value, stop_name) VALUES (?, ?, ?, ?, ?, ?, ?, FROM_UNIXTIME(?), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)')
+			        $sth = $dbh->prepare('REPLACE INTO billing_log (conf_checksum, equip_num, driver, paddle, route, trip, stop, ride_time, latitude, longitude, action, rule, ruleparam, reason, credential, logical_card_id, cash_value, stop_name) VALUES (?, ?, ?, ?, ?, ?, ?, datetime(?, "unixepoch"), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)')
 				        or die "Couldn't prepare statement: " . $dbh->errstr;
 		
 			        $sth->execute($client_query_md5, @client_values[0..16])             # Execute the query
@@ -557,6 +561,10 @@ sub handle_client()
 	
 	while($linebuffer = <CLIENT>) 
 	{
+
+## DEBUG
+print "## billing: $linebuffer\n";
+
                 open LOGFH, ">>$logfile";
                 print LOGFH $linebuffer;
                 close LOGFH;

+ 6 - 1
server/daemons/buspass_server/buspass_server.pl

@@ -30,7 +30,8 @@ use Compress::Zlib;
 
 use POSIX;
 
-my $database_path = 'DBI:mysql:busdb';
+#my $database_path = 'DBI:mysql:busdb';
+my $database_path = 'DBI:SQLite:dbname=../bus.sqlite';
 my $database_user = '';
 my $database_pass = '';
 
@@ -289,6 +290,10 @@ sub handle_client()
 	
 	while($linebuffer = <CLIENT>) 
 	{
+
+## DEBUG
+print "## buspass: $linebuffer\n";
+
 		my ($reply, $hangup_flag) = ServerReply($linebuffer);
 		print CLIENT $reply;
 	

+ 3 - 0
server/daemons/hello_daemon/hello_daemon.pl

@@ -122,6 +122,9 @@ sub handle_client()
 	print CLIENT 'Hello.';
 	
 	close CLIENT;
+
+## debug
+print "...hello\n";
 }
 
 

+ 6 - 1
server/daemons/version_server/version_daemon.pl

@@ -28,7 +28,8 @@ use Fcntl;
 
 use POSIX;
 
-my $database_path = 'DBI:mysql:busdb';
+#my $database_path = 'DBI:mysql:busdb';
+my $database_path = 'DBI:SQLite:dbname=../bus.sqlite';
 my $database_user = '';
 my $database_pass = '';
 
@@ -246,6 +247,10 @@ sub handle_client()
 	
 	while($linebuffer = <CLIENT>) 
 	{
+
+## DEBUG
+print "## version: $linebuffer\n";
+
 		print CLIENT ServerReply($linebuffer);
 	}	#while data from client