|
#define | TRAP_DEFAULT_SIGNAL_HANDLER(stop_cmd) |
| Define default signal handler function Defines function to handle SIGTERM and SIGINT signals. When a signal is received, it runs the specified command and calls trap_terminate(). Place this macro before your main function.
|
|
#define | TRAP_REGISTER_DEFAULT_SIGNAL_HANDLER() |
| Register default signal handler. Register function defined by TRAP_DEFAULT_SIGNAL_HANDLER as handler of SIGTERM and SIGINT signals. Place this macro between TRAP initialization and the main loop.
|
|
#define | TRAP_DEFAULT_INITIALIZATION(argc, argv, module_info) |
| Initialize TRAP using command-line parameters and handle errors. Generates code that parses command-line parameters using trap_parse_params, intializes TRAP library using trap_init and handle possible errors. It calls exit(1) when an error has occured. Place this macro at the beginning of your main function.
|
|
#define | TRAP_DEFAULT_FINALIZATION() trap_finalize(); |
| Generate TRAP cleanup code. Only calls trap_finalize function. Place this macro at the end of your main function.
|
|
#define | TRAP_DEFAULT_GET_DATA_ERROR_HANDLING(ret_code, timeout_cmd, error_cmd) |
| Handle possible errors after call to trap_recv().
|
|
#define | TRAP_DEFAULT_RECV_ERROR_HANDLING(ret_code, timeout_cmd, error_cmd) |
| Handle possible errors after call to trap_recv.
|
|
#define | TRAP_DEFAULT_SEND_DATA_ERROR_HANDLING(ret_code, timeout_cmd, error_cmd) |
| Handle possible errors after call to trap_send_data.
|
|
#define | TRAP_DEFAULT_SEND_ERROR_HANDLING(ret_code, timeout_cmd, error_cmd) |
| Handle possible errors after call to trap_send.
|
|
Set of preprocessor macros for rapid NEMEA module development.
◆ TRAP_DEFAULT_FINALIZATION
Generate TRAP cleanup code. Only calls trap_finalize function. Place this macro at the end of your main function.
Definition at line 1013 of file trap.h.
◆ TRAP_DEFAULT_GET_DATA_ERROR_HANDLING
#define TRAP_DEFAULT_GET_DATA_ERROR_HANDLING |
( |
|
ret_code, |
|
|
|
timeout_cmd, |
|
|
|
error_cmd |
|
) |
| |
Value:
timeout_cmd;\
error_cmd;\
\
\
fprintf(stderr, "trap_recv() error: output and input interfaces data formats or data specifiers mismatch.\n"); \
error_cmd; \
fprintf(stderr, "trap_recv() error: interface negotiation failed (caused by invalid reply from a remote module, corrupted file or an unknown error).\n"); \
error_cmd; \
} else {\
error_cmd;\
}\
}
#define TRAP_E_FORMAT_MISMATCH
Returned by trap_recv when data format or data specifier of the output and input interfaces doesn't m...
#define TRAP_E_OK
Success, no error.
#define TRAP_E_TERMINATED
Interface was terminated during reading/writing.
#define TRAP_E_TIMEOUT
Read or write operation timeout.
#define TRAP_E_NEGOTIATION_FAILED
Returned by trap_recv when negotiation of the output and input interfaces failed.
#define TRAP_E_FORMAT_CHANGED
Returned by trap_recv when format or format spec of the receivers interface has been changed.
const char * trap_last_error_msg
Human-readable message about last error.
Handle possible errors after call to trap_recv().
- Parameters
-
[in] | ret_code | Return code of trap_recv(). |
| timeout_cmd | Command to run when a timeout has occured, e.g. "continue". |
| error_cmd | Command to run when an error has occured or interface was terminated, e.g. "break". |
- Deprecated:
- This macro should be replaced by TRAP_DEFAULT_RECV_ERROR_HANDLING.
Definition at line 1023 of file trap.h.
◆ TRAP_DEFAULT_INITIALIZATION
#define TRAP_DEFAULT_INITIALIZATION |
( |
|
argc, |
|
|
|
argv, |
|
|
|
module_info |
|
) |
| |
Value: {\
trap_print_help(&module_info);\
FREE_MODULE_INFO_STRUCT(MODULE_BASIC_INFO, MODULE_PARAMS) \
return 0;\
}\
trap_free_ifc_spec(ifc_spec);\
FREE_MODULE_INFO_STRUCT(MODULE_BASIC_INFO, MODULE_PARAMS) \
return 1;\
}\
trap_free_ifc_spec(ifc_spec);\
FREE_MODULE_INFO_STRUCT(MODULE_BASIC_INFO, MODULE_PARAMS) \
return 1;\
}\
trap_free_ifc_spec(ifc_spec);\
}
int trap_parse_params(int *argc, char **argv, trap_ifc_spec_t *ifc_spec)
#define TRAP_E_HELP
Returned by parse_parameters when help is requested.
int trap_init(trap_module_info_t *module_info, trap_ifc_spec_t ifc_spec)
Initialize TRAP using command-line parameters and handle errors. Generates code that parses command-line parameters using trap_parse_params, intializes TRAP library using trap_init and handle possible errors. It calls exit(1) when an error has occured. Place this macro at the beginning of your main function.
- Parameters
-
[in,out] | argc | Number of command-line parameters. |
[in,out] | argv | List of command-line parameters. |
[in] | module_info | trap_module_info_t structure containing information about the module. |
Definition at line 984 of file trap.h.
◆ TRAP_DEFAULT_RECV_ERROR_HANDLING
#define TRAP_DEFAULT_RECV_ERROR_HANDLING |
( |
|
ret_code, |
|
|
|
timeout_cmd, |
|
|
|
error_cmd |
|
) |
| |
Value:
timeout_cmd;\
error_cmd;\
\
\
fprintf(stderr, "trap_recv() error: output and input interfaces data formats or data specifiers mismatch.\n"); \
error_cmd; \
fprintf(stderr, "trap_recv() error: interface negotiation failed (caused by invalid reply from a remote module, corrupted file or an unknown error).\n"); \
error_cmd; \
} else {\
error_cmd;\
}\
}
Handle possible errors after call to trap_recv.
- Parameters
-
[in] | ret_code | Return code of trap_recv. |
| timeout_cmd | Command to run when a timeout has occured, e.g. "continue". |
| error_cmd | Command to run when an error has occured or interface was terminated, e.g. "break". |
Definition at line 1050 of file trap.h.
◆ TRAP_DEFAULT_SEND_DATA_ERROR_HANDLING
#define TRAP_DEFAULT_SEND_DATA_ERROR_HANDLING |
( |
|
ret_code, |
|
|
|
timeout_cmd, |
|
|
|
error_cmd |
|
) |
| |
Value:
timeout_cmd;\
error_cmd;\
} else {\
fprintf(stderr,
"Error: trap_send_data() returned %i (%s)\n", (ret_code),
trap_last_error_msg);\
error_cmd;\
}\
}
Handle possible errors after call to trap_send_data.
- Parameters
-
[in] | ret_code | Return code of trap_send_data. |
| timeout_cmd | Command to run when a timeout has occured, e.g. "0" to do nothing. |
| error_cmd | Command to run when an error has occured or interface was terminated, e.g. "break". |
- Deprecated:
- This macro should be replaced by TRAP_DEFAULT_SEND_ERROR_HANDLING.
Definition at line 1080 of file trap.h.
◆ TRAP_DEFAULT_SEND_ERROR_HANDLING
#define TRAP_DEFAULT_SEND_ERROR_HANDLING |
( |
|
ret_code, |
|
|
|
timeout_cmd, |
|
|
|
error_cmd |
|
) |
| |
Value:
timeout_cmd;\
error_cmd;\
} else {\
error_cmd;\
}\
}
Handle possible errors after call to trap_send.
- Parameters
-
[in] | ret_code | Return code of trap_send. |
| timeout_cmd | Command to run when a timeout has occured, e.g. "0" to do nothing. |
| error_cmd | Command to run when an error has occured or interface was terminated, e.g. "break". |
Definition at line 1099 of file trap.h.
◆ TRAP_DEFAULT_SIGNAL_HANDLER
#define TRAP_DEFAULT_SIGNAL_HANDLER |
( |
|
stop_cmd | ) |
|
Value: void trap_default_signal_handler(int signal)\
{\
if (signal == SIGTERM || signal == SIGINT) { \
stop_cmd;\
trap_terminate();\
}\
}
Define default signal handler function Defines function to handle SIGTERM and SIGINT signals. When a signal is received, it runs the specified command and calls trap_terminate(). Place this macro before your main function.
- Parameters
-
[in] | stop_cmd | Command which stops operation of a module. Usually setting a variable which is tested in module's main loop. |
Definition at line 931 of file trap.h.
◆ TRAP_REGISTER_DEFAULT_SIGNAL_HANDLER
#define TRAP_REGISTER_DEFAULT_SIGNAL_HANDLER |
( |
| ) |
|
Value: do {\
printf("Setting signal handler for SIGINT and SIGTERM using 'signal' function.\n");\
signal(SIGTERM, trap_default_signal_handler);\
signal(SIGINT, trap_default_signal_handler);\
} while(0)
int trap_get_verbose_level()
Register default signal handler. Register function defined by TRAP_DEFAULT_SIGNAL_HANDLER as handler of SIGTERM and SIGINT signals. Place this macro between TRAP initialization and the main loop.
Definition at line 963 of file trap.h.