Skip to content

Instantly share code, notes, and snippets.

@jplattel
Created June 3, 2012 11:08
Show Gist options
  • Save jplattel/2863058 to your computer and use it in GitHub Desktop.
Save jplattel/2863058 to your computer and use it in GitHub Desktop.
Zeo-raw data to CSV
# Imports
from ZeoRawData.BaseLink import BaseLink
from ZeoRawData.Parser import Parser
from websocket import create_connection
def eventCallback(self, timestamp, version, event):
print event
def sliceCallback(slice):
if slice['BadSignal'] == True:
print 'Bad Signal'
if slice['Waveform'] is not []:
wave = []
for w in slice['Waveform']:
wave.append(str(w))
print w
f.write(",".join(wave) + '\r\n')
print 'Sending Waveform'
else:
print 'Empty waveform... Bad signal'
# Initialize
f = open('signals.csv', 'a')
port= "/dev/tty.usbserial-FTF6GQ0A"
link = BaseLink(port)
parser = Parser()
print "Zeo Connected."
# Add the Parser to the BaseLink's callback
link.addCallback(parser.update)
print "Raw data input initialized."
# Add your callback functions
parser.addEventCallback(eventCallback)
parser.addSliceCallback(sliceCallback)
# Start link
print "Start reading data: "
link.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment