Python Basic Demo (Raspberry Pi FP-430)

FlashPro-430 python example running on Raspberry Pi - 64-bit (arm64 build, RPi4 model B)

This example is found in /libfpgp430-5.8.0_arm64/Python-demo in the installation directory (linux unzipped package).

  • Python 3.9.2 used in example, based on MSP430 installer.

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.

from ctypes import cdll, c_int, c_long, c_byte, c_char_p, create_string_buffer, Structure # Load the DLL fpasel_dll = cdll.LoadLibrary('/usr/lib/aarch64-linux-gnu/libmultifp430.so') # Set function return types and argument types fpasel_dll.F_Multi_DLLTypeVer.restype = c_int fpasel_dll.F_Get_FPA_SN.restype = c_long fpasel_dll.F_OpenInstancesAndFPAs.argtypes = [c_char_p] fpasel_dll.F_ConfigFileLoad.argtypes = [c_char_p] fpasel_dll.F_ReadCodeFile.argtypes = [c_int, c_char_p] # Prepare string buffer for serial numbers serial_numbers = create_string_buffer(b"*# *") # Call DLL functions fpa_instances = fpasel_dll.F_OpenInstancesAndFPAs(serial_numbers) dll_id = fpasel_dll.F_Multi_DLLTypeVer() result = fpasel_dll.F_Use_Config_INI(0) result = fpasel_dll.F_Initialization() serial_number = fpasel_dll.F_Get_FPA_SN(1) # Output results print("Discovered adapters: {}".format(fpa_instances)) formatted_dll_id = "Multi-FPA DLL version - {0:X}.{1:02X}".format((dll_id >> 8) & 0xF, dll_id & 0xFF) print(formatted_dll_id) print("Adapter serial number: {}".format(serial_number)) # Load configuration and program files config_result = fpasel_dll.F_ConfigFileLoad(b'../LinuxCommandLineDemo/TestConfigs/config_F169.cfg') file_result = fpasel_dll.F_ReadCodeFile(1, b'../LinuxCommandLineDemo/TestCodeFiles/test_8k.txt') ap_result = fpasel_dll.F_AutoProgram(0) # Output results of operations print("Config file load: {}".format(config_result)) print("Code file read: {}".format(file_result)) print("Auto Program: {}".format(ap_result)) # Set the return type for F_Report_Message to c_char_p (C string) fpasel_dll.F_Report_Message.restype = c_char_p # Call the function to get the report message report_message = fpasel_dll.F_Report_Message() # Check if the message is not None and decode it to a Python string if report_message: print(report_message.decode('utf-8')) else: print("No report message available.") # Close instances fpasel_dll.F_CloseInstances()

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

image-20240930-230901.png

Â