Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Excerpt
namePython-FP-ARM

This example is found in API-DLL\FP-GP-ARM-Demo-Py in the installation directory.

  • If running 64-bit Python (default installation), use the x64 ARM-win setup (X-ProARM-xvxx-Setup_x64)

  • If running 32-bit Python, use the x86 ARM-win setup (X-ProARM-xvxx-Setup_x86)

  • For Linux the default Python installation will work with the amd64 or armhf builds.

Any application using the library will call most of the following functions. First, any one adapter is found, and initialized. Assuming at least one adapter was found (F_OpenInstancesAndFPAs returns > 0), the config and code files are loaded to select the MCU and data to be programmed. Finally, the procedure F_AutoProgram will run the full programming sequence of Erase, Blank Check, Write, Verify, and optionally Lock the MCU.

Code Block
languagepy
import os
import sys
import ctypes

#FP-ARM - comment this out and uncomment GP-ARM to use demo for GangPro-ARM
if (sys.platform == "win32"):
    libname = "./FlashProARM-FPAsel.dll"
else:
    libname = "libmultifparm.so"
#GP-ARM - commented out - comment this out and uncomment FP-ARM to use demo for FlashPro-ARM
#if (sys.platform == "win32"):
#    libname = "./GangProARM-FPAsel.dll"
#else:
#    libname = "libmultigparm.so"

init_file = bytes('FPAs-setup.ini', 'utf-8')
if (sys.platform == "win32"):
    config_file_path = bytes('ConfigFiles\\EFR32BG12P433F1024.cfg', 'utf-8')
    code_file_path = bytes('CodeFiles\\SL-512k.txt', 'utf-8')
else:
    config_file_path = bytes('ConfigFiles/EFR32BG12P433F1024.cfg', 'utf-8')
    code_file_path = bytes('CodeFiles/SL-512k.txt', 'utf-8')

#Load library
lib = ctypes.cdll.LoadLibrary(libname)

# Get number of connected adapters
instances = lib.F_OpenInstancesAndFPAs(init_file)
print("Connected adapters: {}".format(instances))

# Init all adapters
result = lib.F_Set_FPA_index(0)
print("F_Set_FPA_index(0): {}".format(result))
result = lib.F_Initialization()
print("F_Initialization: {}".format(result))

# Get adapters serial numbers
serials = []
for instance in range(1, instances+1):
    serials.append(lib.F_Get_FPA_SN(instance))
print(serials)

result = lib.F_ConfigFileLoad(config_file_path)
print("F_ConfigFileLoad: {}".format(result))
result = lib.F_ReadCodeFile(code_file_path)
print("F_ReadCodeFile: {}".format(result))

# Select one adapter
result = lib.F_Set_FPA_index(1)
print("F_Set_FPA_index(1): {}".format(result))

# Verify Access (not required with Auto Program)
result = lib.F_Verify_Access_to_MCU()
print("F_Verify_Access_to_MCU: {}".format(result))

# Auto Program
result = lib.F_AutoProgram(0)
print("F_AutoProgram: {}".format(result))

# Print Auto Program text output (same as GUI)
# max length REPORT_MESSAGE_MAX_SIZE 2000
report_s   = ctypes.create_string_buffer(2000)
lib.F_ReportMessage(report_s)
s = report_s.value.decode()
print(s)

Running the aforementioned code snippet with Python 3.8.3 produces the following result:

Image RemovedImage Added