Maxim Integrated's IoT development kit.

Dependencies:   MAX30101 MAX30003 MAX113XX_Pixi MAX30205 max32630fthr USBDevice

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers mbed_run.py Source File

mbed_run.py

00001 import sys
00002 import mbed_lstools
00003 import serial
00004 from shutil import copy
00005 
00006 bin_file=sys.argv[1]
00007 
00008 mbeds = mbed_lstools.create()
00009 m=mbeds.list_mbeds()
00010 
00011 if len(m) == 0:
00012     print "No mbed device detected"
00013     sys.exit(1)
00014 
00015 #print "Detected mbed devices: "
00016 #print m
00017 
00018 #Select first mbed device
00019 target_mbed=m[0]
00020 target_mount_point=target_mbed['mount_point']
00021 target_platform_name=target_mbed['platform_name']
00022 target_serial_port=target_mbed['serial_port']
00023 
00024 print "Detected mbed device:"
00025 if target_platform_name:
00026     print "  Platform name: " + target_platform_name
00027 print "  Mount point:   " + target_mount_point
00028 print "  Serial port:   " + target_serial_port
00029 
00030 
00031 print "Copy " + bin_file + " -> " + target_mount_point
00032 copy(bin_file, target_mount_point)
00033 
00034 try:
00035     ser = serial.Serial(target_serial_port, 115200)
00036     ser.send_break()
00037     ser.close()
00038 except Exception as e:
00039     #print e
00040     pass