From 2182648e06f093cfa470b9d7b7775f8b006e30b3 Mon Sep 17 00:00:00 2001 From: Nightt <87569709+nightt5879@users.noreply.github.com> Date: Wed, 24 Jun 2026 11:52:41 +0800 Subject: [PATCH] industry/scpi: add unit parser config options Expose scpi-parser unit support through explicit Kconfig options instead of raw CFLAGS. Map each option to the corresponding upstream USE_UNITS_* compile-time define, preserving the existing default unit set while allowing users to enable groups such as USE_UNITS_TIME. Signed-off-by: Nightt <87569709+nightt5879@users.noreply.github.com> --- industry/scpi/Kconfig | 65 +++++++++++++++++++++++++++++++++++++++++- industry/scpi/Makefile | 18 ++++++++++++ 2 files changed, 82 insertions(+), 1 deletion(-) diff --git a/industry/scpi/Kconfig b/industry/scpi/Kconfig index d8911ecc79e..6797051e680 100644 --- a/industry/scpi/Kconfig +++ b/industry/scpi/Kconfig @@ -7,10 +7,71 @@ config SCPI_PARSER tristate "SCPI instrument side parser" default n +if SCPI_PARSER + +menu "SCPI parser unit support" + +config SCPI_PARSER_UNITS_IMPERIAL + bool "Imperial units" + default n + +config SCPI_PARSER_UNITS_ANGLE + bool "Angle units" + default n + +config SCPI_PARSER_UNITS_PARTICLES + bool "Particle units" + default n + +config SCPI_PARSER_UNITS_DISTANCE + bool "Distance units" + default n + +config SCPI_PARSER_UNITS_MAGNETIC + bool "Magnetic units" + default n + +config SCPI_PARSER_UNITS_LIGHT + bool "Light units" + default n + +config SCPI_PARSER_UNITS_ENERGY_FORCE_MASS + bool "Energy, force, and mass units" + default n + +config SCPI_PARSER_UNITS_TIME + bool "Time units" + default n + +config SCPI_PARSER_UNITS_TEMPERATURE + bool "Temperature units" + default n + +config SCPI_PARSER_UNITS_RATIO + bool "Ratio units" + default n + +config SCPI_PARSER_UNITS_POWER + bool "Power units" + default y + +config SCPI_PARSER_UNITS_FREQUENCY + bool "Frequency units" + default y + +config SCPI_PARSER_UNITS_ELECTRIC + bool "Electric units" + default y + +config SCPI_PARSER_UNITS_ELECTRIC_CHARGE_CONDUCTANCE + bool "Electric charge and conductance units" + default n + +endmenu + config SCPI_PARSER_DEMO bool "Enable the SCPI parser library demo" default n - depends on SCPI_PARSER if SCPI_PARSER_DEMO @@ -23,3 +84,5 @@ config SCPI_PARSER_DEMO_STACKSIZE default DEFAULT_TASK_STACKSIZE endif + +endif diff --git a/industry/scpi/Makefile b/industry/scpi/Makefile index c86267297ec..51501112984 100644 --- a/industry/scpi/Makefile +++ b/industry/scpi/Makefile @@ -39,6 +39,24 @@ CFLAGS += -DHAVE_SNPRINTF CFLAGS += -DHAVE_STRNDUP CFLAGS += -DHAVE_STRNCASECMP +SCPI_UNIT = $(if $(filter y,$(CONFIG_SCPI_PARSER_UNITS_$(1))),1,0) +SCPI_UECC = $(call SCPI_UNIT,ELECTRIC_CHARGE_CONDUCTANCE) + +CFLAGS += -DUSE_UNITS_IMPERIAL=$(call SCPI_UNIT,IMPERIAL) +CFLAGS += -DUSE_UNITS_ANGLE=$(call SCPI_UNIT,ANGLE) +CFLAGS += -DUSE_UNITS_PARTICLES=$(call SCPI_UNIT,PARTICLES) +CFLAGS += -DUSE_UNITS_DISTANCE=$(call SCPI_UNIT,DISTANCE) +CFLAGS += -DUSE_UNITS_MAGNETIC=$(call SCPI_UNIT,MAGNETIC) +CFLAGS += -DUSE_UNITS_LIGHT=$(call SCPI_UNIT,LIGHT) +CFLAGS += -DUSE_UNITS_ENERGY_FORCE_MASS=$(call SCPI_UNIT,ENERGY_FORCE_MASS) +CFLAGS += -DUSE_UNITS_TIME=$(call SCPI_UNIT,TIME) +CFLAGS += -DUSE_UNITS_TEMPERATURE=$(call SCPI_UNIT,TEMPERATURE) +CFLAGS += -DUSE_UNITS_RATIO=$(call SCPI_UNIT,RATIO) +CFLAGS += -DUSE_UNITS_POWER=$(call SCPI_UNIT,POWER) +CFLAGS += -DUSE_UNITS_FREQUENCY=$(call SCPI_UNIT,FREQUENCY) +CFLAGS += -DUSE_UNITS_ELECTRIC=$(call SCPI_UNIT,ELECTRIC) +CFLAGS += -DUSE_UNITS_ELECTRIC_CHARGE_CONDUCTANCE=$(SCPI_UECC) + ifneq ($(CONFIG_SCPI_PARSER_DEMO),) MAINSRC = $(SCPI_UNPACK)/examples/test-interactive/main.c CSRCS += scpi-def.c