moving bool choice definition (ON, OFF) to units.c, so it could be used by various applications
| | |
| | | |
| | | extern const scpi_unit_def_t scpi_units_def[]; |
| | | extern const scpi_choice_def_t scpi_special_numbers_def[]; |
| | | extern const scpi_choice_def_t scpi_bool_def[]; |
| | | |
| | | scpi_bool_t SCPI_ParamNumber(scpi_t * context, const scpi_choice_def_t * special, scpi_number_t * value, scpi_bool_t mandatory); |
| | | |
| | |
| | | #include "scpi/error.h" |
| | | #include "scpi/constants.h" |
| | | #include "scpi/utils.h" |
| | | #include "scpi/units.h" |
| | | |
| | | /** |
| | | * Write data to SCPI output |
| | |
| | | scpi_parameter_t param; |
| | | int32_t intval; |
| | | |
| | | scpi_choice_def_t bool_options[] = { |
| | | {"OFF", 0}, |
| | | {"ON", 1}, |
| | | SCPI_CHOICE_LIST_END /* termination of option list */ |
| | | }; |
| | | |
| | | if (!value) { |
| | | SCPI_ErrorPush(context, SCPI_ERROR_SYSTEM_ERROR); |
| | | return FALSE; |
| | |
| | | SCPI_ParamToInt32(context, ¶m, &intval); |
| | | *value = intval ? TRUE : FALSE; |
| | | } else { |
| | | result = SCPI_ParamToChoice(context, ¶m, bool_options, &intval); |
| | | result = SCPI_ParamToChoice(context, ¶m, scpi_bool_def, &intval); |
| | | if (result) { |
| | | *value = intval ? TRUE : FALSE; |
| | | } |
| | |
| | | SCPI_CHOICE_LIST_END, |
| | | }; |
| | | |
| | | /* |
| | | * Special number values definition |
| | | */ |
| | | const scpi_choice_def_t scpi_bool_def[] = { |
| | | {"OFF", 0}, |
| | | {"ON", 1}, |
| | | SCPI_CHOICE_LIST_END /* termination of option list */ |
| | | }; |
| | | |
| | | /** |
| | | * Convert string describing unit to its representation |
| | | * @param units units patterns |