Created
June 3, 2012 11:08
-
-
Save jplattel/2863058 to your computer and use it in GitHub Desktop.
Zeo-raw data to CSV
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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