Post Reply 
Hand Held Products 71M/M eprom carrier question
09-09-2020, 03:56 AM
Post: #25
RE: Hand Held Products 71M/M eprom carrier question
(09-08-2020 05:32 PM)Albert Chan Wrote:  > echo 0:B3DDDDDEE4642513 | sed -f swap_flip.sed
0: C4 22 22 12 B1 B9 AD CE

Here is the equivalent Python code.
This work slightly better, and handled 'colon-less' format correctly.

> echo B3DDDDDEE4642513 | python swap_flip.py
C4 22 22 12 B1 B9 AD CE

Code:
import sys, string
flip = string.maketrans('0123456789ABCDEFabcdef','FEDCBA9876543210543210')

for line in sys.stdin:
    i, j = line.find(':'), line.find('  ')
    s = line[i+1:j].translate(flip, ' ')    # flipped hexdigits only
    print line[:i+1], ' '.join(s[i:i-2:-1] for i in range(1-len(s),0,2))
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Hand Held Products 71M/M eprom carrier question - Albert Chan - 09-09-2020 03:56 AM



User(s) browsing this thread: 6 Guest(s)