Skip to content

In principle I love Python, In practice I can never do anything with it

February 15, 2015

Faced with the thousands of lines of logic analyzer trace, i needed a quick and dirty program to consolidate each transaction into a couple of lines with the mosi/miso payload strung out horizontally instead of line to line. Python should be the answer for this. It’s ubiquitous, it’s flexible, it usually does what you want or gives you a readable error message. The trouble is, i can never remember the syntax. It took me hours of dorking around to dredge up the following pathetic fragment which reads the comma separated values and prints the guts. In principle, it’s just a matter of accumulating miso and mosi data until the packet id changes then spitting out one line for each. By now though, I’ve lost all python momentum and loaded the data into excel instead. As it turns out, all i have is the polling transactions, i missed the transaction altogether. I do notice that the arduino code seems to be using socket 1 instead of 0 (read code is 28) instead of 08. Also note that MISO and MOSI are reversed because, of course, i had the wires reversed.

count=0
with open('/Users/bill/Desktop/arduinow5500.csv') as fp:
    for line in fp:
        count=count+1
        parts=line.split(',') #Time [s],Packet ID,MOSI,MISO
        id=parts[1]
        mosi=parts[2]
        miso=parts[3]
        print id,mosi,miso
 
Packet ID MOSI MISO
0 0x01 0x00
0 0x02 0x03
0 0x03 0x28
0 0x14 0x00

1 0x01 0x00
1 0x02 0x03
1 0x03 0x28
1 0x14 0x00

Obligatory XKCD.

Advertisements

From → web server

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: