项目概述:
用户通过浏览器选择一个文件来导入数据。然后,我解包二进制文件。然后,我将新解包的数据保存为.csv文件,以便以后在excel中查看数据。用户当前通过键入新文件名来创建文件名。然后我继续用matplotlib库绘制所有数据。在
整个代码:#import Gnuplot
import struct
#import binascii
import csv
import matplotlib.pyplot as plt
import os.path
import pylab as pl
from Tkinter import Tk
from tkFileDialog import askopenfilename
#print "testing"
#data = '$'
#data2 = '7'
#out = ord(data)*256 + ord(data2)
#print out
'''
open_path = "/media/6265-D02D/"
fname = raw_input('Enter the file name you want to open (without the entire filepath)(include filetype ex. .txt): ')
#combines open_path with fname
entirepath = os.path.join(open_path, fname)
f = open(entirepath, 'r')
'''
#This opens the file browser inorder to the user to
#choose the file that they want to decipher
Tk().withdraw() '''we don't want a full GUI, so keep the root
window from appearing.
-This opens the filebrowser'''
filename1 = askopenfilename()
f = open(filename1 'r')
time = []
pitch = []
roll = []
yaw = []
p_rate = []
r_rate = []
y_rate = []
motor0 = []
motor1 = []
motor2 = []
motor3 = []
alt = []
thr_in = []
pitch_in = []
roll_in = []
yaw_in = []
byte_count = 50
s = struct.Struct('>3s I h h h h h h h h h h I h h h h s')
while True:
temp_data = []
unpacked_date = []
temp_data = f.read(40)
byte_count = len(temp_data)
if byte_count <40:
break
unpacked_data = s.unpa