From 4670710d378ebddd7eb26a96f6133f36cc613c12 Mon Sep 17 00:00:00 2001 From: chrishoder Date: Sun, 20 Jan 2013 03:36:07 +0000 Subject: [PATCH] updated file management for the data gathering and upload to database git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@1392 12e2690d-a6be-4b82-a7b7-67c4a43b65c8 --- client/GoodFETMCPCANCommunication.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/client/GoodFETMCPCANCommunication.py b/client/GoodFETMCPCANCommunication.py index f555e47..609bf88 100644 --- a/client/GoodFETMCPCANCommunication.py +++ b/client/GoodFETMCPCANCommunication.py @@ -22,18 +22,15 @@ from intelhex import IntelHex; class GoodFETMCPCANCommunication: - def __init__(self, filename=None): + def __init__(self): self.client=GoodFETMCPCAN(); self.client.serInit() self.client.MCPsetup(); - - if( filname == None): - # create a filename with today's date - now = datetime.datetime.now() - self.filename = "../../contrib/ThayerData/" - self.filename += now.strftime("%Y%m%d") - else: - self.filename=filename + + # create a filename with today's date + now = datetime.datetime.now() + self.filename = "../../contrib/ThayerData/" + self.filename += now.strftime("%Y%m%d") ########################## # INFO @@ -65,9 +62,11 @@ class GoodFETMCPCANCommunication: def reset(self): self.client.MCPsetup(); - def sniff(self,freq,duration,description, verbose=True, comment=None): + def sniff(self,freq,duration,filename,description, verbose=True, comment=None): + if(filename=None): + filename=self.filename self.client.MCPsetrate(freq); - outfile = open(self.filename,'a'); + outfile = open(filename,'a'); dataWriter = csv.writer(outfile,delimiter=','); dataWriter.writerow(['# Time Error Bytes 1-13']); dataWriter.writerow(['#' + description]) @@ -264,7 +263,7 @@ if __name__ == "__main__": parser.add_argument('verb', choices=['info', 'test','peek', 'reset', 'sniff', 'freqtest','snifftest', 'spit']); parser.add_argument('-f', '--freq', type=int, default=500, help='The desired frequency (kHz)', choices=[100, 125, 250, 500, 1000]); parser.add_argument('-t','--time', type=int, default=15, help='The duration to run the command (s)'); - parser.add_argument('-o', '--output', default="../../contrib/ted/sniff_out.csv",help='Output file'); + parser.add_argument('-o', '--output', default=None, elp='Output file'); parser.add_argument("-d", "--description", help='Description of experiment (included in the output file)', default=""); parser.add_argument('-v',"--verbose",action='store_false',help='-v will stop packet output to terminal', default=True); parser.add_argument('-c','--comment', help='Comment attached to ech packet uploaded',default=None); -- 2.20.1