Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
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\\STM32U5_fpcert.cfg', 'utf-8')
else:
    config_file_path = bytes('STM32U5_fpcert.cfg', '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))
# Select one adapter
result = lib.F_Set_FPA_index(1)
print("F_Set_FPA_index(1): {}".format(result))
# Open Target (required before F_ReadSTM32Certificate )
result = lib.F_Open_Target_Device()
print("F_Open_Target_Device".format(result))
result = lib.F_ReadSTM32Certificate("")
print("F_ReadSTM32Certificate: {}".format(result))
result = lib.F_Close_Target_Device()
print("F_Close_Target_Device: {}".format(result))

...