Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion open-lst/tools/openlst_tools/bootload_radio.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

from builtins import range
import os
import argparse
import logging
Expand Down Expand Up @@ -106,7 +107,7 @@ def main():
pass
time.sleep(1.5)
# Load pages
for page in xrange(FLASH_APP_START, FLASH_APP_END + 1, FLASH_PAGE_SIZE):
for page in range(FLASH_APP_START, FLASH_APP_END + 1, FLASH_PAGE_SIZE):
page_number = page // FLASH_PAGE_SIZE
page_data = app_section[page:page + FLASH_PAGE_SIZE]
if all(b == 0xff for b in page_data):
Expand Down
8 changes: 5 additions & 3 deletions open-lst/tools/openlst_tools/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

from __future__ import print_function
import six
import abc
import time
import logging
from threading import Thread, Lock
from Queue import Queue, Empty
from queue import Queue, Empty
from .translator import Translator
from .radio_mux import DEFAULT_RX_SOCKET, DEFAULT_TX_SOCKET

Expand Down Expand Up @@ -52,7 +54,7 @@ class CommandHandler(object):
__metaclass__ = abc.ABCMeta

def __init__(self, hwid):
if isinstance(hwid, basestring):
if isinstance(hwid, six.string_types):
self.hwid = int(hwid, 16)
else:
self.hwid = hwid
Expand Down Expand Up @@ -238,7 +240,7 @@ def flush(self):

def poll_message(self, timeout):
msgs = dict(self.poller.poll(timeout * 1000))
for sock, msg in msgs.iteritems():
for sock, msg in six.iteritems(msgs):
if sock == self.rx:
return self.rx.recv()
return None
4 changes: 2 additions & 2 deletions open-lst/tools/openlst_tools/get_telem.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ def main():

con = get_handler(args.hwid, args.rx_path, args.tx_path)
resp = con.send_cmd("lst get_telem")
print resp
print(resp)
for field, val in zip(TELEM_FIELDS, resp.split()[2:]):
print field, val
print(field, val)

if __name__ == '__main__':
main()
7 changes: 4 additions & 3 deletions open-lst/tools/openlst_tools/intel_hex.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.

from binascii import hexlify
from builtins import range


def parse_hex_file(hex_data, mem_size=0x8000):
Expand All @@ -28,7 +29,7 @@ def parse_hex_file(hex_data, mem_size=0x8000):
It returns a 32KB bytearray with empty/unused bytes set to 0xFF
(flash empty)
"""
outbuff = bytearray(0xff for _ in xrange(mem_size))
outbuff = bytearray(0xff for _ in range(mem_size))
line_count = 0
total_data = 0
for line in hex_data.splitlines():
Expand All @@ -49,7 +50,7 @@ def parse_hex_file(hex_data, mem_size=0x8000):
if record_type == 0: # Data
data = [
int(line[(9 + 2 * i):(9 + 2 * i + 2)], 16)
for i in xrange(byte_count)]
for i in range(byte_count)]
checksum = int(
line[(9 + 2 * byte_count):(9 + 2 * byte_count + 2)],
16)
Expand All @@ -72,7 +73,7 @@ def parse_hex_file(hex_data, mem_size=0x8000):
def dump_hex_file(data, line_size=32, skip_lines=True,
truncate_lines=False):
lines = []
for addr in xrange(0, len(data), line_size):
for addr in range(0, len(data), line_size):
line_data = data[addr:addr + line_size]
if truncate_lines:
line_data = line_data.rstrip('\xff')
Expand Down
3 changes: 2 additions & 1 deletion open-lst/tools/openlst_tools/radio_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

from __future__ import print_function
import os
import argparse
import logging
Expand Down Expand Up @@ -48,7 +49,7 @@ def main():

con = get_handler(args.hwid, args.rx_path, args.tx_path)
resp = con.send_cmd(args.command)
print resp
print(resp)

if __name__ == '__main__':
main()
5 changes: 3 additions & 2 deletions open-lst/tools/openlst_tools/radio_mux.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

from __future__ import print_function
import argparse
import pwd
import grp
Expand All @@ -24,7 +25,7 @@
import zmq
from binascii import hexlify
from threading import Thread, Event, Lock
from Queue import Queue
from queue import Queue

ESP_START_BYTE_0 = '\x22'
ESP_START_BYTE_1 = '\x69'
Expand Down Expand Up @@ -188,7 +189,7 @@ def main():
rtscts=False,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE)
print serial_port
print(serial_port)
zmq_poller = ZMQPoller(
tx_socket=args.tx_socket,
rx_socket=args.rx_socket,
Expand Down
12 changes: 7 additions & 5 deletions open-lst/tools/openlst_tools/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.

from __future__ import print_function
import six
from builtins import input, range
import argparse
import zmq
from blessed import Terminal
Expand Down Expand Up @@ -88,7 +90,7 @@ def _zmq_watcher_thread(self):
self._connect_zmq()
while self.running:
msgs = dict(self.poller.poll(50))
for sock, msg in msgs.iteritems():
for sock, msg in six.iteritems(msgs):
if sock == self.rx:
msg = self.rx.recv()
self.insert_msg("<", self._process_zmq_msg(msg))
Expand All @@ -108,7 +110,7 @@ def _process_zmq_msg(self, msg):

def insert_msg(self, prompt, msg):
''' Clear the current line, print some text, then reprint the line '''
if type(msg) == str:
if isinstance(msg, six.string_types):
msg = bytearray(msg)
if self.raw:
msg = ' '.join('{:02x}'.format(x) for x in msg)
Expand Down Expand Up @@ -146,7 +148,7 @@ def clear_line(self):

def _input_loop(self):
try:
self.user_buffer = raw_input('> ')
self.user_buffer = input('> ')
self._command_preprocessor()
except (KeyboardInterrupt, EOFError):
if readline.get_line_buffer() != '':
Expand Down Expand Up @@ -229,7 +231,7 @@ def _pretty_list_print(l, width=80):
nrow = len(l) / ncol
lrow = len(l) - (nrow * ncol)
pstr = "{{:<{nchar}}}".format(nchar=nchar) * ncol
pstr = "\n".join([pstr for i in xrange(nrow)])
pstr = "\n".join([pstr for i in range(nrow)])
if lrow != 0:
pstr += "\n" + "{{:<{nchar}}}".format(nchar=nchar) * lrow
print(pstr.format(*l))
Expand All @@ -240,7 +242,7 @@ def _navigate_tree(cmd_list, tree):
Last level should be a list '''
cmd = cmd_list.pop(0)
if len(cmd_list) == 0:
flat_level = tree if type(tree) == list else tree.keys()
flat_level = tree if isinstance(tree, list) else tree.keys()
if cmd in flat_level:
return [cmd]
else:
Expand Down
3 changes: 2 additions & 1 deletion open-lst/tools/openlst_tools/time_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

from __future__ import print_function
import os
import argparse
import logging
Expand Down Expand Up @@ -58,7 +59,7 @@ def main():
nanoseconds=dt.microseconds * 1000),
timeout=0.5
)
print resp
print(resp)

if __name__ == '__main__':
main()