Last active
February 12, 2017 23:36
-
-
Save mjbella/aecb54203551b2864c9425c4fdcd5068 to your computer and use it in GitHub Desktop.
Parse the Dynamixel packets out of the csv from Seleae serial analyzer
This file contains 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
#!/usr/bin/env python | |
import sys | |
import os | |
import csv | |
state = 0 | |
count = 0 | |
output = [] | |
with open(sys.argv[1], 'rb') as fh: | |
reader = csv.reader(fh, delimiter=',') | |
for line in reader: | |
#print output | |
if 'Time' in line[0]: | |
continue | |
#print line, state, count | |
time = float(line[0]) | |
if 'Error' in line[3]: | |
output = [] | |
continue | |
if (line[1] == '0xFF') & (state == 0): | |
state = 1 | |
print '~~~~~',time,'~~~~~' | |
print 'found 1st FF' | |
output = [] | |
continue | |
if (line[1] == '0xFF') & (state == 1): | |
print 'found 2nd FF' | |
state = 2 | |
output = [] | |
continue | |
if state == 2: | |
print 'MotorID', line[1] | |
state = 3 | |
continue | |
if state == 3: | |
msglen = int(line[1], 16) | |
print 'message length: ', msglen | |
count = 1 | |
state = 4 | |
continue | |
if state == 4: | |
if count >= msglen: | |
output.append(line[1]) | |
#print line[1] | |
print output | |
state = 0 | |
print "======== EOM ========\n" | |
continue | |
count += 1 | |
output.append(line[1]) | |
#print line[1] | |
continue | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment