66#if USE_UNITS_PARTICLES
106#if USE_UNITS_ELECTRIC
137#if USE_UNITS_ELECTRIC_CHARGE_CONDUCTANCE
147#if USE_UNITS_ENERGY_FORCE_MASS
185#if USE_UNITS_FREQUENCY
193#if USE_UNITS_DISTANCE
197#if USE_UNITS_IMPERIAL
222#if USE_UNITS_MAGNETIC
247#if USE_UNITS_TEMPERATURE
250#if USE_UNITS_IMPERIAL
295static const scpi_unit_def_t *
translateUnit(
const scpi_unit_def_t * units,
const char * unit,
size_t len) {
302 for (i = 0; units[i].name != NULL; i++) {
303 if (
compareStr(unit, len, units[i].name, strlen(units[i].name))) {
324 for (i = 0; units[i].name != NULL; i++) {
325 if ((units[i].unit == unit) && (units[i].mult == 1)) {
326 return units[i].name;
343 const scpi_unit_def_t * unitDef;
353 if (unitDef == NULL) {
358 value->content.value *= unitDef->mult;
359 value->unit = unitDef->unit;
389 state.buffer = param.ptr;
390 state.pos = state.buffer;
391 state.len = param.len;
393 switch (param.type) {
401 value->special =
FALSE;
408 switch (param.type) {
427 switch (param.type) {
456 value->special =
TRUE;
457 value->content.tag = tag;
475size_t SCPI_NumberToStr(scpi_t * context,
const scpi_choice_def_t * special, scpi_number_t * value,
char * str,
size_t len) {
480 if (!value || !str || len==0) {
484 if (value->special) {
486 strncpy(str, type, len);
498 if (result + 1 < len) {
502 strncat(str,
" ", len - result);
503 if (result + 2 < len) {
504 strncat(str, unit, len - result - 1);
506 result = strlen(str);
#define SCPIDEFINE_strnlen(s, l)
void SCPI_ErrorPush(scpi_t *context, int16_t err)
@ SCPI_ERROR_SYSTEM_ERROR
@ SCPI_ERROR_INVALID_SUFFIX
int scpiLex_DecimalNumericProgramData(lex_state_t *state, scpi_token_t *token)
int scpiLex_SuffixProgramData(lex_state_t *state, scpi_token_t *token)
int scpiLex_CharacterProgramData(lex_state_t *state, scpi_token_t *token)
int scpiLex_WhiteSpace(lex_state_t *state, scpi_token_t *token)
scpi_bool_t SCPI_ChoiceToName(const scpi_choice_def_t *options, int32_t tag, const char **text)
scpi_bool_t SCPI_ParamToChoice(scpi_t *context, scpi_parameter_t *parameter, const scpi_choice_def_t *options, int32_t *value)
scpi_bool_t SCPI_ParamToDouble(scpi_t *context, scpi_parameter_t *parameter, double *value)
scpi_bool_t SCPI_Parameter(scpi_t *context, scpi_parameter_t *parameter, scpi_bool_t mandatory)
enum _scpi_unit_t scpi_unit_t
#define SCPI_CHOICE_LIST_END
@ SCPI_UNIT_INCH_OF_MERCURY
@ SCPI_UNIT_NAUTICAL_MILE
@ SCPI_UNIT_ASTRONOMIC_UNIT
@ SCPI_UNIT_MM_OF_MERCURY
#define SCPI_UNITS_LIST_END
@ SCPI_TOKEN_PROGRAM_MNEMONIC
@ SCPI_TOKEN_DECIMAL_NUMERIC_PROGRAM_DATA_WITH_SUFFIX
@ SCPI_TOKEN_DECIMAL_NUMERIC_PROGRAM_DATA
scpi_token_t scpi_parameter_t
static scpi_bool_t transformNumber(scpi_t *context, const char *unit, size_t len, scpi_number_t *value)
const scpi_choice_def_t scpi_special_numbers_def[]
scpi_bool_t SCPI_ParamNumber(scpi_t *context, const scpi_choice_def_t *special, scpi_number_t *value, scpi_bool_t mandatory)
static const char * translateUnitInverse(const scpi_unit_def_t *units, const scpi_unit_t unit)
size_t SCPI_NumberToStr(scpi_t *context, const scpi_choice_def_t *special, scpi_number_t *value, char *str, size_t len)
static const scpi_unit_def_t * translateUnit(const scpi_unit_def_t *units, const char *unit, size_t len)
const scpi_unit_def_t scpi_units_def[]
size_t skipWhitespace(const char *cmd, size_t len)
size_t SCPI_DoubleToStr(double val, char *str, size_t len)
scpi_bool_t compareStr(const char *str1, size_t len1, const char *str2, size_t len2)
Conversion routines and string manipulation routines.