-
-
Save tfcollins/c60f9d360454dfec3f87e3024a760d3f to your computer and use it in GitHub Desktop.
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/python3 | |
# ADRV9002 initialize.c -> stream.bin generator | |
# This is only necessary for TES pre v0.14. | |
import os.path | |
from os import path | |
list = [] | |
if not path.exists("initialize.c"): | |
raise Exception("initialize.c not found in local folder") | |
with open("initialize.c", "r") as text: | |
data = text.read() | |
# Find stream array | |
loc = data.find('uint8_t binary_6') | |
if not loc: | |
raise Exception("Stream array not found in initialize.c") | |
data = data[loc:] | |
data = data[data.find('{')+1:data.find('}')] | |
# we expect the array to be a comma separated list | |
data = data.replace(' ', '').replace('\n', '') | |
data = data.split(",") | |
# convert to int | |
list = [int(val) for val in data] | |
with open("stream.bin", 'wb') as file: | |
for val in list: | |
file.write(bytes([val])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment