Fehlerkorrektur; Umstellen auf externen SQL-Server; Umstellen auf xz;MAC-Addresse als weiteres Feld

master
ademant 2018-09-02 09:37:12 +02:00
parent e407cabcdb
commit 456bf77888
4 changed files with 49 additions and 53 deletions

View File

@ -7,29 +7,29 @@ for i in $(find /tmp -name "gps_*.*"|cut -d/ -f3|cut -d\. -f1|sort -u); do
done
#echo $fl|xargs -P4 -n1 bunzip2 -k
for i in $fl; do
bunzip2 $i
j=$(basename $i .bz2)
cat /tmp/$j|grep RMC|grep -v ,,|cut -d, -f2- |bzip2 -9 >> /tmp/${pid}.rmc.bz2
cat /tmp/$j|grep GSV|cut -d, -f2- |bzip2 -9 >> /tmp/${pid}.gsv.bz2
cat /tmp/$j|grep GSA|cut -d, -f2- |bzip2 -9 >> /tmp/${pid}.gsa.bz2
cat /tmp/$j|grep GST|cut -d, -f2- |bzip2 -9 >> /tmp/${pid}.gst.bz2
cat /tmp/$j|grep GGA|cut -d, -f2- |bzip2 -9 >> /tmp/${pid}.gga.bz2
unxz $i
j=$(basename $i .xz)
cat /tmp/$j|grep RMC|grep -v ,,|cut -d, -f2- |xz -9 >> /tmp/${pid}.rmc.xz
cat /tmp/$j|grep GSV|cut -d, -f2- |xz -9 >> /tmp/${pid}.gsv.xz
cat /tmp/$j|grep GSA|cut -d, -f2- |xz -9 >> /tmp/${pid}.gsa.xz
cat /tmp/$j|grep GST|cut -d, -f2- |xz -9 >> /tmp/${pid}.gst.xz
cat /tmp/$j|grep GGA|cut -d, -f2- |xz -9 >> /tmp/${pid}.gga.xz
rm /tmp/$j
done
bunzip2 /tmp/${pid}.rmc.bz2
mysql -u gps -pgps -D gps -e "load data local infile '/tmp/${pid}.rmc' into table gpsrmc fields terminated by ',' enclosed by ';' (epoch,uid,system,fix,utc,breite,laenge,velocity,course);"
unxz /tmp/${pid}.rmc.xz
mysql -h 10.8.0.14 -u gps -pgps -D gps -e "load data local infile '/tmp/${pid}.rmc' into table gpsrmc fields terminated by ',' enclosed by ';' (epoch,mac,uid,system,fix,utc,breite,laenge,velocity,course);"
rm /tmp/${pid}.rmc
bunzip2 /tmp/${pid}.gsv.bz2
mysql -u gps -pgps -D gps -e "load data local infile '/tmp/${pid}.gsv' into table gpsgsv fields terminated by ',' enclosed by ';' (epoch,uid,system,prn,elevation,azimuth,snr);"
unxz /tmp/${pid}.gsv.xz
mysql -h 10.8.0.14 -u gps -pgps -D gps -e "load data local infile '/tmp/${pid}.gsv' into table gpsgsv fields terminated by ',' enclosed by ';' (epoch,mac,uid,system,prn,elevation,azimuth,snr);"
rm /tmp/${pid}.gsv
bunzip2 /tmp/${pid}.gsa.bz2
mysql -u gps -pgps -D gps -e "load data local infile '/tmp/${pid}.gsa' into table gpsgsa fields terminated by ',' enclosed by ';' (epoch,uid,system,pdop,hdop,vdop);"
unxz /tmp/${pid}.gsa.xz
mysql -h 10.8.0.14 -u gps -pgps -D gps -e "load data local infile '/tmp/${pid}.gsa' into table gpsgsa fields terminated by ',' enclosed by ';' (epoch,mac,uid,system,pdop,hdop,vdop);"
rm /tmp/${pid}.gsa
bunzip2 /tmp/${pid}.gst.bz2
mysql -u gps -pgps -D gps -e "load data local infile '/tmp/${pid}.gst' into table gpsgst fields terminated by ',' enclosed by ';' (epoch,uid,system,rms,errmaj,errmin,error,sig_lat,sig_lon,sig_height);"
unxz /tmp/${pid}.gst.xz
mysql -h 10.8.0.14 -u gps -pgps -D gps -e "load data local infile '/tmp/${pid}.gst' into table gpsgst fields terminated by ',' enclosed by ';' (epoch,mac,uid,system,rms,errmaj,errmin,error,sig_lat,sig_lon,sig_height);"
rm /tmp/${pid}.gst
bunzip2 /tmp/${pid}.gga.bz2
mysql -u gps -pgps -D gps -e "load data local infile '/tmp/${pid}.gga' into table gpsgga fields terminated by ',' enclosed by ';' (epoch,uid,system,sats,hdop,hoehe,geoid);"
unxz /tmp/${pid}.gga.xz
mysql -h 10.8.0.14 -u gps -pgps -D gps -e "load data local infile '/tmp/${pid}.gga' into table gpsgga fields terminated by ',' enclosed by ';' (epoch,mac,uid,system,sats,hdop,hoehe,geoid);"
rm /tmp/${pid}.gga
#rm /tmp/${pid}.*

