qmi.utils.adbasic_compiler.compile_program

qmi.utils.adbasic_compiler.compile_program(basic_filename: str, trigger: str, process_number: int, processor_type: str, hardware_type: str, priority: int = 1000, working_dir: str | None = None, keep_c_files: bool = False, adwin_dir: str = '/opt/adwin', pretty_print: bool = False) AdbasicResult

Compile an ADbasic program.

The ADbasic compiler expects that include files can be found relative to the current working directory.

If compilation is successful, an executable file will be created in the same directory as the source file. The name of this file is based on the name of the source file, with the “.bas” extension replaced by “.TCn” depending on the process number.

Parameters:
  • basic_filename – File name of the ADbasic .bas file to compile.

  • trigger – Select event trigger mechanism, either “external” or “timer”.

  • process_number – Select process number, range 1 to 10.

  • processor_type – Select processor type “T<x>”, where <x> is 11, 12 or 12.1.

  • hardware_type – The hardware that is used for compilation. Possible choices P, PII, G, GII (P=pro, G=Gold)

  • priority – Process priority, integer in range -10 to 10 for low priority, or PRIO_HIGH for high priority.

  • working_dir – Working directory when running the compiler. This determines the base directory for searching include files. Pass None to keep the current working directory of the process.

  • keep_c_files – Keep ‘c’ directory containing intermediate C files from ADbasic compiler. This only works under Linux.

  • adwin_dir – Base directory of ADwin software installation.

  • pretty_print – True to print compiler messages in pretty colors. False to log messages via the Python log system.

Returns:

Tuple containing results and error messages (if any) from the compilation process.

If compilation is successful, the success field of this tuple will be True. If compilation fails, the success field will be False and the errors field will contain a list of error messages from the compiler.

Return type:

AdbasicResult

Raises:

AdbasicCompilerException – If an unexpected error occurs while interacting with the ADbasic compiler.