This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new cea2f89f7 industry/scpi: add unit parser config options
cea2f89f7 is described below

commit cea2f89f7428c4a8b45dd31e18baf7605c29cbcc
Author: Nightt <[email protected]>
AuthorDate: Wed Jun 24 11:52:41 2026 +0800

    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 <[email protected]>
---
 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 d8911ecc7..6797051e6 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 c86267297..515011129 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

Reply via email to