Skip to content

Instantly share code, notes, and snippets.

@tfcollins
Created January 20, 2021 23:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tfcollins/c60f9d360454dfec3f87e3024a760d3f to your computer and use it in GitHub Desktop.
Save tfcollins/c60f9d360454dfec3f87e3024a760d3f to your computer and use it in GitHub Desktop.
#!/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