View File

@ -3,49 +3,44 @@ BEGIN {FS =","
OFS=","}
/RMC/ {
gsub(/\./,"",$1)
# gsub(/ \$/,"",$4)
split($3,tel,"$")
gsub(/^0/,"",$10)
split($4,zeit,".")
split($6,w,".")
# gsub(/ \$/,"",$5)
split($4,tel,"$")
gsub(/^0/,"",$11)
split($5,zeit,".")
split($7,w,".")
for(i=length(w[2]);i<6;i++)w[2]=w[2] "0";
deg=substr(w[1],1,length(w[1])-2)*60+substr(w[1],length(w[1])-1,2)
ndeg=""
if($7=="S")ndeg="-"
split($8,l,".")
if($8=="S")ndeg="-"
split($9,l,".")
for(i=length(l[2]);i<6;i++)l[2]=l[2] "0";
ldeg=substr(l[1],1,length(l[1])-2)*60+substr(l[1],length(l[1])-1,2)
nldeg=""
if($9=="W")nldeg="-"
utc=mktime("20"substr($12,5,2)" "substr($12,3,2)" "substr($12,1,2)" "substr($4,1,2)" "substr($4,3,2)" "substr($4,5,2))
if($11=="")$11=0
if($10=="W")nldeg="-"
utc=mktime("20"substr($13,5,2)" "substr($13,3,2)" "substr($13,1,2)" "substr($5,1,2)" "substr($5,3,2)" "substr($5,5,2))
if($12=="")$12=0
# print "RMC",$1,$3,substr($4,2,1),zeit[1]+0,ndeg deg w[2],nldeg ldeg l[2],$11*1000,$12
print "RMC",$1,$2,substr(tel[2],2,1),zeit[1]+0,utc,ndeg deg w[2],nldeg ldeg l[2],$10*1000,$11
print "RMC",$1,$2,$3,substr(tel[2],2,1),zeit[1]+0,utc,ndeg deg w[2],nldeg ldeg l[2],$11*1000,$12+0
}
/GGA/ {gsub(/\./,"",$1);gsub(/ \$/,"",$3);gsub(/^0/,"",$10);split($4,ts,".");gsub(/^0/,"",$7)
print "GGA",$1,$2,substr($3,2,1),$10,$11*1000,$12*1000,$14*1000
/GGA/ {gsub(/\./,"",$1);gsub(/ \$/,"",$4);gsub(/^0/,"",$11);split($5,ts,".");gsub(/^0/,"",$8)
print "GGA",$1,$2,$3,substr($4,2,1),$11,$12*1000,$13*1000,$15*1000
}
/GSA/ {gsub(/\./,"",$1);gsub(/ \$/,"",$3)
print "GSA",$1,$2,substr($3,2,1),$18*1000,$19*1000,$20*1000
/GSA/ {gsub(/\./,"",$1);gsub(/ \$/,"",$4)
print "GSA",$1,$2,$3,substr($4,2,1),$19*1000,$20*1000,$21*1000
}
/GSV/ {gsub(/\./,"",$1);gsub(/ \$/,"",$3)
# bp=0
/GSV/ {gsub(/\./,"",$1);gsub(/ \$/,"",$4)
for(i=1;i<=4;i++){
if(i*4+6<NF){
if(i*4+7<NF){
bp=1
# if(i==1){print "insert into gpsgsv (epoch,uid,system,prn,elevation,azimuth,snr) values "}
# if(i>1){print ","}
if(length($(i*4+6))==0){$(i*4+6)=0}
if($(i*4+6)=="\r"){$(i*4+6)=0}
print "GSV",$1,$2,substr($3,2,1),$(4*i+3)+0,$(4*i+4)+0,$(4*i+5)+0,$(4*i+6)+0
if(length($(i*4+7))==0){$(i*4+7)=0}
if($(i*4+7)=="\r"){$(i*4+7)=0}
print "GSV",$1,$2,$3,substr($4,2,1),$(4*i+4)+0,$(4*i+5)+0,$(4*i+6)+0,$(4*i+7)+0
}
}
# if(bp==1){print ";"}
}
# }
/GST/ {
gsub(/\./,"",$1)
split($4,zeit,".")
gsub(/ \$/,"",$3)
print "GST",$1,$2,substr($3,2,1),$5+0,$6+0,$7+0,$8+0,$9*1000,$10*1000,$11*1000
split($5,zeit,".")
gsub(/ \$/,"",$4)
print "GST",$1,$2,$3,substr($4,2,1),$6+0,$7+0,$8+0,$9+0,$10*1000,$11*1000,$12*1000
}

View File

@ -5,7 +5,7 @@ STTY=$(echo $1|sed -e 's/tty//g')
if [ ! -f /tmp/${TTY}.pid ]; then
id=
echo $$ > /tmp/${TTY}.pid
mac=$(printf "%d\n" 0x$(cat $(find /sys/class/net -name "en*" |head -n1)/address|tr -d ':'))
uid=$(echo $(udevadm info --name=/dev/${TTY}|sed -n '/MAJOR/{s/[A-Z: =]*//;p}')*256+$(udevadm info --name=/dev/${TTY}|sed -n '/MINOR/{s/[A-Z: =]*//;p}')|bc)
vendor=$(udevadm info --name=/dev/${TTY}|sed -n '/VENDOR=/{s/[A-Z:_ =]*//;p}')
serial=$(udevadm info --name=/dev/${TTY}|sed -n '/SERIAL=/{s/[A-Z:_ =]*//;p}')
@ -14,5 +14,6 @@ if [ ! -f /tmp/${TTY}.pid ]; then
# cat /dev/${TTY}|unbuffer -p tr -dc "[:print:]\n"|ts %.s,${STTY},${uid},|unbuffer -p sed -e 's/*..//g'|/home/pi/gps/gps_pre_sql.awk| $(mysql -u gps -D gps -pgps --batch )
# cat /dev/${TTY}|unbuffer -p tr -dc "[:print:]\n"|ts %.s,${STTY},${uid},|unbuffer -p sed -e 's/*..//g'|/home/pi/gps/gps_pre.awk|split -a12 -l1000 - /tmp/gps_${uid}. --filter='gzip -9 > $FILE.gz'
tr -dc "[:print:]\n" < /dev/${TTY} |ts %.s,${uid},|unbuffer -p sed -e 's/*..//g'|/home/pi/gps/gps_pre.awk|split -a12 -l1000 - /tmp/gps_${uid}. --filter='bzip2 -9 > $FILE.bz2'
# tr -dc "[:print:]\n" < /dev/${TTY} |ts %.s,${uid},|unbuffer -p sed -e 's/*..//g'|/home/pi/gps/gps_pre.awk|split -a12 -l1000 - /tmp/gps_${uid}. --filter='bzip2 -9 > $FILE.bz2'
tr -dc "[:print:]\n" < /dev/${TTY} |ts %.s,${mac},${uid},|unbuffer -p sed -e 's/*..//g'|/home/pi/gps/gps_pre.awk|split -a12 -l10000 - /tmp/gps_${uid}. --filter='xz -9 > $FILE.xz'
fi

View File

@ -1,10 +1,10 @@
#!/bin/sh
mysql -u gps -pgps -D gps -e "create table if not exists gps.gpstty (epoch bigint,uid integer,vendor varchar(20),serial varchar(40),path varchar(30), index(epoch,uid));"
mysql -u gps -pgps -D gps -e "create table if not exists gps.gpsrmc (epoch bigint,uid integer,system char(1),fix integer,breite bigint,laenge bigint,velocity integer,course integer, utc bigint, index(uid,epoch,breite,laenge));"
mysql -u gps -pgps -D gps -e "create table if not exists gps.gpsgsv (epoch bigint,uid integer,system char(1),prn smallint,elevation tinyint,azimuth smallint,snr tinyint, index(uid,epoch,prn));"
mysql -u gps -pgps -D gps -e "create table if not exists gps.gpsgga (epoch bigint,uid integer,system char(1),fix integer,sats tinyint,hdop integer,hoehe bigint,geoid integer, index(uid,epoch,hoehe));"
mysql -u gps -pgps -D gps -e "create table if not exists gps.gpsgsa (epoch bigint,uid integer,system char(1),pdop integer,hdop integer,vdop integer, index(uid,epoch,hdop,vdop,pdop));"
mysql -u gps -pgps -D gps -e "create table if not exists gps.gpsgst (epoch bigint,uid integer,system char(1),rms bigint,errmaj integer,errmin integer,error integer,sig_lat integer,sig_lon integer,sig_height integer, index(uid,epoch,sig_lat,sig_lon,sig_height));"
mysql -h 10.8.0.14 -u gps -pgps -D gps -e "create table if not exists gps.gpstty (epoch bigint,mac bigint,uid integer,vendor varchar(20),serial varchar(40),path varchar(30), index(epoch,uid));"
mysql -h 10.8.0.14 -u gps -pgps -D gps -e "create table if not exists gps.gpsrmc (epoch bigint,mac bigint,uid integer,system char(1),fix integer,breite bigint,laenge bigint,velocity integer,course integer, utc bigint, index(uid,epoch,breite,laenge));"
mysql -h 10.8.0.14 -u gps -pgps -D gps -e "create table if not exists gps.gpsgsv (epoch bigint,mac bigint,uid integer,system char(1),prn smallint,elevation tinyint,azimuth smallint,snr tinyint, index(uid,epoch,prn));"
mysql -h 10.8.0.14 -u gps -pgps -D gps -e "create table if not exists gps.gpsgga (epoch bigint,mac bigint,uid integer,system char(1),fix integer,sats tinyint,hdop integer,hoehe bigint,geoid integer, index(uid,epoch,hoehe));"
mysql -h 10.8.0.14 -u gps -pgps -D gps -e "create table if not exists gps.gpsgsa (epoch bigint,mac bigint,uid integer,system char(1),pdop integer,hdop integer,vdop integer, index(uid,epoch,hdop,vdop,pdop));"
mysql -h 10.8.0.14 -u gps -pgps -D gps -e "create table if not exists gps.gpsgst (epoch bigint,mac bigint,uid integer,system char(1),rms bigint,errmaj integer,errmin integer,error integer,sig_lat integer,sig_lon integer,sig_height integer, index(uid,epoch,sig_lat,sig_lon,sig_height));"
#mysql -u gps -pgps -D gps -e "create table if not exists gps.gpsin (uid integer, id bigint, epoch bigint, telegram char(5),payload varchar(160),raw tinyint, index (uid,id,epoch,telegram,raw));"
#mysql -u gps -pgps -D gps -e "create table if not exists gps.gpsrmc (uid integer, id bigint, epoch bigint, breite bigint,laenge bigint,velocity integer,fix char(1),system char(1),fix_epoch integer,raw tinyint, index (uid,id,epoch,breite,laenge));"