mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-29 22:20:37 +00:00
tool: update python scripts to python3
This commit is contained in:
parent
3404c94120
commit
5c54401929
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Scrape GATT UUIDs from Bluetooth SIG page
|
||||
# https://www.bluetooth.com/specifications/assigned-numbers/company-identifiers
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Scrape GAP Data Types from Bluetooth SIG page
|
||||
# Copyright 2016 BlueKitchen GmbH
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Scrape GATT UUIDs from Bluetooth SIG page
|
||||
# Copyright 2016 BlueKitchen GmbH
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Scrape GATT UUIDs from Bluetooth SIG page
|
||||
# https://www.bluetooth.com/specifications/assigned-numbers/logical-link-control/
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Scrape SDP UUIDs from Bluetooth SIG page
|
||||
# Copyright 2017 BlueKitchen GmbH
|
||||
@ -69,11 +69,11 @@ def remove_newlines(remark):
|
||||
def process_rows(fout, rows, pattern):
|
||||
for row in rows:
|
||||
columns = row.getchildren()
|
||||
name = columns[0].text_content().encode('ascii','ignore')
|
||||
value = columns[1].text_content().encode('ascii','ignore')
|
||||
name = columns[0].text_content().replace(u'\u2013','').replace(u'\u200b','')
|
||||
value = columns[1].text_content().replace(u'\u200b','')
|
||||
remark = ''
|
||||
if (len(columns) > 2):
|
||||
remark = columns[2].text_content().encode('ascii','ignore')
|
||||
remark = columns[2].text_content().replace(u'\u200b','')
|
||||
# skip tbody headers
|
||||
if name in ["Protocol Name", "Service Class Name", "Attribute Name", "UUID Name",
|
||||
"Reserved", 'Reserved for HID Attributes', 'Available for HID Language Strings']:
|
||||
@ -82,6 +82,11 @@ def process_rows(fout, rows, pattern):
|
||||
if value.startswith('(Max value '):
|
||||
continue
|
||||
name = create_pretty_define(name)
|
||||
print(name)
|
||||
if name.endswith("DISPLAY"):
|
||||
for c in name:
|
||||
print("ord %c = 0x%x" % (c, ord(c)))
|
||||
|
||||
# skip duplicate attributes
|
||||
if name in defines:
|
||||
continue
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
# BlueKitchen GmbH (c) 2014
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import glob
|
||||
import re
|
||||
@ -308,7 +308,7 @@ def create_events(events):
|
||||
else:
|
||||
last_variable_length_field_pos = offset
|
||||
if field_type in 'V':
|
||||
if last_variable_length_field_pos >= 0:
|
||||
if last_variable_length_field_pos != '':
|
||||
if offset_is_number:
|
||||
# convert to string
|
||||
offset = '((uint8_t) %u)' % offset
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import sys
|
||||
|
||||
@ -107,8 +107,11 @@ hfile_header_end = """
|
||||
"""
|
||||
|
||||
cfile_header_begin = """
|
||||
#define BTSTACK_FILE__ "btstack_memory.c"
|
||||
|
||||
|
||||
/*
|
||||
* btstack_memory.h
|
||||
* btstack_memory.c
|
||||
*
|
||||
* @brief BTstack memory management via configurable memory pools
|
||||
*
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# BlueKitchen GmbH (c) 2014
|
||||
|
||||
import re
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
import os, sys, getopt, re, pickle
|
||||
|
||||
copyright = """/*
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Convert offical Bluetooth GATT Service definitions into BTstack's .gatt format
|
||||
# Copyright 2016 BlueKitchen GmbH
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Create Makefile.inc file for all source folders
|
||||
# Copyright 2017 BlueKitchen GmbH
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# BlueKitchen GmbH (c) 2014
|
||||
|
||||
# convert log output to PacketLogger format
|
||||
@ -91,7 +91,7 @@ if len(sys.argv) == 1:
|
||||
print('BTstack Console to PacketLogger converter')
|
||||
print('Copyright 2014, BlueKitchen GmbH')
|
||||
print('')
|
||||
print('Usage: ', sys.argv[0], 'asci-log-file.txt [hci_dump.pkgl]')
|
||||
print('Usage: ', sys.argv[0], 'ascii-log-file.txt [hci_dump.pklg]')
|
||||
print('Converted hci_dump.pklg can be viewed with Wireshark and OS X PacketLogger')
|
||||
exit(0)
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# BlueKitchen GmbH (c) 2014
|
||||
|
||||
# primitive dump for PacketLogger format
|
||||
@ -11,9 +11,7 @@
|
||||
# uint8_t type; // 0xfc for note
|
||||
# }
|
||||
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
import datetime
|
||||
|
||||
packet_types = [ "CMD =>", "EVT <=", "ACL =>", "ACL <="]
|
||||
@ -36,14 +34,14 @@ def read_net_32(f):
|
||||
def as_hex(data):
|
||||
str_list = []
|
||||
for byte in data:
|
||||
str_list.append("{0:02x} ".format(ord(byte)))
|
||||
str_list.append("{0:02x} ".format(byte))
|
||||
return ''.join(str_list)
|
||||
|
||||
if len(sys.argv) == 1:
|
||||
print 'Dump PacketLogger file'
|
||||
print 'Copyright 2014, BlueKitchen GmbH'
|
||||
print ''
|
||||
print 'Usage: ', sys.argv[0], 'hci_dump.pklg'
|
||||
print ('Dump PacketLogger file')
|
||||
print ('Copyright 2014, BlueKitchen GmbH')
|
||||
print ('')
|
||||
print ('Usage: ', sys.argv[0], 'hci_dump.pklg')
|
||||
exit(0)
|
||||
|
||||
infile = sys.argv[1]
|
||||
@ -66,10 +64,9 @@ with open (infile, 'rb') as fin:
|
||||
pos = pos + 4 + len
|
||||
time = "[%s.%03u]" % (datetime.datetime.fromtimestamp(ts_sec).strftime("%Y-%m-%d %H:%M:%S"), ts_usec / 1000)
|
||||
if type == 0xfc:
|
||||
print time, "LOG", packet
|
||||
print (time, "LOG", packet.decode('ascii'))
|
||||
continue
|
||||
if type <= 0x03:
|
||||
print time, packet_types[type], as_hex(packet)
|
||||
print (time, packet_types[type], as_hex(packet))
|
||||
except TypeError:
|
||||
print ("Error parsing pklg at offset %u (%x)." % (pos, pos))
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# BlueKitchen GmbH (c) 2017
|
||||
|
||||
# primitive dump for .tlv format
|
||||
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
import datetime
|
||||
|
||||
def read_net_32(f):
|
||||
a = f.read(1)
|
||||
@ -26,14 +23,14 @@ def read_net_32(f):
|
||||
def as_hex(data):
|
||||
str_list = []
|
||||
for byte in data:
|
||||
str_list.append("{0:02x} ".format(ord(byte)))
|
||||
str_list.append("{0:02x} ".format(byte))
|
||||
return ''.join(str_list)
|
||||
|
||||
if len(sys.argv) == 1:
|
||||
print 'Dump TLV file'
|
||||
print 'Copyright 2017, BlueKitchen GmbH'
|
||||
print ''
|
||||
print 'Usage: ', sys.argv[0], 'file.tlv'
|
||||
print ('Dump TLV file')
|
||||
print ('Copyright 2017, BlueKitchen GmbH')
|
||||
print ('')
|
||||
print ('Usage: ', sys.argv[0], 'file.tlv')
|
||||
exit(0)
|
||||
|
||||
infile = sys.argv[1]
|
||||
@ -65,4 +62,3 @@ with open (infile, 'rb') as fin:
|
||||
|
||||
except TypeError:
|
||||
print ("Error parsing tlv at offset %u (%x)." % (pos, pos))
|
||||
|
||||
|
@ -1,10 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# BlueKitchen GmbH (c) 2014
|
||||
|
||||
import glob
|
||||
import re
|
||||
import sys
|
||||
|
||||
import btstack_parser as parser
|
||||
|
||||
print('''
|
||||
@ -361,7 +357,7 @@ def create_event_factory(events, subevents, defines):
|
||||
if not event_supported(event_name):
|
||||
continue
|
||||
class_name = class_name_for_event(event_name)
|
||||
print class_name
|
||||
print(class_name)
|
||||
subcases += java_event_factory_subevent.format(event_type, class_name)
|
||||
|
||||
with open(outfile, 'wt') as fout:
|
||||
|
6
tool/misc/update_copyright.py
Normal file → Executable file
6
tool/misc/update_copyright.py
Normal file → Executable file
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import re
|
||||
|
||||
@ -113,8 +113,10 @@ def requiresCopyrightUpdate(file_name):
|
||||
global copyrightString, onlyDumpDifferentCopyright
|
||||
exactCopyrightFound = False
|
||||
|
||||
with open(file_name, "rb") as fin:
|
||||
with open(file_name, "rt") as fin:
|
||||
print("File: " + file_name)
|
||||
for line in fin:
|
||||
print("Line: " + line)
|
||||
parts = re.match('.*('+copyrightString+').*',line)
|
||||
if parts:
|
||||
exactCopyrightFound = True
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# BlueKitchen GmbH (c) 2018
|
||||
|
||||
import glob
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
import math
|
||||
import sys
|
||||
|
||||
@ -33,8 +33,8 @@ if __name__ == "__main__":
|
||||
print(usage)
|
||||
sys.exit(1)
|
||||
|
||||
sine_num_samples = sine_sample_rate/sine_frequency
|
||||
|
||||
sine_num_samples = int(sine_sample_rate/sine_frequency)
|
||||
print(type(sine_num_samples).__name__)
|
||||
print(sine_array.format(sine_sample_rate=sine_sample_rate, sine_frequency=sine_frequency))
|
||||
items = 0
|
||||
for sample in range(0,sine_num_samples):
|
||||
@ -42,9 +42,9 @@ if __name__ == "__main__":
|
||||
angle = (sample * 360.0) / sine_num_samples
|
||||
sine = math.sin(math.radians(angle))
|
||||
rescaled = int(round(sine * 32767))
|
||||
print ("%6d, " % rescaled),
|
||||
print ("%6d, " % rescaled, end=''),
|
||||
if items == VALUES_PER_LINE:
|
||||
items = 0
|
||||
print
|
||||
print("")
|
||||
|
||||
print( "};")
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import re
|
||||
|
||||
@ -70,7 +70,7 @@ def update_filename_tag(dir_name, file_name, has_tag):
|
||||
|
||||
def get_filename_tag(file_path):
|
||||
basename = os.path.basename(file_path)
|
||||
with open(file_path, "rb") as fin:
|
||||
with open(file_path, "rt") as fin:
|
||||
for line in fin:
|
||||
parts = re.match(filetag_re,line)
|
||||
if not parts:
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Parase and dump UUID128 in various formats
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user