Skip to content

Commit

Permalink
Merge pull request #185 from fleborne/fix/detect-baudrate-display
Browse files Browse the repository at this point in the history
[Bootloader] Fix display of baudrate used
  • Loading branch information
JeromeGalan authored Mar 31, 2023
2 parents e19a94d + c5786b7 commit 3d9ea42
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions pyluos/tools/bootloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,13 +623,6 @@ def reboot_network(device, topic, nodes_to_reboot):
# @return None
# *******************************************************************************
def luos_flash(args):
print('Luos flash subcommand with parameters :')
print('\t--baudrate : ', args.baudrate)
print('\t--gate : ', args.gate)
print('\t--target : ', args.target)
print('\t--binary : ', args.binary)
print('\t--port : ', args.port)

topic = 1

if not (args.port):
Expand All @@ -639,6 +632,15 @@ def luos_flash(args):
print('Please specify a port to access the network.')
return BOOTLOADER_FLASH_PORT_ERROR

baudrate = os.getenv('LUOS_BAUDRATE', args.baudrate)

print('Luos flash subcommand with parameters :')
print('\t--baudrate : ', baudrate)
print('\t--gate : ', args.gate)
print('\t--target : ', args.target)
print('\t--binary : ', args.binary)
print('\t--port : ', args.port)

# state used to check each step
machine_state = True
# list of all the nodes that may fail in each step
Expand All @@ -655,7 +657,7 @@ def luos_flash(args):
f.close()

# init device
device = Device(args.port, baudrate=os.getenv('LUOS_BAUDRATE', args.baudrate), background_task=False)
device = Device(args.port, baudrate=baudrate, background_task=False)

# find routing table
state = find_network(device)
Expand Down Expand Up @@ -765,18 +767,20 @@ def luos_flash(args):
# @return None
# *******************************************************************************
def luos_detect(args):
print('Luos detect subcommand on port : ', args.port)
print('\tLuos detect subcommand at baudrate : ', args.baudrate)

if not (args.port):
try:
args.port= serial_discover(os.getenv('LUOS_BAUDRATE', args.baudrate))[0]
except:
print('Please specify a port to access the network.')
return BOOTLOADER_DETECT_ERROR

baudrate = os.getenv('LUOS_BAUDRATE', args.baudrate)

print('Luos detect subcommand on port : ', args.port)
print('\tLuos detect subcommand at baudrate : ', baudrate)

# detect network
device = Device(args.port, baudrate=os.getenv('LUOS_BAUDRATE', args.baudrate))
device = Device(args.port, baudrate=baudrate)
# print network to user
print(device.nodes)
device.close()
Expand All @@ -789,19 +793,20 @@ def luos_detect(args):
# @return None
# *******************************************************************************
def luos_reset(args):
print('Luos discover subcommand on port : ', args.port)
print('\tLuos discover subcommand at baudrate : ', args.baudrate)

if not (args.port):
try:
args.port= serial_discover(os.getenv('LUOS_BAUDRATE', args.baudrate))[0]
except:
return BOOTLOADER_DETECT_ERROR

baudrate = os.getenv('LUOS_BAUDRATE', args.baudrate)

print('Luos discover subcommand on port : ', args.port)
print('\tLuos discover subcommand at baudrate : ', args.baudrate)

# send rescue command
print('Send reset command.')
port = serial.Serial(args.port, os.getenv('LUOS_BAUDRATE', args.baudrate), timeout=0.05)
port = serial.Serial(args.port, baudrate, timeout=0.05)
rst_cmd = {
'bootloader': {
'command': {
Expand All @@ -816,7 +821,7 @@ def luos_reset(args):
port.close()

# detect network
device = Device(args.port, baudrate=os.getenv('LUOS_BAUDRATE', args.baudrate), background_task=False)
device = Device(args.port, baudrate=baudrate, background_task=False)

print(device.nodes)
device.close()
Expand Down

0 comments on commit 3d9ea42

Please sign in to comment.