Function Decorators

@c_function

@c_function([c_function_name][, api])

New in version SNAP 2.7.

This decorator allows the user to easily link C code so it is accessible from the SNAPpy script. Both parameters are optional.

Parameters:
  • c_function_name (Optional(str)) – Name of the C function that should be called when the decorated SNAPpy function is invoked from the SNAPpy script or by RPC. If omitted, it defaults to the name of the decorated SNAPpy function.
  • api (Optional(list)) –

    A Python list of strings indicating the return type of the function and the types of all the parameters that should be passed to the function. Some types are not available as return types or for passed parameters. The following list describes the possible string values which are valid:

    String Usage Description
    ’str’ Parameter Only SNAPpy string in RAM, mutable by the C code
    ’const str’ Parameter Only SNAPpy string in RAM or flash, immutable by the C code
    ’none’ Return Only Return type of void functions in C
    ’int’ Parameter or Return 16-bit signed integer, SNAPpy standard integer type
    ’bool’ Parameter or Return Boolean value of True or False

Warning

Be sure that your C code does not extend the passed string to be larger than the buffer assigned to the string when it was passed.

See also

  • “C Support in SNAP 2.7” technical brief

@setHook

@setHook(hook)

This decorator should precede the definition of any function to be triggered by a “hooked” event in the SNAP environment, such as when a node reboots or when a pin changes state.

Parameters:hook – Value of one of the SNAP Hooks

See also