Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/btldr rescue #139

Merged
merged 1 commit into from
May 6, 2022
Merged
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
31 changes: 26 additions & 5 deletions pyluos/tools/bootloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
import math
import crc8
import os
from ..io.serial_io import Serial
import serial
import struct

# *******************************************************************************
# Global Variables
Expand Down Expand Up @@ -570,17 +573,35 @@ def luos_detect(args):
# @return None
# *******************************************************************************
def luos_reset(args):
print('Luos detect subcommand on port : ', args.port)
print('Luos discover subcommand on port : ', args.port)

if not (args.port):
args.port= serial_discover()[0]
try:
args.port= serial_discover()[0]
except:
sys.exit("Can't find any Gate interface")
return


# send rescue command
print('Send reset command.')
port = serial.Serial(args.port, 1000000, timeout=0.05)
rst_cmd = {
'bootloader': {
'command': {
'type': BOOTLOADER_RESET,
'node': 0,
'size': 0
},
}
}
s = json.dumps(rst_cmd).encode()
port.write(b'\x7E' + struct.pack('<H', len(s)) + s + b'\x81')
port.close()

# detect network
device = Device(args.port, background_task=False)
print(device.nodes)
# send rescue command
print("Send reset command")
send_command(device, 0, BOOTLOADER_RESET)

# *******************************************************************************
# @brief command used to detect network
Expand Down