License GNU General Public License, version 3
Lines 45
Included in this Library
Permissions
Owner: wildintellect
Viewable by Everyone
Editable by All Siafoo Users
Hide
Siafoo is here to make coding less frustrating and to save you time. Join Siafoo Now or Learn More

rfid.py Atom Feed 0

# 's
 1import sys
2import ctypes
3import winbase
4import ceserial
5import time
6from time import *
7#import exch
8#latin2_decoder = lambda s: str(s) #unicode(s, "iso8859-2", "replace")
9
10def gprmc_test(row_ary):
11 return (row_ary[0] == "$GPRMC") and (row_ary[1]!="") and (row_ary[3]!="") and (row_ary[5]!="")
12
13def get_pos(row_ary):
14 return {'rtime':float(row_ary[1]),'lon':float(row_ary[3]),'lat':float(row_ary[5])}
15
16#def rec_pos(data):
17# cur.execute("insert into coords_rec (rectime,long,lat) values(%f,%f,%f)"%(data['rtime'],data['lon'],data['lat']))
18
19#from sqlite3 import dbapi2 as sqlite
20#con=sqlite.connect("\\SD Card\\work\\cdata.db",isolation_level=None)
21#con.text_factory=latin2_decoder
22#cur=con.cursor()
23
24
25s=ceserial.Serial(port="COM7:",baudrate=4800)
26s.open()
27of=open('\\CF Card\\tmp1.txt',"w")
28rv=s.read(50)
29cnt=0
30c2=0
31while (len(rv)>0) and (cnt<10000) and (c2<5):
32 try:
33 #Adds a timestamp before each line of data, comma separated from rest of line
34 stamp = strftime("\n %d %b %Y %H:%M:%S,",localtime())
35 outline = rv.replace("\n",stamp)
36 of.write(outline)
37 gps_ary=rv.split(',')
38 if (gprmc_test(gps_ary)):
39 # rec_pos(get_pos(gps_ary))
40 print "(%f,%f,%f)"%(rtime,lon,lat)
41 #break
42
43 cnt+=1
44 rv=s.read(50)
45 except Exception, e:
46 c2=c2+1
47 print "%d. exception: "%c2
48 #print exch.formatExceptionInfo()
49
50#con.close()
51of.close()
52s.close()