Commit 86855a7f2ccf6921b8b60013db23448114460d88

Authored by Raymond Bakke Pedersen
1 parent b9c84850

Skriver til fil og laster opp til nett

Showing 1 changed file with 37 additions and 5 deletions   Show diff stats
serialrx
... ... @@ -21,17 +21,49 @@ ser = serial.Serial("/dev/ttyS0")
21 21 while(1):
22 22 d_in=ser.readline().decode('ascii')
23 23 d_in = d_in.split(',')
24   -
  24 +
25 25 if d_in[0]==("$GPRMC"):#GPS
26 26 if d_in[2]=='A':
27   - print(d_in)
  27 + now = d_in[9]
  28 + tid = d_in[1]
  29 + time = tid[:2]
  30 + min = tid[2:4]
  31 + ar = now[3:]
  32 + mane=now[1:3]
  33 + dag = now[:1]
  34 + timezone = ("CET")
  35 + print('{}.{}.{}-{}:{} {}'.format(ar,mane,dag,time,min,timezone))
  36 + oclock = ('{}.{}.{}-{}:{} {}'.format(ar,mane,dag,time,min,timezone))
  37 +
  38 + latitude=d_in[3]
  39 + ltdg =latitude[:2]
  40 + ldg=float(ltdg)
  41 + lmdg=(latitude[2:])
  42 + limdg=float(lmdg)
  43 + lfddg=ldg+(limdg/60)
  44 + print('{},{}'.format(lfddg, d_in[4]))
  45 + lat = ('{}'.format(lfddg))
  46 +
  47 + longtitude=d_in[5]
  48 + lotdg =longtitude[:3]
  49 + lodg=float(lotdg)
  50 + lomdg=longtitude[3:]
  51 + loimdg=float(lomdg)
  52 + lofddg=lodg+(loimdg/60)
  53 + print('{},{}'.format(lofddg, d_in[6]))
  54 + lon = ('{}'.format(lofddg))
28 55  
  56 + GPIO.output(out_b, 1)
29 57 if GPIO.input(in_a):
30   - f = open ('pos','a')
31   - tilfil = d_in[3]+'\t'+d_in[5]+'\n'
32   - f.write(tilfil)
  58 + f = open ('/var/www/html/index.html','a')
  59 +# tilfil = d_in[3]+'\t'+d_in[5]+'\n'
  60 + locInfo = oclock + '\n' + lat + '\t' + lon +'\n'
  61 + f.write(locInfo)
33 62 f.close()
34 63 print("Location saved!")
  64 + GPIO.output(out_a, 1)
  65 + else:
  66 + GPIO.output(out_a, 0)
35 67 else:
36 68 print("ERROR: Data is invalid")
37 69  
... ...