-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added python script that generates random UID header file for testing
- Loading branch information
1 parent
4513052
commit c84a514
Showing
2 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
########### | ||
# Generate UID Test in C Header File | ||
# | ||
########### | ||
|
||
import string | ||
import random | ||
import pickle | ||
|
||
setSize = 500 | ||
uniqueLen = 7 | ||
|
||
uniqueSet = [] | ||
|
||
print "Generating Set" | ||
while (len(uniqueSet) < setSize): | ||
if len(uniqueSet)%50 == 49: | ||
print str(len(uniqueSet)+1) + " values have been generated" | ||
thisUID = [] | ||
for i in range(7): | ||
thisUID.append(random.choice(range(0xFF))) | ||
if thisUID not in uniqueSet: | ||
print thisUID | ||
uniqueSet.append(thisUID) | ||
|
||
print "Generating PROGMEM array as uniqueSet.h" | ||
with open('uniqueSet.h', 'w') as f: | ||
f.write("//THIS IS FOR TESTING ONLY!!!!!!\n\n") | ||
f.write("unsigned int uniqueSetLen = " + str(setSize) + ";\n\n") | ||
f.write("unsigned char uniqueSet[" + str(setSize)*uniqueLen + "] PROGMEM = {\n") | ||
for i in range(len(uniqueSet)): | ||
outStr = " " | ||
for d in range(6): | ||
outStr += "0x{:02x}".format(uniqueSet[i][d]).upper().replace("X","x") + ", " | ||
|
||
outStr += "0x{:02x}".format(uniqueSet[i][6]).upper().replace("X","x") | ||
if (i == (len(uniqueSet)-1)): | ||
outStr += "\n" | ||
else: | ||
outStr += ",\n" | ||
f.write(outStr) | ||
f.write("};\n") | ||
|