Compare commits
175 Commits
stream_2_5
...
2.8-alpha
Author | SHA1 | Date | |
---|---|---|---|
b0c8a14071 | |||
4feb14ea35 | |||
2830f07324 | |||
abd8daafc3 | |||
489e783872 | |||
10d1fa8b02 | |||
c8bffebfc6 | |||
97f6beb3ae | |||
b80261ba16 | |||
6a114b2c2c | |||
bf29238762 | |||
13d1fb2ca0 | |||
cc1ab5685c | |||
370b3cd8c4 | |||
3a034f843d | |||
2de8e916b2 | |||
6044edfdd9 | |||
836388cd22 | |||
2685a43760 | |||
0eed3ee9c7 | |||
c5e3e89e44 | |||
1f27983505 | |||
146a8c895f | |||
efd5a0cbcd | |||
2968231b60 | |||
ea2238aa53 | |||
d22e1a5f4a | |||
31189ebecf | |||
d42e5a7a9e | |||
e13aa2a96f | |||
ae021ffeab | |||
5a9d89822f | |||
054b0c0e3f | |||
ac07ac3dcf | |||
0195386606 | |||
0026959b1e | |||
450e88d9a9 | |||
a4888634b6 | |||
46a68831c2 | |||
537d573983 | |||
96450e7010 | |||
31e1243eed | |||
0a90eb3d9c | |||
65f46aec36 | |||
37d14caa5b | |||
384474f6fd | |||
17d8592574 | |||
0936ac7840 | |||
704ece6231 | |||
5c6e98127e | |||
8805437c68 | |||
3acf791409 | |||
0ba674a341 | |||
40c33abac7 | |||
bc67317b0b | |||
06e212c66e | |||
7b314ccffd | |||
1d84986ee8 | |||
2ca8a129f7 | |||
126da8c499 | |||
ea110d5047 | |||
b37fad41c6 | |||
74775996db | |||
74426aab66 | |||
690bbb13d4 | |||
871fbed2b0 | |||
85c68d2ae6 | |||
8870611d4d | |||
67af7fc1bf | |||
93bea174e4 | |||
84fc6aabc8 | |||
38c4f5bcb6 | |||
e2af7e3149 | |||
950d75ba43 | |||
e651c99697 | |||
9694628d3f | |||
046582d1a0 | |||
f6f0ea9ae5 | |||
018547cdf3 | |||
d763a64f03 | |||
cefa460a0d | |||
cc5948ad0b | |||
be1943a66d | |||
d9acb47afe | |||
b721d26fb8 | |||
7530c7c67d | |||
824cd4d283 | |||
2e30e7aee6 | |||
3a5a3e22b9 | |||
51bd766ba6 | |||
0ab0d6db07 | |||
a12de614d6 | |||
240abd2788 | |||
e131fcb32f | |||
f88f594e87 | |||
56ef0651f2 | |||
9b9726b800 | |||
b139221f0b | |||
b0ab8a7a8b | |||
ddac589676 | |||
5b380cdaad | |||
cc9adc77fa | |||
2b38f7bcfa | |||
0ceada70b5 | |||
7bf91b403d | |||
bf5c359649 | |||
c41ac44bd1 | |||
e36013d64e | |||
9e48ad3e61 | |||
054e74d04a | |||
5f6319ed3d | |||
2f39622a57 | |||
7801119215 | |||
a6696cae49 | |||
40b52167aa | |||
814e3d53a3 | |||
6bd46e0470 | |||
d5cda13f6f | |||
bfc8e6a9cd | |||
73cba130c3 | |||
c09bc44aa4 | |||
b907e3f469 | |||
8c3bed09e4 | |||
4c99b82bb7 | |||
a6d72761b9 | |||
6c504d30cf | |||
1c814a451b | |||
daafc125c3 | |||
63f680bdc1 | |||
e88a327957 | |||
223c71bc68 | |||
14a04fd200 | |||
dc85511fe9 | |||
d0b8d3f585 | |||
97652917c9 | |||
c171a62f93 | |||
c7c28e7fa2 | |||
79a17788f2 | |||
9f0a2d2fb6 | |||
66f6ce9bd2 | |||
e5dfe7b816 | |||
6efb17be64 | |||
0310b30446 | |||
863cdf3d7f | |||
e51bb2555e | |||
9e0157d679 | |||
3e91eb4fc1 | |||
caf811c23a | |||
de116c9e5a | |||
eef38b0557 | |||
0057899476 | |||
0148e6e27e | |||
c6af859f9d | |||
01f0761ca8 | |||
d7770846aa | |||
0e76ba6464 | |||
fcb44ec845 | |||
cec8195e5e | |||
6c0eb32d75 | |||
9ae5f1d583 | |||
3b60bb9420 | |||
db50c35ad6 | |||
4f05d4e254 | |||
c5a17b217d | |||
fdccb0c5a9 | |||
ccbafef55a | |||
c594134317 | |||
11cfaf44ee | |||
a34678cbcc | |||
26fd99823c | |||
42c305c79b | |||
9585506644 | |||
4317ae0f75 | |||
6e6c79f5ea | |||
8da0014091 |
7
.cvsignore
Normal file
@ -0,0 +1,7 @@
|
||||
O.*
|
||||
*~
|
||||
bin
|
||||
lib
|
||||
dbd
|
||||
include
|
||||
*.pdf
|
7
.gitignore
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
O.*
|
||||
*~
|
||||
bin
|
||||
lib
|
||||
dbd
|
||||
include
|
||||
*.pdf
|
37
GNUmakefile
Normal file
@ -0,0 +1,37 @@
|
||||
ifeq ($(wildcard /ioc/tools/driver.makefile),)
|
||||
$(warning It seems you do not have the PSI build environment. Remove GNUmakefile.)
|
||||
include Makefile
|
||||
else
|
||||
include /ioc/tools/driver.makefile
|
||||
EXCLUDE_VERSIONS = 3.13.2
|
||||
PROJECT=stream
|
||||
BUILDCLASSES += Linux
|
||||
|
||||
DOCUDIR = documentation
|
||||
|
||||
PCRE=1
|
||||
ASYN=1
|
||||
-include src/CONFIG_STREAM
|
||||
|
||||
SOURCES += $(RECORDS:%=src/dev%Stream.c)
|
||||
SOURCES += $(FORMATS:%=src/%Converter.cc)
|
||||
SOURCES += $(BUSSES:%=src/%Interface.cc)
|
||||
SOURCES += $(STREAM_SRCS:%=src/%)
|
||||
|
||||
HEADERS += devStream.h
|
||||
HEADERS += StreamFormat.h
|
||||
HEADERS += StreamFormatConverter.h
|
||||
HEADERS += StreamBuffer.h
|
||||
HEADERS += StreamError.h
|
||||
|
||||
StreamCore.o: streamReferences
|
||||
|
||||
streamReferences:
|
||||
perl ../src/makeref.pl Interface $(BUSSES) > $@
|
||||
perl ../src/makeref.pl Converter $(FORMATS) >> $@
|
||||
|
||||
export DBDFILES = streamSup.dbd
|
||||
streamSup.dbd:
|
||||
@echo Creating $@
|
||||
perl ../src/makedbd.pl $(RECORDTYPES) > $@
|
||||
endif
|
5
MODULE
@ -1,5 +0,0 @@
|
||||
# Please change the following email with yours.
|
||||
Email: dirk.zimoch@psi.ch
|
||||
Module-Name: StreamDevice2
|
||||
Description: StreamDevice2
|
||||
Project-Name:
|
35
Makefile
@ -1,24 +1,29 @@
|
||||
TOP = ..
|
||||
|
||||
DIRS = src
|
||||
streamApp_DEPEND_DIRS = src
|
||||
|
||||
# Look if we have EPICS R3.13 or R3.14
|
||||
ifeq ($(wildcard $(TOP)/configure),)
|
||||
# EPICS R3.13
|
||||
include $(TOP)/config/CONFIG_APP
|
||||
CONFIG = $(TOP)/config
|
||||
else
|
||||
ifneq ($(wildcard $(TOP)/configure),)
|
||||
# EPICS R3.14
|
||||
DIRS = configure
|
||||
include $(TOP)/configure/CONFIG
|
||||
else ifneq ($(wildcard $(TOP)/config),)
|
||||
# EPICS R3.13
|
||||
CONFIG = $(TOP)/config
|
||||
DIRS = config
|
||||
include $(TOP)/config/CONFIG_APP
|
||||
else
|
||||
TOP = .
|
||||
DIRS = configure
|
||||
include $(TOP)/configure/CONFIG
|
||||
ifneq ($(words $(CALC) $(SYNAPPS)), 0)
|
||||
# with synApps calc module (contains scalcout)
|
||||
DIRS += srcSynApps
|
||||
srcSynApps_DEPEND_DIRS = src
|
||||
streamApp_DEPEND_DIRS += srcSynApps
|
||||
endif
|
||||
endif
|
||||
|
||||
DIRS += src
|
||||
src_DEPEND_DIRS = configure
|
||||
DIRS += streamApp
|
||||
streamApp_DEPEND_DIRS = src
|
||||
|
||||
include $(CONFIG)/RULES_DIRS
|
||||
include $(CONFIG)/RULES_TOP
|
||||
|
||||
documentation/stream.pdf: documentation/*.html documentation/*.css documentation/*.png
|
||||
cd documentation; makepdf
|
||||
|
||||
install: documentation/stream.pdf
|
||||
|
3
config/CONFIG
Normal file
@ -0,0 +1,3 @@
|
||||
#CONFIG
|
||||
# Add any changes to make rules here
|
||||
#CROSS_COMPILER_TARGET_ARCHS = mv167
|
20
config/CONFIG_APP
Normal file
@ -0,0 +1,20 @@
|
||||
#CONFIG_APP
|
||||
include $(TOP)/config/RELEASE
|
||||
-include $(TOP)/config/RELEASE.$(HOST_ARCH)
|
||||
include $(EPICS_BASE)/config/CONFIG
|
||||
INSTALL_LOCATION = $(TOP)
|
||||
ifdef INSTALL_LOCATION_APP
|
||||
INSTALL_LOCATION = $(INSTALL_LOCATION_APP)
|
||||
endif
|
||||
|
||||
ifdef T_A
|
||||
-include $(TOP)/config/O.$(T_A)/CONFIG_APP_INCLUDE
|
||||
endif
|
||||
|
||||
# Where to install databases
|
||||
INSTALL_DB = $(INSTALL_LOCATION)/db
|
||||
# dbst based database optimization (default: NO)
|
||||
DB_OPT = NO
|
||||
# May be overridden if not all databases should be installed
|
||||
INSTALLDB = $(DB)
|
||||
include $(TOP)/config/CONFIG
|
9
config/Makefile
Normal file
@ -0,0 +1,9 @@
|
||||
#
|
||||
# Makefile,v 1.1.2.1 1999/07/15 19:55:30 jba Exp
|
||||
#
|
||||
|
||||
TOP=..
|
||||
include $(TOP)/config/CONFIG_APP
|
||||
|
||||
include $(TOP)/config/RULES_ARCHS
|
||||
|
21
config/Makefile.Host
Normal file
@ -0,0 +1,21 @@
|
||||
#
|
||||
# Makefile.Host,v 1.1.2.3 2001/09/14 19:39:14 anj Exp
|
||||
#
|
||||
|
||||
TOP=../..
|
||||
include $(TOP)/config/CONFIG_APP
|
||||
|
||||
TARGETS = checkRelease CONFIG_APP_INCLUDE
|
||||
|
||||
include $(TOP)/config/RULES.Host
|
||||
|
||||
inc:: $(TARGETS)
|
||||
|
||||
CONFIG_APP_INCLUDE: $(wildcard $(TOP)/config/RELEASE*) $(TOP)/config/CONFIG_APP
|
||||
$(PERL) $(TOP)/config/convertRelease.pl $@
|
||||
|
||||
checkRelease:
|
||||
$(PERL) $(TOP)/config/convertRelease.pl $@
|
||||
|
||||
.PHONY :: checkRelease
|
||||
|
15
config/Makefile.Vx
Normal file
@ -0,0 +1,15 @@
|
||||
#
|
||||
# Makefile.Vx,v 1.1.2.3 2001/09/14 19:39:15 anj Exp
|
||||
#
|
||||
|
||||
TOP=../..
|
||||
include $(TOP)/config/CONFIG_APP
|
||||
|
||||
TARGETS = CONFIG_APP_INCLUDE
|
||||
|
||||
include $(TOP)/config/RULES.Vx
|
||||
|
||||
inc:: $(TARGETS)
|
||||
|
||||
CONFIG_APP_INCLUDE: $(wildcard $(TOP)/config/RELEASE*) $(TOP)/config/CONFIG_APP
|
||||
$(PERL) $(TOP)/config/convertRelease.pl -h $(HOST_ARCH) $@
|
1
config/RELEASE
Normal file
@ -0,0 +1 @@
|
||||
include $(TOP)/configure/RELEASE
|
203
config/RULES.Db
Normal file
@ -0,0 +1,203 @@
|
||||
# RULES.Db,v 1.9.6.6 2003/03/25 23:13:22 jba Exp
|
||||
#
|
||||
# Rules for making things related to databases
|
||||
#
|
||||
MAKEBPT = $(EPICS_BASE_HOST_BIN)/makeBpt$(EXE)
|
||||
DBLOADTEMPLATE = $(EPICS_BASE_HOST_BIN)/dbLoadTemplate$(EXE)
|
||||
DBEXPAND = $(EPICS_BASE_HOST_BIN)/dbExpand$(EXE)
|
||||
DBST = dbst
|
||||
MAKEDBDEPENDS = $(PERL) $(TOP)/config/makeDbDepends.pl
|
||||
REPLACEVAR = $(PERL) $(TOP)/config/replaceVAR.pl
|
||||
ifndef WIN32
|
||||
TOUCH = touch
|
||||
else
|
||||
TOUCH = $(PERL) $(TOP)/config/touch.pl
|
||||
endif
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
# if we are not building base add base dbd dirs
|
||||
|
||||
ifneq ($(EPICS_BASE),$(TOP))
|
||||
ifneq ($(EPICS_BASE),$(INSTALL_LOCATION))
|
||||
EPICS_DBDFLAGS += -I $(EPICS_BASE)/dbd
|
||||
endif
|
||||
endif
|
||||
|
||||
#---------------------------------------------------------------
|
||||
# ----------------------------------------------------
|
||||
# create names (lists) for installed things
|
||||
# ----------------------------------------------------
|
||||
|
||||
INSTALL_BPTS = $(BPTS:%= $(INSTALL_DBD)/%)
|
||||
INSTALL_DBDS = $(DBDINSTALL:%= $(INSTALL_DBD)/%)
|
||||
INSTALL_DBDNAME = $(DBDNAME:%= $(INSTALL_DBD)/%)
|
||||
INSTALL_DATA = $(INSTALLDB:%=$(INSTALL_DB)/%)
|
||||
INSTALL_TEMPLATES = $(filter %.template,$(INSTALL_DATA))
|
||||
|
||||
#---------------------------------------------------------------
|
||||
# Main targets
|
||||
|
||||
all:: install
|
||||
|
||||
inc:: $(INSTALL_DBDS) $(INSTALL_BPTS) $(INSTALL_TEMPLATES)
|
||||
|
||||
rebuild:: clean install
|
||||
|
||||
install:: inc buildInstall
|
||||
|
||||
buildInstall:: build $(INSTALL_DATA)
|
||||
|
||||
depends::
|
||||
|
||||
clean::
|
||||
@echo "Cleaning"
|
||||
@$(RM) $(DB) $(DBDNAME) *.template *.substitutions *.db.raw \
|
||||
*.db-stamp *.edf esiread.cnf
|
||||
|
||||
##################################################### "Foreign" templates
|
||||
|
||||
TEMPLATE_LINKS = $(filter-out $(notdir $(USES_TEMPLATE)), $(USES_TEMPLATE))
|
||||
TEMPLATE_FILES = $(filter $(notdir $(USES_TEMPLATE)), $(USES_TEMPLATE))
|
||||
DB_STAMP = $(patsubst %.db, %.db-stamp, $(DB))
|
||||
DB_REALTARGET = $(patsubst %.db-stamp, %.db, $@)
|
||||
|
||||
ifneq '$(TEMPLATE_LINKS)' ''
|
||||
build:: $(notdir $(TEMPLATE_LINKS))
|
||||
endif
|
||||
build:: $(INSTALL_DBDNAME) $(TEMPLATE_FILES) $(DB_STAMP)
|
||||
|
||||
$(notdir $(TEMPLATE_LINKS)): %.template:
|
||||
ifndef WIN32
|
||||
@$(RM) $(notdir $(TEMPLATE_LINKS))
|
||||
ln -s $(TEMPLATE_LINKS) .
|
||||
# Workaround for dbLoadTemplate bug: terminate here if link target doesn't exist
|
||||
@cat $(TEMPLATE_LINKS) > /dev/null
|
||||
else
|
||||
@$(RM) $(notdir $(TEMPLATE_LINKS))
|
||||
$(CP) $(TEMPLATE_LINKS) .
|
||||
endif
|
||||
|
||||
##################################################### Inflated or plain databases
|
||||
|
||||
$(INSTALL_DB)/%.db: %.db-stamp
|
||||
@echo "Installing database $@"
|
||||
@$(INSTALL) -d -m 644 $(patsubst %.db-stamp, %.db, $<) $(@D)
|
||||
|
||||
# Must have DBDNAME defined to use dbst optimization
|
||||
ifndef DBDNAME
|
||||
DB_OPT = NO
|
||||
endif
|
||||
|
||||
# dbst based database optimization
|
||||
ifeq '$(DB_OPT)' 'YES'
|
||||
.PRECIOUS: %.db.raw
|
||||
%.db-stamp: %.db.raw $(INSTALL_DBD)/$(DBDNAME)
|
||||
@echo "Optimizing database $@"
|
||||
$(DBST) $(INSTALL_DBD)/$(DBDNAME) $< -d > $(DB_REALTARGET)
|
||||
@$(TOUCH) $@
|
||||
%.db-stamp: %.t.db.raw $(INSTALL_DBD)/$(DBDNAME)
|
||||
@echo "Optimizing database $@"
|
||||
$(DBST) $(INSTALL_DBD)/$(DBDNAME) $< -d > $(DB_REALTARGET)
|
||||
@$(TOUCH) $@
|
||||
else
|
||||
# NO optimization => move it and keep a stamp
|
||||
%.db-stamp: %.db.raw
|
||||
@$(MV) $< $(DB_REALTARGET)
|
||||
@$(TOUCH) $@
|
||||
@$(TOUCH) $<
|
||||
%.db-stamp: %.t.db.raw
|
||||
@$(MV) $< $(DB_REALTARGET)
|
||||
@$(TOUCH) $@
|
||||
@$(TOUCH) $<
|
||||
endif
|
||||
|
||||
%.t.db.raw: %.substitutions
|
||||
@echo "Inflating database from $<"
|
||||
@$(RM) $@
|
||||
@$(DBLOADTEMPLATE) $< > $@
|
||||
|
||||
##################################################### CapFast filter
|
||||
|
||||
%.edf:: ../%.sch $(DEPSCHS)
|
||||
@if [ ! -f cad.rc -a -r ../cad.rc ] ; then ln -s ../cad.rc ; fi
|
||||
$(SCH2EDIF) $(SCH2EDIF_SYSFLAGS) $(SCH2EDIF_FLAGS) $<
|
||||
|
||||
##################################################### Substitution files
|
||||
|
||||
$(INSTALL_DB)/%.substitutions: %.substitutions
|
||||
@echo "Installing $@"
|
||||
@$(INSTALL) -d -m 644 $(@F) $(@D)
|
||||
|
||||
%.substitutions:: ../%.substitutions
|
||||
@$(CP) $< $@
|
||||
|
||||
ifdef CREATESUBSTITUTIONS
|
||||
%.substitutions:: $(word $(words $(CREATESUBSTITUTIONS)),$(CREATESUBSTITUTIONS))
|
||||
@$(CREATESUBSTITUTIONS) $*
|
||||
endif
|
||||
|
||||
# Better make it PRECIOUS (to get around make bug)
|
||||
.PRECIOUS: %.substitutions
|
||||
|
||||
##################################################### Template databases
|
||||
|
||||
# Installed template files (dbLoadTemplate() on IOC side)
|
||||
$(INSTALL_DB)/%.template: %.template
|
||||
@echo "Installing $@"
|
||||
@$(INSTALL) -d -m 644 $(@F) $(@D)
|
||||
|
||||
%.template:: ../%.template
|
||||
@$(CP) $< $@
|
||||
|
||||
%.template: %.edf
|
||||
$(E2DB) $(E2DB_SYSFLAGS) $(E2DB_FLAGS) -n $@.VAR $<
|
||||
@$(REPLACEVAR) < $@.VAR > $@
|
||||
@$(RM) $@.VAR
|
||||
|
||||
##################################################### Flat databases
|
||||
|
||||
%.db.raw:: ../%.db
|
||||
$(CP) $< $@
|
||||
|
||||
%.db.raw: %.edf
|
||||
$(E2DB) $(E2DB_SYSFLAGS) $(E2DB_FLAGS) -n $@.VAR $<
|
||||
@$(REPLACEVAR) < $@.VAR > $@
|
||||
@$(RM) $@.VAR
|
||||
|
||||
##################################################### DBD stuff
|
||||
|
||||
$(INSTALL_DBD)/%: %
|
||||
@echo "Installing $@"
|
||||
@$(INSTALL) -d -m 644 $< $(@D)
|
||||
|
||||
$(INSTALL_DBD)/%:: ../%
|
||||
@echo "Installing $@"
|
||||
@$(INSTALL) -d -m 644 $< $(@D)
|
||||
|
||||
bpt%.dbd: bpt%.data
|
||||
$(RM) $@
|
||||
$(MAKEBPT) $<
|
||||
|
||||
bpt%.dbd:: ../bpt%.data
|
||||
$(RM) $@
|
||||
$(MAKEBPT) $<
|
||||
|
||||
# Patch for old applications
|
||||
ifdef USER_DBDFLAGS
|
||||
DBDFLAGS = $(USER_DBDFLAGS)
|
||||
endif
|
||||
|
||||
ifdef DBDEXPAND
|
||||
$(DBDNAME): ../$(DBDEXPAND)
|
||||
@echo "Expanding dbd"
|
||||
@$(RM) $@
|
||||
$(DBEXPAND) $(DBDFLAGS) $< > dbExpand.tmp
|
||||
$(MV) dbExpand.tmp $@
|
||||
endif
|
||||
|
||||
##################################################### Dependencies
|
||||
|
||||
DEPENDS: $(filter $(patsubst %.db, %.substitutions, $(DB)), $(wildcard *.substitutions))
|
||||
@$(MAKEDBDEPENDS) $^
|
||||
|
||||
-include DEPENDS
|
3
config/RULES.Host
Normal file
@ -0,0 +1,3 @@
|
||||
#RULES.Host
|
||||
|
||||
include $(EPICS_BASE)/config/RULES.Host
|
7
config/RULES.Vx
Normal file
@ -0,0 +1,7 @@
|
||||
#RULES.Vx
|
||||
include $(EPICS_BASE)/config/RULES.Vx
|
||||
inc:: $(INSTALL_INCREC)
|
||||
|
||||
# Library should be rebuilt because LIBOBJS may have changed.
|
||||
$(LIBNAME): ../Makefile.Vx
|
||||
|
9
config/RULES.ioc
Normal file
@ -0,0 +1,9 @@
|
||||
#RULES.ioc
|
||||
include $(EPICS_BASE)/config/RULES_DIRS
|
||||
buildInstall:: cdCommands
|
||||
|
||||
cdCommands: Makefile $(wildcard $(TOP)/config/RELEASE*)
|
||||
@$(PERL) $(TOP)/config/convertRelease.pl -a $(ARCH) -h $(HOST_ARCH) $@
|
||||
|
||||
clean::
|
||||
@$(RM) cdCommands
|
4
config/RULES.iocBoot
Normal file
@ -0,0 +1,4 @@
|
||||
#RULES.iocBoot
|
||||
DIRS += $(wildcard ioc*)
|
||||
DIRS += $(wildcard as*)
|
||||
include $(EPICS_BASE)/config/RULES_DIRS
|
14
config/RULES.munch
Normal file
@ -0,0 +1,14 @@
|
||||
MUNCH = $(PERL) $(INSTALL_LOCATION)/bin/$(HOST_ARCH)/munch.pl
|
||||
|
||||
# The original 3.13.10 munching rule does not really work well
|
||||
|
||||
build:: $(LIBNAME).munch
|
||||
|
||||
buildInstall:: $(INSTALL_BIN)/$(LIBNAME).munch
|
||||
|
||||
%.munch: %
|
||||
$(RM) $*_ctct.o $*_ctdt.c
|
||||
$(NM) $< | $(MUNCH) > $*_ctdt.c
|
||||
$(GCC) -traditional $(CFLAGS) -fdollars-in-identifiers -c $(SOURCE_FLAG) $*_ctdt.c
|
||||
$(LINK.c) $@ $< $*_ctdt.o
|
||||
|
2
config/RULES_ARCHS
Normal file
@ -0,0 +1,2 @@
|
||||
#RULES_ARCHS
|
||||
include $(EPICS_BASE)/config/RULES_ARCHS
|
2
config/RULES_DIRS
Normal file
@ -0,0 +1,2 @@
|
||||
#RULES_DIRS
|
||||
include $(EPICS_BASE)/config/RULES_DIRS
|
5
config/RULES_TOP
Normal file
@ -0,0 +1,5 @@
|
||||
#RULES_TOP
|
||||
include $(EPICS_BASE)/config/RULES_TOP
|
||||
|
||||
uninstall::
|
||||
@$(RMDIR) $(INSTALL_DB)
|
186
config/convertRelease.pl
Normal file
@ -0,0 +1,186 @@
|
||||
eval 'exec perl -S $0 ${1+"$@"}' # -*- Mode: perl -*-
|
||||
if $running_under_some_shell; # convertRelease.pl
|
||||
#
|
||||
# convertRelease.pl,v 1.1.2.1 2001/09/14 19:39:15 anj Exp
|
||||
#
|
||||
# Parse config/RELEASE file(s) and generate a derived output file.
|
||||
#
|
||||
# This tool replaces makeConfigAppInclude.pl and makeIocCdCommands.pl
|
||||
# and adds consistency checks for RELEASE files.
|
||||
#
|
||||
|
||||
use Cwd;
|
||||
use Getopt::Std;
|
||||
|
||||
$cwd = cwd();
|
||||
$cwd =~ s/\/tmp_mnt//; # hack for sun4
|
||||
$cwd =~ s/\\/\//g; # hack for win32
|
||||
|
||||
getopt "aht";
|
||||
|
||||
if ($opt_a) {
|
||||
$arch = $opt_a;
|
||||
} else { # Look for O.<arch> in current path
|
||||
$_ = $cwd;
|
||||
($arch) = /.*\/O.([\w-]+)$/;
|
||||
}
|
||||
|
||||
$hostarch = $arch;
|
||||
$hostarch = $opt_h if ($opt_h);
|
||||
|
||||
if ($opt_t) {
|
||||
$top = $opt_t;
|
||||
} else { # Find $top from current path
|
||||
$top = $cwd;
|
||||
$top =~ s/\/iocBoot.*//;
|
||||
$top =~ s/\/config\/O\..*//;
|
||||
}
|
||||
|
||||
unless (@ARGV == 1) {
|
||||
print "Usage: convertRelease.pl [-a arch] [-h hostarch] [-t top] outfile\n";
|
||||
print " where outfile is be one of:\n";
|
||||
print "\tcheckRelease - checks consistency with support apps\n";
|
||||
print "\tcdCommands - generate cd path strings for IOC use\n";
|
||||
print "\tCONFIG_APP_INCLUDE - additional build variables\n";
|
||||
exit 2;
|
||||
}
|
||||
$outfile = $ARGV[0];
|
||||
|
||||
# TOP refers to this application
|
||||
%macros = (TOP => $top);
|
||||
@apps = (TOP); # Provides the order of apps in RELEASE file
|
||||
|
||||
# Read the RELEASE file(s)
|
||||
$relfile = "$top/config/RELEASE";
|
||||
die "Can't find config/RELEASE file" unless (-r $relfile);
|
||||
&readRelease($relfile, \%macros, \@apps);
|
||||
|
||||
if ($hostarch) {
|
||||
$relfile .= ".$hostarch";
|
||||
&readRelease($relfile, \%macros, \@apps) if (-r $relfile);
|
||||
}
|
||||
|
||||
# This is a perl switch statement:
|
||||
for ($outfile) {
|
||||
/CONFIG_APP_INCLUDE/ and do { &configAppInclude; last; };
|
||||
/cdCommands/ and do { &cdCommands; last; };
|
||||
/checkRelease/ and do { &checkRelease; last; };
|
||||
die "Output file type \'$outfile\' not supported";
|
||||
}
|
||||
|
||||
sub readRelease {
|
||||
my ($file, $Rmacros, $Rapps) = @_;
|
||||
# $Rmacros is a reference to a hash, $Rapps a ref to an array
|
||||
my ($pre, $macro, $post, $path);
|
||||
local *IN;
|
||||
open(IN, $file) or die "Can't open $file: $!\n";
|
||||
while (<IN>) {
|
||||
chomp;
|
||||
s/\s*#.*$//; # Remove trailing comments
|
||||
next if /^\s*$/; # Skip blank lines
|
||||
|
||||
# Expand all macros in the line:
|
||||
while (($pre,$macro,$post) = /(.*)\$\((\w+)\)(.*)/, $macro ne "") {
|
||||
$_ = $pre . $Rmacros->{$macro} . $post;
|
||||
}
|
||||
|
||||
# Handle "<macro> = <path>"
|
||||
($macro, $path) = /^\s*(\w+)\s*=\s*(.*)/;
|
||||
if ($macro ne "") {
|
||||
$Rmacros->{$macro} = $path;
|
||||
push @$Rapps, $macro;
|
||||
next;
|
||||
}
|
||||
# Handle "include <path>" syntax
|
||||
($path) = /^\s*include\s+(.*)/;
|
||||
&readRelease($path, $Rmacros, $Rapps) if (-r $path);
|
||||
}
|
||||
close IN;
|
||||
}
|
||||
|
||||
sub configAppInclude {
|
||||
@includes = grep !/^(TOP|TEMPLATE_TOP)$/, @apps;
|
||||
|
||||
unlink($outfile);
|
||||
open(OUT,">$outfile") or die "$! creating $outfile";
|
||||
print OUT "# Do not modify this file, changes made here will\n";
|
||||
print OUT "# be lost when the application is next rebuilt.\n\n";
|
||||
|
||||
if ($arch) {
|
||||
foreach $app (@includes) {
|
||||
$path = $macros{$app};
|
||||
next unless (-d "$path/bin/$arch");
|
||||
print OUT "${app}_BIN = \$($app)/bin/$arch\n";
|
||||
}
|
||||
foreach $app (@includes) {
|
||||
$path = $macros{$app};
|
||||
next unless (-d "$path/lib/$arch");
|
||||
print OUT "${app}_LIB = \$($app)/lib/$arch\n";
|
||||
}
|
||||
}
|
||||
foreach $app (@includes) {
|
||||
$path = $macros{$app};
|
||||
next unless (-d "$path/include");
|
||||
print OUT "EPICS_INCLUDES += -I\$($app)/include\n";
|
||||
}
|
||||
foreach $app (@includes) {
|
||||
$path = $macros{$app};
|
||||
next unless (-d "$path/dbd");
|
||||
print OUT "EPICS_DBDFLAGS += -I \$($app)/dbd\n";
|
||||
}
|
||||
close OUT;
|
||||
}
|
||||
|
||||
sub cdCommands {
|
||||
die "Architecture not set (use -a option)" unless ($arch);
|
||||
@includes = grep !/^TEMPLATE_TOP$/, @apps;
|
||||
|
||||
# if -t <top> was given, substitute it in the startup path
|
||||
$startup = $cwd;
|
||||
$startup =~ s/.*(\/iocBoot\/.*)/$top$1/ if ($opt_t);
|
||||
|
||||
unlink($outfile);
|
||||
open(OUT,">$outfile") or die "$! creating $outfile";
|
||||
print OUT "startup = \"$startup\"\n";
|
||||
print OUT "appbin = \"$top/bin/$arch\"\n"; # compatibility with R3.13.1
|
||||
|
||||
foreach $app (@includes) {
|
||||
$path = $macros{$app};
|
||||
$lcapp = lc($app);
|
||||
print OUT "$lcapp = \"$path\"\n" if (-d $path);
|
||||
print OUT "${lcapp}bin = \"$path/bin/$arch\"\n" if (-d "$path/bin/$arch");
|
||||
}
|
||||
close OUT;
|
||||
}
|
||||
|
||||
sub checkRelease {
|
||||
$status = 0;
|
||||
delete $macros{TOP};
|
||||
delete $macros{TEMPLATE_TOP};
|
||||
|
||||
while (($app, $path) = each %macros) {
|
||||
%check = (TOP => $path);
|
||||
@order = ();
|
||||
$relfile = "$path/config/RELEASE";
|
||||
&readRelease($relfile, \%check, \@order) if (-r $relfile);
|
||||
if ($hostarch) {
|
||||
$relfile .= ".$hostarch";
|
||||
&readRelease($relfile, \%check, \@order) if (-r $relfile);
|
||||
}
|
||||
delete $check{TOP};
|
||||
|
||||
while (($parent, $ppath) = each %check) {
|
||||
if (exists $macros{$parent} && ($macros{$parent} ne $ppath)) {
|
||||
print "\n" unless ($status);
|
||||
print "Definition of $parent conflicts with $app support.\n";
|
||||
print "In this application config/RELEASE defines\n";
|
||||
print "\t$parent = $macros{$parent}\n";
|
||||
print "but $app at $path has\n";
|
||||
print "\t$parent = $ppath\n";
|
||||
$status = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
print "\n" if ($status);
|
||||
exit $status;
|
||||
}
|
23
config/makeDbDepends.pl
Normal file
@ -0,0 +1,23 @@
|
||||
eval 'exec perl -S $0 ${1+"$@"}' # -*- Mode: perl -*-
|
||||
if $running_under_some_shell; # makeDbDepends.pl
|
||||
|
||||
# Called from within the object directory.
|
||||
# Searches the .substitutions files (from the command line) for
|
||||
# "file xxx {" entries to create a .DEPENDS file
|
||||
|
||||
open(OUT, ">.DEPENDS") or die "Cannot open .DEPENDS: $!";
|
||||
|
||||
foreach $file (@ARGV) {
|
||||
open(IN, "<$file") or die "Cannot open $file: $!";
|
||||
@substfile = <IN>;
|
||||
close IN or die "Cannot close $file: $!";
|
||||
|
||||
@depends = grep { s/^\s*file\s*(.*)\s*\{.*$/\1/ } @substfile;
|
||||
chomp @depends;
|
||||
|
||||
if (@depends) {
|
||||
$file =~ s/\.substitutions/\.t.db.raw/;
|
||||
print OUT "${file}:: @depends\n";
|
||||
}
|
||||
}
|
||||
close OUT or die "Cannot close $file: $!";
|
12
config/replaceVAR.pl
Normal file
@ -0,0 +1,12 @@
|
||||
eval 'exec perl -S $0 ${1+"$@"}' # -*- Mode: perl -*-
|
||||
if $running_under_some_shell; # replaceVAR.pl
|
||||
|
||||
# Called from within the object directory
|
||||
# Replaces VAR(xxx) with $(xxx)
|
||||
# and VAR_xxx_ with $(xxx)
|
||||
|
||||
while (<STDIN>) {
|
||||
s/VAR\(/\$\(/g;
|
||||
s/VAR_([^_]*)_/\$\($1\)/g;
|
||||
print;
|
||||
}
|
31
config/touch.pl
Normal file
@ -0,0 +1,31 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# unix touch in Perl
|
||||
|
||||
use File::Copy;
|
||||
use File::Basename;
|
||||
|
||||
sub Usage
|
||||
{
|
||||
my ($txt) = @_;
|
||||
|
||||
print "Usage:\n";
|
||||
print "\ttouch file [ file2 file3 ...]\n";
|
||||
print "\nError: $txt\n" if $txt;
|
||||
|
||||
exit 2;
|
||||
}
|
||||
|
||||
# need at least one arg: ARGV[0]
|
||||
Usage("need more args") if $#ARGV < 0;
|
||||
|
||||
@targets=@ARGV[0..$#ARGV];
|
||||
|
||||
foreach $file ( @targets )
|
||||
{
|
||||
open(OUT,">$file") or die "$! creating $file";
|
||||
#print OUT "NUL\n";
|
||||
close OUT;
|
||||
}
|
||||
|
||||
# EOF touch.pl
|
14
configure/CONFIG
Normal file
@ -0,0 +1,14 @@
|
||||
#CONFIG
|
||||
include $(TOP)/configure/CONFIG_APP
|
||||
# Add any changes to make definitions here
|
||||
|
||||
#CROSS_COMPILER_TARGET_ARCHS = vxWorks-68040
|
||||
#CROSS_COMPILER_TARGET_ARCHS =
|
||||
|
||||
# Use this when your IOC and the host use different paths
|
||||
# to access the application. Typically this will be
|
||||
# used with the Microsoft FTP server or with NFS mounts. Use
|
||||
# is indicated by failure of the cdCommands script on
|
||||
# vxWorks. You must rebuild in the iocBoot directory
|
||||
# before this takes effect.
|
||||
#IOCS_APPL_TOP = <the top of the application as seen by the IOC>
|
27
configure/CONFIG_APP
Normal file
@ -0,0 +1,27 @@
|
||||
# CONFIG_APP
|
||||
|
||||
include $(TOP)/configure/RELEASE
|
||||
-include $(TOP)/configure/RELEASE.$(EPICS_HOST_ARCH)
|
||||
-include $(TOP)/configure/RELEASE.Common.$(T_A)
|
||||
-include $(TOP)/configure/RELEASE.$(EPICS_HOST_ARCH).$(T_A)
|
||||
|
||||
ifneq ($(wildcard $(EPICS_BASE)/configure),)
|
||||
CONFIG=$(EPICS_BASE)/configure
|
||||
else
|
||||
CONFIG=$(EPICS_BASE)/config
|
||||
DIRS += config
|
||||
endif
|
||||
include $(CONFIG)/CONFIG
|
||||
|
||||
INSTALL_LOCATION = $(TOP)
|
||||
ifdef INSTALL_LOCATION_APP
|
||||
INSTALL_LOCATION = $(INSTALL_LOCATION_APP)
|
||||
endif
|
||||
|
||||
ifdef T_A
|
||||
-include $(TOP)/configure/O.$(T_A)/CONFIG_APP_INCLUDE
|
||||
endif
|
||||
|
||||
# dbst based database optimization (default: NO)
|
||||
DB_OPT = NO
|
||||
HOST_OPT=NO
|
15
configure/Makefile
Normal file
@ -0,0 +1,15 @@
|
||||
# Makefile
|
||||
|
||||
TOP=..
|
||||
|
||||
include $(TOP)/configure/CONFIG
|
||||
|
||||
# Set the following to NO to disable consistency checking of
|
||||
# the support applications defined in $(TOP)/configure/RELEASE
|
||||
CHECK_RELEASE = YES
|
||||
|
||||
TARGETS = $(CONFIG_TARGETS)
|
||||
CONFIGS += $(subst ../,,$(wildcard $(CONFIG_INSTALLS)))
|
||||
|
||||
include $(TOP)/configure/RULES
|
||||
|
29
configure/RELEASE
Normal file
@ -0,0 +1,29 @@
|
||||
#RELEASE Location of external products
|
||||
# Run "gnumake clean uninstall install" in the application
|
||||
# top directory each time this file is changed.
|
||||
#
|
||||
# NOTE: The build does not check dependancies on files
|
||||
# external to this application. Thus you should run
|
||||
# "gnumake clean uninstall install" in the top directory
|
||||
# each time EPICS_BASE, SNCSEQ, or any other external
|
||||
# module defined in the RELEASE file is rebuilt.
|
||||
|
||||
TEMPLATE_TOP=$(EPICS_BASE)/templates/makeBaseApp/top
|
||||
|
||||
# If you don't want to install into $(TOP) then
|
||||
# define INSTALL_LOCATION_APP here
|
||||
#INSTALL_LOCATION_APP=<fullpathname>
|
||||
|
||||
EPICS_BASE=/usr/local/epics/base-3.14.12
|
||||
ASYN=~/top/asyn4-30
|
||||
CALC=~/top/SynApps/calc-2-8
|
||||
PCRE=~/top/pcre-7.2
|
||||
|
||||
#3.14.8 does not understand ~
|
||||
#EPICS_BASE=/usr/local/epics/base-3.14.8
|
||||
#ASYN=/afs/psi.ch/user/z/zimoch/top/asyn-4.10
|
||||
|
||||
##Example 3.13 build
|
||||
#EPICS_BASE=/usr/local/epics/base-3.13.10
|
||||
#ASYN=/afs/psi.ch/user/z/zimoch/top_3.13/4-6
|
||||
#COMPAT=/afs/psi.ch/user/z/zimoch/top_3.13
|
9
configure/RULES
Normal file
@ -0,0 +1,9 @@
|
||||
#CONFIG
|
||||
ifneq ($(wildcard $(EPICS_BASE)/configure),)
|
||||
include $(EPICS_BASE)/configure/RULES
|
||||
else
|
||||
include $(EPICS_BASE)/config/RULES_ARCHS
|
||||
endif
|
||||
|
||||
# Library should be rebuilt because LIBOBJS may have changed.
|
||||
$(LIBNAME): ../Makefile
|
BIN
doc/PSI.gif
Before Width: | Height: | Size: 1.6 KiB |
BIN
documentation/PSI.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: aai Records</h1>
|
||||
<h1>aai Records</h1>
|
||||
<p>
|
||||
<b>Note:</b> aai record support is disabled per default.
|
||||
Enable it in <code>src/CONFIG_STREAM</code>.
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: aao Records</h1>
|
||||
<h1>aao Records</h1>
|
||||
<p>
|
||||
<b>Note:</b> aao record support is disabled per default.
|
||||
Enable it in <code>src/CONFIG_STREAM</code>.
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: ai Records</h1>
|
||||
<h1>ai Records</h1>
|
||||
|
||||
<h2>Normal Operation</h2>
|
||||
<p>
|
||||
@ -41,6 +41,12 @@ written or read value.
|
||||
(=20.0/0xFFFF) maps 0x0000 to -10.0, 0x7FFF to 0.0 and 0xFFFF to 10.0.
|
||||
Using unsigned formats with values ≥ 0x800000 gives different results
|
||||
on 64 bit machines.
|
||||
<p>
|
||||
If <code>LINR=="NO CONVERSION"</code> (the default), <code>VAL</code>
|
||||
is directly converted from and to <code>long</code> without going through
|
||||
<code>RVAL</code>. This allows for more bits on 64 bit machines.
|
||||
To get the old behavior, use <code>LINR=="LINEAR"</code>.
|
||||
</p>
|
||||
</dd>
|
||||
<dt>ENUM format (e.g. <code>%{</code>):</dt>
|
||||
<dd>
|
||||
@ -78,6 +84,6 @@ written or read value.
|
||||
<a href="calcout.html">calcout</a>
|
||||
<a href="scalcout.html">scalcout</a>
|
||||
</p>
|
||||
<p><small>Dirk Zimoch, 2005</small></p>
|
||||
<p><small>Dirk Zimoch, 2015</small></p>
|
||||
</body>
|
||||
</html>
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: ao Records</h1>
|
||||
<h1>ao Records</h1>
|
||||
|
||||
<h2>Normal Operation</h2>
|
||||
<p>
|
||||
@ -40,6 +40,12 @@ written or read value.
|
||||
(=20.0/0xFFFF) maps -10.0 to 0x0000, 0.0 to 0x7FFF and 10.0 to 0xFFFF.
|
||||
Using unsigned formats with values ≥ 0x800000 gives different results
|
||||
on 64 bit machines.
|
||||
<p>
|
||||
If <code>LINR=="NO CONVERSION"</code> (the default), <code>OVAL</code>
|
||||
is directly converted to <code>long</code> without going through
|
||||
<code>RVAL</code>. This allows for more bits on 64 bit machines.
|
||||
To get the old behavior, use <code>LINR=="LINEAR"</code>.
|
||||
</p>
|
||||
</dd>
|
||||
<dt>ENUM format (e.g. <code>%{</code>):</dt>
|
||||
<dd>
|
||||
@ -79,6 +85,6 @@ written or read value.
|
||||
<a href="calcout.html">calcout</a>
|
||||
<a href="scalcout.html">scalcout</a>
|
||||
</p>
|
||||
<p><small>Dirk Zimoch, 2005</small></p>
|
||||
<p><small>Dirk Zimoch, 2015</small></p>
|
||||
</body>
|
||||
</html>
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: bi Records</h1>
|
||||
<h1>bi Records</h1>
|
||||
|
||||
<h2>Normal Operation</h2>
|
||||
<p>
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: bo Records</h1>
|
||||
<h1>bo Records</h1>
|
||||
|
||||
<h2>Normal Operation</h2>
|
||||
<p>
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: calcout Records</h1>
|
||||
<h1>calcout Records</h1>
|
||||
|
||||
<p>
|
||||
<b>Note:</b> Device support for calcout records is only available for
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: Using EPICS 3.13</h1>
|
||||
<h1>Using EPICS 3.13</h1>
|
||||
|
||||
<a name="pre"></a>
|
||||
<h2>1. Prerequisites</h2>
|
Before Width: | Height: | Size: 187 B After Width: | Height: | Size: 187 B |
Before Width: | Height: | Size: 187 B After Width: | Height: | Size: 187 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: Format Converter API</h1>
|
||||
<h1>Format Converter API</h1>
|
||||
|
||||
<a name="class"></a>
|
||||
<h2>Converter Class</h2>
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: Format Converters</h1>
|
||||
<h1>Format Converters</h1>
|
||||
|
||||
<a name="syntax"></a>
|
||||
<h2>1. Format Syntax</h2>
|
||||
@ -28,8 +28,8 @@ A format converter consists of
|
||||
</p>
|
||||
<ul>
|
||||
<li>The <code>%</code> character</li>
|
||||
<li>Optionally a field <span class="new">or record</span> name in <code>()</code></li>
|
||||
<li>Optionally flags out of the characters <code>*# +0-<span class="new">?=</span></code></li>
|
||||
<li>Optionally a field or record name in <code>()</code></li>
|
||||
<li>Optionally flags out of the characters <code>*# +0-?=!</code></li>
|
||||
<li>Optionally an integer <em>width</em> field</li>
|
||||
<li>Optionally a period character (<code>.</code>) followed
|
||||
by an integer <em>precision</em> field (input ony for most formats)</li>
|
||||
@ -40,7 +40,7 @@ A format converter consists of
|
||||
<p>
|
||||
The flags <code>*# +0-</code> work like in the C functions
|
||||
<em>printf()</em> and <em>scanf()</em>.
|
||||
The flags <code>?</code> and <code>=</code> are extensions.
|
||||
The flags <code>?</code>, <code>=</code> and <code>!</code> are extensions.
|
||||
</p>
|
||||
<p>
|
||||
The <code>*</code> flag skips data in input formats.
|
||||
@ -67,16 +67,24 @@ The <code>0</code> flag says that numbers should be left padded with
|
||||
The <code>-</code> flag specifies that output is left justified if
|
||||
<em>width</em> is larger than required.
|
||||
</p>
|
||||
<p class="new">
|
||||
<p>
|
||||
The <code>?</code> flag makes failing input conversions succeed with
|
||||
a default zero value (0, 0.0, or "", depending on the format type).
|
||||
</p>
|
||||
<p class="new">
|
||||
<p>
|
||||
The <code>=</code> flag allows to compare input with current values.
|
||||
It is only allowed in input formats.
|
||||
Instead of reading a new value from input, the current value is
|
||||
formatted (like for output) and then compared to the input.
|
||||
</p>
|
||||
<p>
|
||||
The <code>!</code> flag demands that input is exactly <em>width</em>
|
||||
bytes long (normally <em>width</em> defines the maximum number of
|
||||
bytes read in many formats).
|
||||
For example <code>in "%!5d";</code> expects exactly 5 digits.
|
||||
Fewer digits are considered loss of data and make the format fail.
|
||||
This feature has been added by Klemen Vodopivec, SNS.
|
||||
</p>
|
||||
|
||||
<h3>Examples:</h3>
|
||||
<table>
|
||||
@ -132,6 +140,7 @@ Thus, data type modifiers like <code>l</code> or <code>h</code> do not
|
||||
exist in <em>StreamDevice</em> formats.
|
||||
</p>
|
||||
|
||||
<a name="redirection"></a>
|
||||
<h3>Redirection</h3>
|
||||
<p>
|
||||
To use other fields of the record or even fields of other records on the
|
||||
@ -142,11 +151,8 @@ field formatted as a string.
|
||||
Use <code>in "%(<i>otherrecord</i>.RVAL)f";</code> to write the floating
|
||||
point input value into the <code>RVAL</code> field of
|
||||
<code><i>otherrecord</i></code>.
|
||||
<span class="new">
|
||||
If no field is given for an other record .VAL is assumed.
|
||||
When a record name conflicts with a field name use .VAL explicitly.
|
||||
</span>
|
||||
|
||||
</p>
|
||||
<p>
|
||||
This feature is very useful when one line of input contains many values that should
|
||||
@ -157,6 +163,9 @@ attribute (see
|
||||
target="ex">Record Reference Manual</a>), the record will be processed.
|
||||
It is your responsibility that the data type of the record field is
|
||||
compatible to the the data type of the converter.
|
||||
STRING formats are compatible with arrays of CHAR or UCHAR.
|
||||
</p>
|
||||
<p>
|
||||
Note that using this syntax is by far not as efficient as using the
|
||||
default field.
|
||||
At the moment it is not possible to set <code>otherrecord</code> to an alarm
|
||||
@ -188,13 +197,13 @@ With the <code>#</code> flag, output always contains a period character.
|
||||
<p>
|
||||
<b>Input:</b> All these formats are equivalent. Leading whitespaces are skipped.
|
||||
</p>
|
||||
<p class="new">
|
||||
<p>
|
||||
With the <code>#</code> flag additional whitespace between sign and number
|
||||
is accepted.
|
||||
</p>
|
||||
<p class="new">
|
||||
<p>
|
||||
When a maximum field width is given, leading whitespace only counts to the
|
||||
field witdth when the space flag is given.
|
||||
field witdth when the space flag is used.
|
||||
</p>
|
||||
|
||||
<a name="stdl"></a>
|
||||
@ -209,6 +218,10 @@ field witdth when the space flag is given.
|
||||
<p>
|
||||
With the <code>#</code> flag, octal values are prefixed with <code>0</code>
|
||||
and hexadecimal values with <code>0x</code> or <code>0X</code>.
|
||||
<p>
|
||||
Unlike printf, <code>%x</code> and <code>%X</code> truncate the
|
||||
output to the the given width (number of least significant half bytes).
|
||||
</p>
|
||||
</p>
|
||||
<p>
|
||||
<b>Input:</b> <code>%d</code> matches signed decimal, <code>%u</code> matches
|
||||
@ -220,16 +233,16 @@ Octal and hexadecimal values can optionally be prefixed.
|
||||
hexadecimal notation.
|
||||
Leading whitespaces are skipped.
|
||||
</p>
|
||||
<p class="new">
|
||||
<p>
|
||||
With the <code>-</code> negative octal and hexadecimal values are accepted.
|
||||
</p>
|
||||
<p class="new">
|
||||
<p>
|
||||
With the <code>#</code> flag additional whitespace between sign and number
|
||||
is accepted.
|
||||
</p>
|
||||
<p class="new">
|
||||
<p>
|
||||
When a maximum field width is given, leading whitespace only counts to the
|
||||
field witdth when the space flag is given.
|
||||
field witdth when the space flag is used.
|
||||
</p>
|
||||
|
||||
<a name="stds"></a>
|
||||
@ -245,16 +258,19 @@ and <code>%c</code> matches a sequence of not-null characters.
|
||||
The maximum string length is given by <em>width</em>.
|
||||
The default <em>width</em> is infinite for <code>%s</code> and
|
||||
1 for <code>%c</code>.
|
||||
Leading whitespaces are skipped with <code>%s</code>
|
||||
<span class="new">
|
||||
except when the space flag is given</span>
|
||||
but not with <code>%c</code>.
|
||||
Leading whitespaces are skipped with <code>%s</code> except when
|
||||
the space flag is used but not with <code>%c</code>.
|
||||
The empty string matches.
|
||||
</p>
|
||||
<p class="new">
|
||||
<p>
|
||||
With the <code>#</code> flag <code>%s</code> matches a sequence of not-null
|
||||
characters instead of non-whitespace characters.
|
||||
</p>
|
||||
<p>
|
||||
With the <code>0</code> flag <code>%s</code> pads with 0 bytes instead of
|
||||
spaces.
|
||||
</p>
|
||||
|
||||
|
||||
<a name="cset"></a>
|
||||
<h2>6. Standard Charset STRING Converter (<code>%[<em>charset</em>]</code>)</h2>
|
||||
@ -285,9 +301,20 @@ to the value 0, <code>STANDBY</code> to 1 and <code>ON</code> to 2.
|
||||
<p>
|
||||
When using the <code>#</code> flag it is allowed to assign integer values
|
||||
to the strings using <code>=</code>.
|
||||
Unassigned strings increment their values by 1 as usual.
|
||||
</p>
|
||||
<p>
|
||||
Example: <code>%#{neg=-1|stop=0|pos=1|fast=10}</code>.
|
||||
If one string is the initial substing of another, the substing must come
|
||||
later to ensure correct matching.
|
||||
In particular if one string is the emptry string, it must be the last one.
|
||||
Use <code>#</code> and <code>=</code> to renumber if necessary.
|
||||
</p>
|
||||
<p>
|
||||
Use the assignment <code>=?</code> for the last string to make it the
|
||||
default value for output formats.
|
||||
</p>
|
||||
<p>
|
||||
Example: <code>%#{neg=-1|stop|pos|fast=10|rewind=-10}</code>.
|
||||
</p>
|
||||
<p>
|
||||
If one of the strings contains <code>|</code> or <code>}</code>
|
||||
@ -295,10 +322,11 @@ If one of the strings contains <code>|</code> or <code>}</code>
|
||||
a <code>\</code> must be used to escape the character.
|
||||
</p>
|
||||
<p>
|
||||
In output, depending on the value, one of the strings is printed.
|
||||
<b>Output:</b> Depending on the value, one of the strings is printed,
|
||||
or the default if no value matches.
|
||||
</p>
|
||||
<p>
|
||||
In input, if any of the strings matches the value is set accordingly.
|
||||
<b>Input:</b> If any of the strings matches, the value is set accordingly.
|
||||
</p>
|
||||
|
||||
<a name="bin"></a>
|
||||
@ -344,9 +372,12 @@ endian</em>, i.e. least significant byte first.
|
||||
With the <code>0</code> flag, the value is unsigned, otherwise signed.
|
||||
</p>
|
||||
<p>
|
||||
In output, the <em>prec</em> (or sizeof(long) whatever is less) least
|
||||
In output, the <em>precision</em> (or sizeof(long) whatever is less) least
|
||||
significant bytes of the value are sign extended or zero extended
|
||||
(depending on the <code>0</code> flag) to <em>width</em> bytes.
|
||||
The default for <em>precision</em> is 1. Thus if you do not specify
|
||||
the <em>precision</em>, only the least significant byte is written!
|
||||
It is common error to write <code>out "%2r";</code> instead of <code>out "%.2r";</code>.
|
||||
</p>
|
||||
<p>
|
||||
In input, <em>width</em> bytes are read and put into the value.
|
||||
@ -357,7 +388,7 @@ the value is sign extended or zero extended, depending on the
|
||||
<code>0</code> flag.
|
||||
</p>
|
||||
<p>
|
||||
Example: <code>out "%.2r"</code>
|
||||
Examples: <code>out "%.2r"; in "%02r";</code>
|
||||
</p>
|
||||
|
||||
<a name="rawdouble"></a>
|
||||
@ -411,7 +442,7 @@ The <em>width</em> field is the byte number from which to start
|
||||
calculating the checksum.
|
||||
Default is 0, i.e. the first byte of the input or output of the current
|
||||
command.
|
||||
The last byte is <em>prec</em> bytes before the checksum (default 0).
|
||||
The last byte is <em>precision</em> bytes before the checksum (default 0).
|
||||
For example in <code>"abcdefg%<xor>"</code> the checksum is calculated
|
||||
from <code>abcdefg</code>,
|
||||
but in <code>"abcdefg%2.1<xor>"</code> only from <code>cdef</code>.
|
||||
@ -423,8 +454,17 @@ With the <code>#</code> flag, the byte order is changed to <em>little
|
||||
endian</em>, i.e. least significant byte first.
|
||||
</p>
|
||||
<p>
|
||||
The <code>0</code> flag changes the checksum representation from
|
||||
binary to hexadecimal ASCII (2 bytes per checksum byte).
|
||||
The <code>0</code> flag changes the checksum representation to
|
||||
to hexadecimal ASCII (2 chars per checksum byte).
|
||||
</p>
|
||||
<p>
|
||||
The <code>-</code> flag changes the checksum representation to
|
||||
"poor man's hex": 0x30 ... 0x3f (2 chars per checksum byte).
|
||||
</p>
|
||||
<p>
|
||||
The <code>+</code> flag changes the checksum representation to
|
||||
decimal ASCII (formatted with %d).
|
||||
</p>
|
||||
<!--
|
||||
In output, the case of the ASCII checksum matches the case of first
|
||||
letter of the function name.
|
||||
@ -465,21 +505,24 @@ In input, the next byte or bytes must match the checksum.
|
||||
(poly=0x07, init=0x00, xorout=0x00).</dd>
|
||||
<dt><code>%<ccitt8></code></dt>
|
||||
<dd>One byte. The CCITT standard 8 bit crc checksum
|
||||
(poly=0x31, init=0x00, xorout=0x00).</dd>
|
||||
(poly=0x31, init=0x00, xorout=0x00, reflected).</dd>
|
||||
<dt><code>%<crc16></code></dt>
|
||||
<dd>Two bytes. An often used 16 bit crc checksum
|
||||
(poly=0x8005, init=0x0000, xorout=0x0000).</dd>
|
||||
<dt><code>%<crc16r></code></dt>
|
||||
<dd>Two bytes. An often used reflected 16 bit crc checksum
|
||||
(poly=0x8005, init=0x0000, xorout=0x0000).</dd>
|
||||
(poly=0x8005, init=0x0000, xorout=0x0000, reflected).</dd>
|
||||
<dt><code>%<modbus></code></dt>
|
||||
<dd>Two bytes. The modbus 16 bit crc checksum
|
||||
(poly=0x8005, init=0xffff, xorout=0x0000, reflected)</dd>
|
||||
<dt><code>%<ccitt16></code></dt>
|
||||
<dd>Two bytes. The usual (but <a target="ex"
|
||||
href="http://www.joegeluso.com/software/articles/ccitt.htm">wrong?</a>)
|
||||
href="http://srecord.sourceforge.net/crc16-ccitt.html">wrong?</a>)
|
||||
implementation of the CCITT standard 16 bit crc checksum
|
||||
(poly=0x1021, init=0xFFFF, xorout=0x0000).</dd>
|
||||
<dt><code>%<ccitt16a></code></dt>
|
||||
<dd>Two bytes. The unusual (but <a target="ex"
|
||||
href="http://www.joegeluso.com/software/articles/ccitt.htm">correct?</a>)
|
||||
href="http://srecord.sourceforge.net/crc16-ccitt.html">correct?</a>)
|
||||
implementation of the CCITT standard 16 bit crc checksum with augment.
|
||||
(poly=0x1021, init=0x1D0F, xorout=0x0000).</dd>
|
||||
<dt><code>%<ccitt16x></code> or <code>%<crc16c></code> or <code>%<xmodem></code></dt>
|
||||
@ -490,10 +533,10 @@ In input, the next byte or bytes must match the checksum.
|
||||
(poly=0x04C11DB7, init=0xFFFFFFFF, xorout=0xFFFFFFFF).</dd>
|
||||
<dt><code>%<crc32r></code></dt>
|
||||
<dd>Four bytes. The standard reflected 32 bit crc checksum.
|
||||
(poly=0x04C11DB7, init=0xFFFFFFFF, xorout=0xFFFFFFFF).</dd>
|
||||
(poly=0x04C11DB7, init=0xFFFFFFFF, xorout=0xFFFFFFFF, reflected).</dd>
|
||||
<dt><code>%<jamcrc></code></dt>
|
||||
<dd>Four bytes. Another reflected 32 bit crc checksum.
|
||||
(poly=0x04C11DB7, init=0xFFFFFFFF, xorout=0x00000000).</dd>
|
||||
(poly=0x04C11DB7, init=0xFFFFFFFF, xorout=0x00000000, reflected).</dd>
|
||||
<dt><code>%<adler32></code></dt>
|
||||
<dd>Four bytes. The Adler32 checksum according to <a target="ex"
|
||||
href="http://www.ietf.org/rfc/rfc1950.txt">RFC 1950</a>.</dd>
|
||||
@ -502,41 +545,49 @@ In input, the next byte or bytes must match the checksum.
|
||||
</dl>
|
||||
|
||||
<a name="regex"></a>
|
||||
<h2>12. Regular Expresion STRING Converter (<code>%/<em>regex</em>/</code>)</h2>
|
||||
<h2>13. Regular Expresion STRING Converter (<code>%/<em>regex</em>/</code>)</h2>
|
||||
<p>
|
||||
This input-only format matches <a target="ex"
|
||||
href="http://www.pcre.org/" >Perl compatible regular expressions (PCRE)</a>.
|
||||
It is only available if a PCRE library is installed.
|
||||
</p>
|
||||
<div class="box">
|
||||
<p>
|
||||
If PCRE is not available for your host or cross architecture, download
|
||||
the sourcecode from <a target="ex" href="http://www.pcre.org/">www.pcre.org</a>
|
||||
and try my EPICS compatible <a target="ex"
|
||||
href="http://epics.web.psi.ch/software/streamdevice/pcre/Makefile">Makefile</a>
|
||||
to compile it like a normal EPICS application.
|
||||
to compile it like a normal EPICS support module.
|
||||
The Makefile is known to work with EPICS 3.14.8 and PCRE 7.2.
|
||||
In your RELEASE file define the variable <code>PCRE</code> so that
|
||||
it points to the install location of PCRE.
|
||||
</p>
|
||||
<p>
|
||||
If PCRE is already installed on your system, use the variables
|
||||
<code>PCRE_INCLUDE</code> and <code>PCRE_LIB</code> instead to provide
|
||||
the install directories of <code>pcre.h</code> and the library.
|
||||
</p>
|
||||
<p>
|
||||
If you have PCRE installed in different locations for different (cross)
|
||||
architectures, define the variables in RELEASE.Common.<architecture>
|
||||
instead of the global RELEASE file.
|
||||
If PCRE is already installed on (some of) your systems, you may add
|
||||
architectures where PCRE can be found in standard include and library
|
||||
locations to the variable <code>WITH_SYSTEM_PCRE</code>.
|
||||
If either the header file or the library are in a non-standard place,
|
||||
set in your RELEASE file the variables <code>PCRE_INCLUDE_<em>arch</em></code>
|
||||
and/or <code>PCRE_LIB_<em>arch</em></code> for the respective architectures
|
||||
to the correct directories or set
|
||||
<code>PCRE_INCLUDE</code> and/or <code>PCRE_LIB</code>
|
||||
in architecture specific RELEASE.Common.<em>arch</em> files.
|
||||
</p>
|
||||
</div>
|
||||
<p>
|
||||
If the regular expression is not anchored, i.e. does not start with
|
||||
<code>^</code>, leading non-matching input is skipped.
|
||||
<code>^</code>, leading non-matching input is skipped.
|
||||
To match in multiline mode (across newlines) add <code>(?m)</code>
|
||||
at the beginning of the pattern.
|
||||
To match case insensitive, add <code>(?i)</code>.
|
||||
</p>
|
||||
<p>
|
||||
A maximum of <em>width</em> bytes is matched, if specified.
|
||||
If <em>prec</em> is given, it specifies the sub-expression whose match
|
||||
is retuned.
|
||||
If <em>precision</em> is given, it specifies the sub-expression whose match
|
||||
is returned.
|
||||
Otherwise the complete match is returned.
|
||||
In any case, the complete match is consumed from the input buffer.
|
||||
If the expression contains a <code>/</code> it must be escaped.
|
||||
If the expression contains a <code>/</code> it must be escaped like <code>\/</code>.
|
||||
</p>
|
||||
<p>
|
||||
Example: <code>%.1/<title>(.*)<\/title>/</code> returns
|
||||
@ -544,8 +595,74 @@ the title of an HTML page, skipps anything before the
|
||||
<code><title></code> tag and leaves anything after the
|
||||
<code></title></code> tag in the input buffer.
|
||||
</p>
|
||||
<a name="regsub"></a>
|
||||
<h2>14. Regular Expresion Substitution Pseudo-Converter (<code>%#/<em>regex</em>/<em>subst</em>/</code>)</h2>
|
||||
<p>
|
||||
This is a variant of the previous converter (note the <code>#</code>)
|
||||
but instead of returning the matching string,
|
||||
it can be used as a pre-processor for input or
|
||||
as a post-processor for output.
|
||||
</p>
|
||||
<p>
|
||||
Matches of the <em>regex</em> are replaced by the string <em>subst</em> with all
|
||||
<code>&</code> or <code>\0</code> in <em>subst</em> replaced with the match itself and all
|
||||
<code>\1</code> through <code>\9</code> replaced with the match of the corresponding sub-expression.
|
||||
To get a literal <code>&</code> or <code>\</code> or <code>/</code> in the substitution write
|
||||
<code>\&</code> or <code>\\</code> or <code>\/</code>.
|
||||
There is no way to specify literal bytes with values less or equal to 9 in the
|
||||
substitution!
|
||||
</p>
|
||||
<p>
|
||||
If <em>width</em> is specified, it limits the number of characters processed.
|
||||
If the <code>-</code> flag is used (i.e. <em>width</em> looks like a negative number)
|
||||
only the last <em>width</em> characters are processed, else the first.
|
||||
Without <em>width</em> (or 0) all available characters are processed.
|
||||
</p>
|
||||
<p>
|
||||
If <em>precision</em> is specified, it indicates which matches to replace.
|
||||
With the <code>+</code> flag given, <em>precision</em> is the maximum
|
||||
number of matches to replace.
|
||||
Otherwise <em>precision</em> is the index (counting from 1) of the match to replace.
|
||||
Without <em>precision</em> (or 0), all matches are replaced.
|
||||
</p>
|
||||
<p>
|
||||
In input this converter pre-processes data received from the device before
|
||||
following converters read it.
|
||||
Converters preceding this one will read unmodified input.
|
||||
Thus place this converter before those whose input should be pre-processed.
|
||||
</p>
|
||||
<p>
|
||||
In output it post-processes data already formatted by preceding converters
|
||||
before sending it to the device.
|
||||
Converters following this one will send their output unmodified.
|
||||
Thus place this converter after those whose output should be post-processed.
|
||||
</p>
|
||||
<p>
|
||||
Examples:
|
||||
<div class="indent">
|
||||
<code>%#+-10.2/ab/X/</code> replaces the string <code>ab</code> with <code>X</code>
|
||||
maximal 2 times in the last 10 characters.
|
||||
(<code>abcabcabcabc</code> becomes <code>abcXcXcabc</code>)
|
||||
</div>
|
||||
<div class="indent">
|
||||
<code>%#/\\/\//</code> replaces all <code>\</code> with <code>/</code>
|
||||
(<code>\dir\file</code> becomes <code>/dir/file</code>)
|
||||
</div>
|
||||
<div class="indent">
|
||||
<code>%#/..\B/&:/</code> inserts <code>:</code> after every second character
|
||||
which is not at the end of a word.
|
||||
(<code>0b19353134</code> becomes <code>0b:19:35:31:34</code>)
|
||||
</div>
|
||||
<div class="indent">
|
||||
<code>%#/://</code> removes all <code>:</code> characters.
|
||||
(<code>0b:19:35:31:34</code> becomes <code>0b19353134</code>)
|
||||
</div>
|
||||
<div class="indent">
|
||||
<code>%#/([^+-])*([+-])/\2\1/</code> moves a postfix sign to the front.
|
||||
(<code>1.23-</code> becomes <code>-1.23</code>)<br>
|
||||
</div>
|
||||
<a name="mantexp"></a>
|
||||
<h2>13. MantissaExponent DOUBLE converter (<code>%m</code>)</h2>
|
||||
<h2>15. MantissaExponent DOUBLE converter (<code>%m</code>)</h2>
|
||||
<p>
|
||||
This exotic and experimental format matches numbers in the format
|
||||
<i>[sign] mantissa sign exponent</i>, e.g <code>+123-4</code> meaning
|
||||
@ -564,9 +681,8 @@ Format flags <code>+</code>, <code>-</code>, and space are supported in
|
||||
the usual way (always sign, left justified, space instead of + sign).
|
||||
Flags <code>#</code> and <code>0</code> are unsupported.
|
||||
</p>
|
||||
<div class="new">
|
||||
<a name="timestamp"></a>
|
||||
<h2>14. Timestamp DOUBLE converter (<code>%T(<em>timeformat</em>)</code>)</h2>
|
||||
<h2>16. Timestamp DOUBLE converter (<code>%T(<em>timeformat</em>)</code>)</h2>
|
||||
<p>
|
||||
This format reads or writes timestamps and converts them to a double number.
|
||||
The value represents the number of seconds since 1970 (the UNIX epoch).
|
||||
@ -603,7 +719,7 @@ In output, the system function <em>strftime()</em> is used to format the time.
|
||||
There may be differences in the implementation between operating systems.
|
||||
</p>
|
||||
<p>
|
||||
In input, <em>StreamDevice</em> used its own implementation because many
|
||||
In input, <em>StreamDevice</em> uses its own implementation because many
|
||||
systems are missing the <em>strptime()</em> function and additional formats
|
||||
are supported.
|
||||
</p>
|
||||
@ -617,9 +733,8 @@ Because of the complexity of the problem, locales are not supported.
|
||||
Thus, only the English month names can be used (week day names are
|
||||
ignored anyway).
|
||||
</p>
|
||||
</div>
|
||||
<hr>
|
||||
<p align="right"><a href="processing.html">Next: Record Processing</a></p>
|
||||
<p><small>Dirk Zimoch, 2011</small></p>
|
||||
<p><small>Dirk Zimoch, 2015</small></p>
|
||||
</body>
|
||||
</html>
|
@ -88,11 +88,11 @@ many process variables distributed over many records.
|
||||
|
||||
<h2>Recommended Readings</h2>
|
||||
<p>
|
||||
<a href="http://www.aps.anl.gov/epics/base/R3-14/8-docs/AppDevGuide.pdf"
|
||||
target="ex">IOC Application Developer's Guide (PDF)</a>
|
||||
<a href="http://www.aps.anl.gov/epics/base/R3-14/12-docs/AppDevGuide"
|
||||
target="ex">IOC Application Developer's Guide</a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="http://www.aps.anl.gov/asd/controls/epics/EpicsDocumentation/AppDevManuals/RecordRef/Recordref-1.html"
|
||||
<a href="https://wiki-ext.aps.anl.gov/epics/index.php/RRM_3-14"
|
||||
target="ex">EPICS Record Reference Manual</a>
|
||||
</p>
|
||||
|
||||
@ -104,13 +104,8 @@ This marks text you typically type in configuration files etc.
|
||||
<pre>
|
||||
Longer code segments are often set in a box.
|
||||
</pre>
|
||||
<p>
|
||||
Important modifications and new features are
|
||||
<span class="new">highlighted with a yellow background</span>.
|
||||
Obsolete features are <strike class="new">highlighted and crossed out</strike>.
|
||||
</p>
|
||||
<hr>
|
||||
<p align="right"><a href="setup.html">Next: Setup</a></p>
|
||||
<p><small>Dirk Zimoch, 2011</small></p>
|
||||
<p><small>Dirk Zimoch, 2015</small></p>
|
||||
</body>
|
||||
</html>
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: longin Records</h1>
|
||||
<h1>longin Records</h1>
|
||||
|
||||
<h2>Normal Operation</h2>
|
||||
<p>
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: longout Records</h1>
|
||||
<h1>longout Records</h1>
|
||||
|
||||
<h2>Normal Operation</h2>
|
||||
<p>
|
43
documentation/makepdf
Executable file
@ -0,0 +1,43 @@
|
||||
#/bin/sh
|
||||
if ! wkhtmltopdf -V >/dev/null 2>&1
|
||||
then
|
||||
echo "wkhtmltopdf not installed."
|
||||
echo "See https://wkhtmltopdf.org"
|
||||
exit 1
|
||||
fi >&2
|
||||
|
||||
PAGES="
|
||||
index.html
|
||||
setup.html
|
||||
epics3_13.html
|
||||
protocol.html
|
||||
formats.html
|
||||
processing.html
|
||||
recordtypes.html
|
||||
aai.html
|
||||
aao.html
|
||||
ai.html
|
||||
ao.html
|
||||
bi.html
|
||||
bo.html
|
||||
mbbi.html
|
||||
mbbo.html
|
||||
mbbiDirect.html
|
||||
mbboDirect.html
|
||||
stringin.html
|
||||
stringout.html
|
||||
longin.html
|
||||
longout.html
|
||||
waveform.html
|
||||
calcout.html
|
||||
scalcout.html
|
||||
tipsandtricks.html
|
||||
recordinterface.html
|
||||
businterface.html
|
||||
formatconverter.html
|
||||
osinterface.html
|
||||
"
|
||||
|
||||
rm -f stream.pdf
|
||||
wkhtmltopdf --print-media-type --dpi 1200 --zoom 0.85 --page-size Letter \
|
||||
$PAGES stream.pdf
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: mbbi Records</h1>
|
||||
<h1>mbbi Records</h1>
|
||||
|
||||
<h2>Normal Operation</h2>
|
||||
<p>
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: mbbiDirect Records</h1>
|
||||
<h1>mbbiDirect Records</h1>
|
||||
|
||||
<h2>Normal Operation</h2>
|
||||
<p>
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: mbbo Records</h1>
|
||||
<h1>mbbo Records</h1>
|
||||
|
||||
<h2>Normal Operation</h2>
|
||||
<p>
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: mbboDirect Records</h1>
|
||||
<h1>mbboDirect Records</h1>
|
||||
|
||||
<h2>Normal Operation</h2>
|
||||
<p>
|
@ -132,6 +132,7 @@ div div div a {list-style-type:circle;}
|
||||
<a target="_parent" href="formats.html#bcd" title="Binary coded decimal LONG converter">%D</a>
|
||||
<a target="_parent" href="formats.html#chksum" title="Checksum pseudo converter">%<<em>checksum</em>></a>
|
||||
<a target="_parent" href="formats.html#regex" title="Perl regular expression STRING converter">%/<em>regex</em>/</a>
|
||||
<a target="_parent" href="formats.html#regsub" title="Perl regular expression substitution pseudo converter">%#/<em>regex</em>/<em>subst</em>/</a>
|
||||
<a target="_parent" href="formats.html#mantexp" title="MantissaExponent DOUBLE converter">%m</a>
|
||||
<a target="_parent" href="formats.html#timestamp" title="Timestamp DOUBLE converter">%T</a>
|
||||
</div>
|
||||
@ -178,6 +179,7 @@ div div div a {list-style-type:circle;}
|
||||
<a target="_parent" href="tipsandtricks.html#writemany">Write more than one value in one message</a>
|
||||
<a target="_parent" href="tipsandtricks.html#readmany">Read more than one value from one message</a>
|
||||
<a target="_parent" href="tipsandtricks.html#mixed">Read values of mixed data type</a>
|
||||
<a target="_parent" href="tipsandtricks.html#web">Read a web page</a>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: Operating System API</h1>
|
||||
<h1>Operating System API</h1>
|
||||
|
||||
<h2>Sorry, this documentation is still missing.</h2>
|
||||
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: Record Processing</h1>
|
||||
<h1>Record Processing</h1>
|
||||
|
||||
<a name="proc"></a>
|
||||
<h2>1. Normal Processing</h2>
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: Protocol Files</h1>
|
||||
<h1>Protocol Files</h1>
|
||||
<a name="gen"></a>
|
||||
<h2>1. General Information</h2>
|
||||
<p>
|
||||
@ -261,7 +261,7 @@ number in the range of <code>-128</code> to <code>255</code>,
|
||||
or <code>-0200</code> to <code>0377</code>, respectively.
|
||||
</p>
|
||||
<p>
|
||||
<em>StreamDevice</em> also recordgnizes the ASCII symbolic names
|
||||
<em>StreamDevice</em> also recognizes the ASCII symbolic names
|
||||
(not case sensitive) for several byte codes:<br>
|
||||
<code>NUL </code>(= <code>0x00</code>) <em>null</em><br>
|
||||
<code>SOH </code>(= <code>0x01</code>) <em>start of heading</em><br>
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: Record API</h1>
|
||||
<h1>Record API</h1>
|
||||
|
||||
<h2>Sorry, this documentation is still missing.</h2>
|
||||
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: Record Types</h1>
|
||||
<h1>Record Types</h1>
|
||||
|
||||
<h2>Supported Record Types</h2>
|
||||
<p>
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: scalcout Records</h1>
|
||||
<h1>scalcout Records</h1>
|
||||
|
||||
<p>
|
||||
<b>Note:</b> The scalcout record is part of the <i>calc</i> module of
|
||||
@ -29,7 +29,7 @@ before the final <code>return(0)</code>:
|
||||
</p>
|
||||
<pre class="box">
|
||||
if(pscalcoutDSET->init_record ) {
|
||||
return (*pscalcoutDSET->init_record)(pcalc);
|
||||
return (*pscalcoutDSET->init_record)(pcalc);
|
||||
}
|
||||
</pre>
|
||||
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: Setup</h1>
|
||||
<h1>Setup</h1>
|
||||
|
||||
<a name="pre"></a>
|
||||
<h2>1. Prerequisites</h2>
|
@ -5,8 +5,9 @@ a:hover {color: #FF0000;}
|
||||
body {
|
||||
margin-right:1em;
|
||||
margin-left:15em;
|
||||
margin-top:11ex;
|
||||
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
|
||||
margin-top:70px;
|
||||
padding-top:1px;
|
||||
font-family: Helvetica, Arial, sans-serif;
|
||||
font-size:14px;
|
||||
background-color:#ffffff;
|
||||
}
|
||||
@ -19,6 +20,7 @@ pre {
|
||||
border:1px solid #000000;
|
||||
white-space:pre;
|
||||
margin:2ex;
|
||||
page-break-inside:avoid;
|
||||
}
|
||||
|
||||
kbd {
|
||||
@ -30,26 +32,26 @@ dt {
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size:225%;
|
||||
font-size:250%;
|
||||
margin-top:0;
|
||||
font-style:italic;
|
||||
font-family:serif;
|
||||
font-weight:bold;
|
||||
font-family:"Times New Roman", serif;
|
||||
text-align:center;
|
||||
position:fixed;
|
||||
top:0;
|
||||
left:0;
|
||||
width:100%;
|
||||
min-height:60px;
|
||||
height: 4ex;
|
||||
line-height:190%;
|
||||
background-color:white;
|
||||
border-top:6px solid #1b4486;
|
||||
border-bottom:4px solid #1b4486;
|
||||
border-width:0;
|
||||
border-bottom:3px solid #1b4486;
|
||||
white-space:nowrap;
|
||||
background-image:url(PSI.gif);
|
||||
background-image:url(PSI.png);
|
||||
background-repeat:no-repeat;
|
||||
background-position:10px 2px;
|
||||
text-shadow: .1em .1em .1em lightgray;
|
||||
background-position:10px 5px;
|
||||
text-shadow:.1em .1em .1em darkgray;
|
||||
box-shadow:0 .3em .1em -.2em darkgray;
|
||||
}
|
||||
|
||||
h2 {
|
||||
@ -87,11 +89,21 @@ code {
|
||||
text-align:left;
|
||||
}
|
||||
|
||||
.box {
|
||||
margin-left:1ex;
|
||||
margin-right:1ex;
|
||||
margin-top:0.5ex;
|
||||
padding: 0 1ex;
|
||||
border: 1px solid black;
|
||||
text-align:left;
|
||||
background-color:#f0f0f0;
|
||||
}
|
||||
|
||||
#navleft {
|
||||
position:fixed;
|
||||
left:0;
|
||||
top:0;
|
||||
padding-top:9ex;
|
||||
padding-top:70px;
|
||||
width:14em;
|
||||
height:100%;
|
||||
border-style:solid;
|
||||
@ -115,13 +127,9 @@ a[target=ex]:hover:after {
|
||||
}
|
||||
|
||||
@media print {
|
||||
a:link {color: black; text-decoration:none;}
|
||||
a:visited {color: black; text-decoration:none;}
|
||||
a:hover {color: black; text-decoration:none;}
|
||||
a[target=ex] {text-decoration:underline;}
|
||||
a:link {text-decoration:none;}
|
||||
a[target=ex]:after {content:" [" attr(href) "]";}
|
||||
code {color: black; }
|
||||
body {margin-left:10px;}
|
||||
h1 {position:absolute;}
|
||||
body {margin:0 4em;}
|
||||
h1 {position:relative; background-position:0 0;}
|
||||
#navleft {display:none;}
|
||||
}
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: stringin Records</h1>
|
||||
<h1>stringin Records</h1>
|
||||
|
||||
<h2>Normal Operation</h2>
|
||||
<p>
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: stringout Records</h1>
|
||||
<h1>stringout Records</h1>
|
||||
|
||||
<h2>Normal Operation</h2>
|
||||
<p>
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: Tips and Tricks</h1>
|
||||
<h1>Tips and Tricks</h1>
|
||||
|
||||
<a name="argvar"></a>
|
||||
<h2>I have many almost identical protocols</h2>
|
||||
@ -103,7 +103,7 @@ an array: (3.14, 17.30, -12.34)
|
||||
<h3>B) We have up to 12 numeric values</h3>
|
||||
<p>
|
||||
Use a <a href="calcout.html">calcout</a> record and
|
||||
<a href="formats.html#types">field references</a> in the format.
|
||||
<a href="formats.html#redirection">redirection to fields</a>.
|
||||
</p>
|
||||
<p>
|
||||
<code>
|
||||
@ -128,7 +128,7 @@ record (calcout, "$(RECORD)") {<br>
|
||||
</p>
|
||||
<h3>C) Values are in other records on the same IOC</h3>
|
||||
<p>
|
||||
Use <a href="formats.html#types">record references</a> in the format.
|
||||
Use <a href="formats.html#redirection">redirection to records</a>.
|
||||
</p>
|
||||
<p>
|
||||
<code>
|
||||
@ -216,7 +216,7 @@ Any non-matching input is ignored by record B.
|
||||
</p>
|
||||
<h3>C) Values should be stored in other records on the same IOC</h3>
|
||||
<p>
|
||||
Use <a href="formats.html#types">record references</a> in the format.
|
||||
Use <a href="formats.html#redirection">redirection to records</a>.
|
||||
To avoid record names in protocol files, use
|
||||
<a href="protocol.html#argvar">protocol arguments</a>.
|
||||
</p>
|
||||
@ -244,11 +244,11 @@ processes record B.
|
||||
</p>
|
||||
|
||||
<a name="mixed"></a>
|
||||
<h2>I have a device that sends mixed data types: numbers and strings</h2>
|
||||
<h2>I have a device that sends mixed data types: numbers or strings</h2>
|
||||
<p>
|
||||
Use a <code>@mismatch</code>
|
||||
<a href="protocol.html#except">exception handler</a> and
|
||||
<a href="formats.html#types">record references</a> in the format.
|
||||
<a href="formats.html#redirection">redirection to records</a>.
|
||||
To avoid record names in protocol files, use
|
||||
<a href="protocol.html#argvar">protocol arguments</a>.
|
||||
</p>
|
||||
@ -260,7 +260,7 @@ When asked "<code>CURRENT?</code>", the device send something like
|
||||
</p>
|
||||
<p>
|
||||
<code>
|
||||
read_current {out "CURRENT?"; in "CURRENT %f A"; @mismatch {in "%(\1)39c";}}
|
||||
read_current {out "CURRENT?"; in "CURRENT %f A"; @mismatch {in "%(\$1)39c";}}
|
||||
</code>
|
||||
</p>
|
||||
<p>
|
||||
@ -281,7 +281,7 @@ With some more records, you can clean the message record if SEVR is not INVALID.
|
||||
<code>
|
||||
record (calcout, "$(DEVICE):clean_1") {<br>
|
||||
field (INPA, "$(DEVICE):readcurrent.SEVR CP")<br>
|
||||
field (CALC, "A!=2")<br>
|
||||
field (CALC, "A#3")<br>
|
||||
field (OOPT, "When Non-zero")<br>
|
||||
field (OUT, "$(DEVICE):clean_2.PROC")<br>
|
||||
}<br>
|
||||
@ -289,9 +289,124 @@ record (stringout, "$(DEVICE):clean_2") {<br>
|
||||
field (VAL, "OK")<br>
|
||||
field (OUT, "$(DEVICE):message PP")<br>
|
||||
}<br>
|
||||
|
||||
</code>
|
||||
<a name="web"></a>
|
||||
<h2>I need to read a web page</h2>
|
||||
<p>
|
||||
First you have to send a correctly formatted HTML request.
|
||||
Note that this request must contain the full URL like
|
||||
"http://server/page" and must be terminated with <u>two</u> newlines.
|
||||
The server should be the same as in the
|
||||
<a href="setup.html#sta"><code>drvAsynIPPortConfigure</code></a>
|
||||
command (if not using a http proxy).
|
||||
|
||||
The web page you get often contains much more information than you need.
|
||||
<a href="formats.html#regex">Regular expressions</a> are great
|
||||
to find what you are looking for.
|
||||
</p>
|
||||
<h3>Example 1</h3>
|
||||
<p>
|
||||
Read the title of a web page.
|
||||
</p>
|
||||
<p>
|
||||
<code>
|
||||
get_title {<br>
|
||||
extrainput = ignore;<br>
|
||||
replyTimeout = 1000;<br>
|
||||
out "GET http://\$1\n\n";<br>
|
||||
in "%+.1/(?im)<title>(.*)<\/title>/";<br>
|
||||
}
|
||||
</code>
|
||||
</p>
|
||||
<p>
|
||||
Terminate the request with two newlines, either explicit like here
|
||||
<u>or</u> using an
|
||||
<a href="protocol.html#sysvar"><code>outTerminator</code></a>.
|
||||
The URI (without http:// but including the web server host name)
|
||||
is passed as <a href="protocol.html#argvar">argument</a> 1 to <code>\$1</code>.
|
||||
Note that web servers may be slow, so allow some
|
||||
<a href="protocol.html#argvar"><code>replyTimeout</code></a>.
|
||||
</p>
|
||||
<p>
|
||||
If you don't use an <code>inTerminator</code> then the whole page is
|
||||
read as one "line" to the <code>in</code> command and can be parsed easily
|
||||
with a regular expression.
|
||||
We want to see the string between <code><title></code> and
|
||||
<code></title></code>, so we put it into a subexpression in
|
||||
<code>()</code> and request the first subexpression with <code>.1</code>.
|
||||
Note that the <code>/</code> in the closing tag has be be escaped
|
||||
to avoid a misinterpretation as the closing <code>/</code> of the regular
|
||||
expression.
|
||||
</p>
|
||||
<p>
|
||||
The tags may be upper or lower case like <code><TITLE></code> or
|
||||
<code><Title></code>, so we ask for case insensitive matching with
|
||||
<code>(?i)</code>.
|
||||
</p>
|
||||
<p>
|
||||
The string should be terminated with the first closing
|
||||
<code></title></code>, not the last one in the file.
|
||||
(There should not be more than one title but you never know.)
|
||||
Thus we ask not to be greedy with <code>(?m)</code>.
|
||||
<code>(?i)</code> and <code>(?m)</code> can be combined to <code>(?im)</code>.
|
||||
See the PCRE documentation for more regexp syntax.
|
||||
</p>
|
||||
<p>
|
||||
The regular expression matcher ignores and discards any content before the
|
||||
matching section.
|
||||
Content after the match is discarded with <code>extrainput = ignore</code>
|
||||
so that it does not trigger errors reporting "surplus input".
|
||||
</p>
|
||||
<p>
|
||||
Finally, the title may be too long for the record.
|
||||
The <code>+</code> tells the format matcher not to fail in this case
|
||||
but to truncate the string instead.
|
||||
You can read the string with a stringin record or for longer strings with
|
||||
a waveform record with data type CHAR.
|
||||
</p>
|
||||
<p>
|
||||
<code>
|
||||
record (stringin, "$(DEVICE):title") {<br>
|
||||
field (DTYP, "stream")<br>
|
||||
field (INP, "@$(DEVICETYPE).proto get_title($(PAGE)) $(BUS)")<br>
|
||||
}<br>
|
||||
record (waveform, "$(DEVICE):longtitle") {<br>
|
||||
field (DTYP, "stream")<br>
|
||||
field (INP, "@$(DEVICETYPE).proto get_title($(PAGE)) $(BUS)")<br>
|
||||
field (FTVL, "CHAR")<br>
|
||||
field (NELM, "100")<br>
|
||||
}<br>
|
||||
</code>
|
||||
</p>
|
||||
|
||||
<h3>Example 2</h3>
|
||||
<p>
|
||||
Read a number from a web page. First we have to locate the number.
|
||||
For that we match against any known string right before the number
|
||||
(and <a href="formats.html#syntax">discard the match</a> with <code>*</code>).
|
||||
Then we read the number.
|
||||
</p>
|
||||
<code>
|
||||
get_title {<br>
|
||||
extrainput = ignore;<br>
|
||||
replyTimeout = 1000;<br>
|
||||
out "GET http://\$1\n\n";<br>
|
||||
in "%*/Interesting value:/%f more text";<br>
|
||||
}
|
||||
</code>
|
||||
<p>
|
||||
When using <code>extrainput = ignore;</code>, it is always a good idea to
|
||||
match a few bytes after the value, too.
|
||||
This catches errors where loading of the page is interrupted in the middle
|
||||
of the number. (You don't want to miss the exponent from something like 1.23E-14).
|
||||
</p>
|
||||
<p>
|
||||
You can read more than one value from a file with successive regular expressions
|
||||
and <a href="formats.html#redirection">redirections</a>.
|
||||
But this only works if the order of the values is predictible.
|
||||
<i>StreamDevice</i> is not an XML parser! It always reads sequentially.
|
||||
</p>
|
||||
<hr>
|
||||
<p><small>Dirk Zimoch, 2007</small></p>
|
||||
<p><small>Dirk Zimoch, 2012</small></p>
|
||||
</body>
|
||||
</html>
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: waveform Records</h1>
|
||||
<h1>waveform Records</h1>
|
||||
|
||||
<h2>Normal Operation</h2>
|
||||
<p>
|
57
makefile
@ -1,57 +0,0 @@
|
||||
include /ioc/tools/driver.makefile
|
||||
EXCLUDE_VERSIONS = 3.13.2
|
||||
PROJECT=stream2
|
||||
BUILDCLASSES += Linux
|
||||
|
||||
#DOCUDIR = doc
|
||||
|
||||
DBDS = stream.dbd
|
||||
|
||||
BUSSES += AsynDriver
|
||||
BUSSES += Dummy
|
||||
|
||||
FORMATS += Enum
|
||||
FORMATS += BCD
|
||||
FORMATS += Raw
|
||||
FORMATS += RawFloat
|
||||
FORMATS += Binary
|
||||
FORMATS += Checksum
|
||||
FORMATS += Regexp
|
||||
FORMATS += MantissaExponent
|
||||
FORMATS += Timestamp
|
||||
|
||||
RECORDTYPES += aai aao
|
||||
RECORDTYPES += ao ai
|
||||
RECORDTYPES += bo bi
|
||||
RECORDTYPES += mbbo mbbi
|
||||
RECORDTYPES += mbboDirect mbbiDirect
|
||||
RECORDTYPES += longout longin
|
||||
RECORDTYPES += stringout stringin
|
||||
RECORDTYPES += waveform
|
||||
|
||||
SOURCES += $(RECORDTYPES:%=src/dev%Stream.c)
|
||||
SOURCES += $(FORMATS:%=src/%Converter.cc)
|
||||
SOURCES += $(BUSSES:%=src/%Interface.cc)
|
||||
SOURCES += $(wildcard src/Stream*.cc)
|
||||
SOURCES += src/StreamVersion.c
|
||||
|
||||
HEADERS += StreamFormat.h
|
||||
HEADERS += StreamFormatConverter.h
|
||||
HEADERS += StreamBuffer.h
|
||||
HEADERS += StreamError.h
|
||||
|
||||
ifeq (${EPICS_BASETYPE},3.13)
|
||||
USR_INCLUDES += -include $(INSTALL_INCLUDE)/compat3_13.h
|
||||
endif
|
||||
ifeq (${EPICS_BASETYPE},3.14)
|
||||
RECORDTYPES += calcout
|
||||
endif
|
||||
|
||||
StreamCore.o: streamReferences
|
||||
|
||||
streamReferences:
|
||||
perl ../src/makeref.pl Interface $(BUSSES) > $@
|
||||
perl ../src/makeref.pl Converter $(FORMATS) >> $@
|
||||
|
||||
stream.dbd:
|
||||
perl ../src/makedbd.pl $(RECORDTYPES) > $@
|
@ -22,14 +22,14 @@
|
||||
#include "StreamError.h"
|
||||
#include "StreamBuffer.h"
|
||||
|
||||
#ifdef EPICS_3_14
|
||||
#include <epicsAssert.h>
|
||||
#include <epicsTime.h>
|
||||
#include <epicsTimer.h>
|
||||
#else
|
||||
#ifdef EPICS_3_13
|
||||
#include <assert.h>
|
||||
#include <wdLib.h>
|
||||
#include <sysLib.h>
|
||||
#else
|
||||
#include <epicsAssert.h>
|
||||
#include <epicsTime.h>
|
||||
#include <epicsTimer.h>
|
||||
extern "C" {
|
||||
#include <callback.h>
|
||||
}
|
||||
@ -126,7 +126,7 @@ static const char* ioActionStr[] = {
|
||||
};
|
||||
|
||||
static const char* asynStatusStr[] = {
|
||||
"asynSuccess", "asynTimeout", "asynOverflow", "asynError"
|
||||
"asynSuccess", "asynTimeout", "asynOverflow", "asynError", "asynDisconnected", "asynDisabled"
|
||||
};
|
||||
|
||||
static const char* eomReasonStr[] = {
|
||||
@ -134,7 +134,7 @@ static const char* eomReasonStr[] = {
|
||||
};
|
||||
|
||||
class AsynDriverInterface : StreamBusInterface
|
||||
#ifdef EPICS_3_14
|
||||
#ifndef EPICS_3_13
|
||||
, epicsTimerNotify
|
||||
#endif
|
||||
{
|
||||
@ -164,12 +164,12 @@ class AsynDriverInterface : StreamBusInterface
|
||||
const char* outputBuffer;
|
||||
size_t outputSize;
|
||||
int peeksize;
|
||||
#ifdef EPICS_3_14
|
||||
epicsTimerQueueActive* timerQueue;
|
||||
epicsTimer* timer;
|
||||
#else
|
||||
#ifdef EPICS_3_13
|
||||
WDOG_ID timer;
|
||||
CALLBACK timeoutCallback;
|
||||
#else
|
||||
epicsTimerQueueActive* timerQueue;
|
||||
epicsTimer* timer;
|
||||
#endif
|
||||
|
||||
AsynDriverInterface(Client* client);
|
||||
@ -189,16 +189,16 @@ class AsynDriverInterface : StreamBusInterface
|
||||
bool disconnectRequest();
|
||||
void finish();
|
||||
|
||||
#ifdef EPICS_3_14
|
||||
#ifdef EPICS_3_13
|
||||
static void expire(CALLBACK *pcallback);
|
||||
#else
|
||||
// epicsTimerNotify methods
|
||||
epicsTimerNotify::expireStatus expire(const epicsTime &);
|
||||
#else
|
||||
static void expire(CALLBACK *pcallback);
|
||||
#endif
|
||||
|
||||
// local methods
|
||||
void timerExpired();
|
||||
bool connectToBus(const char* busname, int addr);
|
||||
bool connectToBus(const char* portname, int addr);
|
||||
void lockHandler();
|
||||
void writeHandler();
|
||||
void readHandler();
|
||||
@ -211,20 +211,22 @@ class AsynDriverInterface : StreamBusInterface
|
||||
(StreamBusInterface::priority());
|
||||
}
|
||||
void startTimer(double timeout) {
|
||||
#ifdef EPICS_3_14
|
||||
timer->start(*this, timeout);
|
||||
#else
|
||||
#ifdef EPICS_3_13
|
||||
callbackSetPriority(priority(), &timeoutCallback);
|
||||
wdStart(timer, (int)((timeout+1)*sysClkRateGet())-1,
|
||||
reinterpret_cast<FUNCPTR>(callbackRequest),
|
||||
reinterpret_cast<int>(&timeoutCallback));
|
||||
#else
|
||||
timer->start(*this, timeout
|
||||
+epicsThreadSleepQuantum()*0.5
|
||||
);
|
||||
#endif
|
||||
}
|
||||
void cancelTimer() {
|
||||
#ifdef EPICS_3_14
|
||||
timer->cancel();
|
||||
#else
|
||||
#ifdef EPICS_3_13
|
||||
wdCancel(timer);
|
||||
#else
|
||||
timer->cancel();
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -240,7 +242,7 @@ class AsynDriverInterface : StreamBusInterface
|
||||
public:
|
||||
// static creator method
|
||||
static StreamBusInterface* getBusInterface(Client* client,
|
||||
const char* busname, int addr, const char* param);
|
||||
const char* portname, int addr, const char* param);
|
||||
};
|
||||
|
||||
RegisterStreamBusInterface(AsynDriverInterface);
|
||||
@ -248,6 +250,7 @@ RegisterStreamBusInterface(AsynDriverInterface);
|
||||
AsynDriverInterface::
|
||||
AsynDriverInterface(Client* client) : StreamBusInterface(client)
|
||||
{
|
||||
debug ("AsynDriverInterface(%s)\n", client->name());
|
||||
pasynCommon = NULL;
|
||||
pasynOctet = NULL;
|
||||
intrPvtOctet = NULL;
|
||||
@ -259,20 +262,25 @@ AsynDriverInterface(Client* client) : StreamBusInterface(client)
|
||||
eventMask = 0;
|
||||
receivedEvent = 0;
|
||||
peeksize = 1;
|
||||
debug ("AsynDriverInterface(%s) createAsynUser\n", client->name());
|
||||
pasynUser = pasynManager->createAsynUser(handleRequest,
|
||||
handleTimeout);
|
||||
assert(pasynUser);
|
||||
pasynUser->userPvt = this;
|
||||
#ifdef EPICS_3_14
|
||||
timerQueue = &epicsTimerQueueActive::allocate(true);
|
||||
assert(timerQueue);
|
||||
timer = &timerQueue->createTimer();
|
||||
assert(timer);
|
||||
#else
|
||||
#ifdef EPICS_3_13
|
||||
debug ("AsynDriverInterface(%s) wdCreate()\n", client->name());
|
||||
timer = wdCreate();
|
||||
callbackSetCallback(expire, &timeoutCallback);
|
||||
callbackSetUser(this, &timeoutCallback);
|
||||
#else
|
||||
debug ("AsynDriverInterface(%s) epicsTimerQueueActive::allocate(true)\n", client->name());
|
||||
timerQueue = &epicsTimerQueueActive::allocate(true);
|
||||
assert(timerQueue);
|
||||
debug ("AsynDriverInterface(%s) timerQueue->createTimer()\n", client->name());
|
||||
timer = &timerQueue->createTimer();
|
||||
assert(timer);
|
||||
#endif
|
||||
debug ("AsynDriverInterface(%s) done\n", client->name());
|
||||
}
|
||||
|
||||
AsynDriverInterface::
|
||||
@ -306,11 +314,11 @@ AsynDriverInterface::
|
||||
}
|
||||
// Now, no handler is running any more and none will start.
|
||||
|
||||
#ifdef EPICS_3_14
|
||||
#ifdef EPICS_3_13
|
||||
wdDelete(timer);
|
||||
#else
|
||||
timer->destroy();
|
||||
timerQueue->release();
|
||||
#else
|
||||
wdDelete(timer);
|
||||
#endif
|
||||
pasynManager->disconnect(pasynUser);
|
||||
pasynManager->freeAsynUser(pasynUser);
|
||||
@ -318,17 +326,19 @@ AsynDriverInterface::
|
||||
}
|
||||
|
||||
// interface function getBusInterface():
|
||||
// do we have this bus/addr ?
|
||||
// do we have this port/addr ?
|
||||
StreamBusInterface* AsynDriverInterface::
|
||||
getBusInterface(Client* client,
|
||||
const char* busname, int addr, const char*)
|
||||
const char* portname, int addr, const char*)
|
||||
{
|
||||
debug ("AsynDriverInterface::getBusInterface(%s, %s, %d)\n",
|
||||
client->name(), portname, addr);
|
||||
AsynDriverInterface* interface = new AsynDriverInterface(client);
|
||||
if (interface->connectToBus(busname, addr))
|
||||
if (interface->connectToBus(portname, addr))
|
||||
{
|
||||
debug ("AsynDriverInterface::getBusInterface(%s, %d): "
|
||||
"new Interface allocated\n",
|
||||
busname, addr);
|
||||
"new interface allocated\n",
|
||||
portname, addr);
|
||||
return interface;
|
||||
}
|
||||
delete interface;
|
||||
@ -340,7 +350,66 @@ getBusInterface(Client* client,
|
||||
bool AsynDriverInterface::
|
||||
supportsEvent()
|
||||
{
|
||||
return (pasynInt32 != NULL) || (pasynUInt32 != NULL);
|
||||
if (intrPvtInt32 || intrPvtUInt32) return true;
|
||||
|
||||
// look for interfaces for events
|
||||
asynInterface* pasynInterface;
|
||||
|
||||
pasynInterface = pasynManager->findInterface(pasynUser,
|
||||
asynInt32Type, true);
|
||||
if (pasynInterface)
|
||||
{
|
||||
pasynInt32 = static_cast<asynInt32*>(pasynInterface->pinterface);
|
||||
pvtInt32 = pasynInterface->drvPvt;
|
||||
pasynUser->reason = ASYN_REASON_SIGNAL; // required for GPIB
|
||||
if (pasynInt32->registerInterruptUser(pvtInt32, pasynUser,
|
||||
intrCallbackInt32, this, &intrPvtInt32) == asynSuccess)
|
||||
{
|
||||
printf ("%s: AsynDriverInterface::supportsEvent: "
|
||||
"pasynInt32->registerInterruptUser(%p, %p, %p, %p, %p)\n",
|
||||
clientName(), pvtInt32, pasynUser,
|
||||
intrCallbackInt32, this, &intrPvtInt32);
|
||||
return true;
|
||||
}
|
||||
const char *portname;
|
||||
pasynManager->getPortName(pasynUser, &portname);
|
||||
error("%s: port %s does not allow to register for "
|
||||
"Int32 interrupts: %s\n",
|
||||
clientName(), portname, pasynUser->errorMessage);
|
||||
pasynInt32 = NULL;
|
||||
intrPvtInt32 = NULL;
|
||||
}
|
||||
|
||||
// no asynInt32 available, thus try asynUInt32
|
||||
pasynInterface = pasynManager->findInterface(pasynUser,
|
||||
asynUInt32DigitalType, true);
|
||||
if (pasynInterface)
|
||||
{
|
||||
pasynUInt32 =
|
||||
static_cast<asynUInt32Digital*>(pasynInterface->pinterface);
|
||||
pvtUInt32 = pasynInterface->drvPvt;
|
||||
pasynUser->reason = ASYN_REASON_SIGNAL;
|
||||
if (pasynUInt32->registerInterruptUser(pvtUInt32,
|
||||
pasynUser, intrCallbackUInt32, this, 0xFFFFFFFF,
|
||||
&intrPvtUInt32) == asynSuccess)
|
||||
{
|
||||
printf ("%s: AsynDriverInterface::supportsEvent: "
|
||||
"pasynUInt32->registerInterruptUser(%p, %p, %p, %p, %#X, %p)\n",
|
||||
clientName(), pvtUInt32, pasynUser,
|
||||
intrCallbackUInt32, this, 0xFFFFFFFF, &intrPvtInt32);
|
||||
return true;
|
||||
}
|
||||
const char *portname;
|
||||
pasynManager->getPortName(pasynUser, &portname);
|
||||
error("%s: port %s does not allow to register for "
|
||||
"UInt32 interrupts: %s\n",
|
||||
clientName(), portname, pasynUser->errorMessage);
|
||||
pasynUInt32 = NULL;
|
||||
intrPvtUInt32 = NULL;
|
||||
}
|
||||
|
||||
// no event interface available
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AsynDriverInterface::
|
||||
@ -352,20 +421,32 @@ supportsAsyncRead()
|
||||
if (pasynOctet->registerInterruptUser(pvtOctet, pasynUser,
|
||||
intrCallbackOctet, this, &intrPvtOctet) != asynSuccess)
|
||||
{
|
||||
error("%s: bus does not support asynchronous input: %s\n",
|
||||
clientName(), pasynUser->errorMessage);
|
||||
const char *portname;
|
||||
int addr;
|
||||
pasynManager->getPortName(pasynUser, &portname);
|
||||
pasynManager->getAddr(pasynUser, &addr);
|
||||
if (addr >= 0)
|
||||
error("%s: asyn port %s addr %d does not support asynchronous input: %s\n",
|
||||
clientName(), portname, addr, pasynUser->errorMessage);
|
||||
else
|
||||
error("%s: asyn port %s does not support asynchronous input: %s\n",
|
||||
clientName(), portname, pasynUser->errorMessage);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AsynDriverInterface::
|
||||
connectToBus(const char* busname, int addr)
|
||||
connectToBus(const char* portname, int addr)
|
||||
{
|
||||
if (pasynManager->connectDevice(pasynUser, busname, addr) !=
|
||||
asynSuccess)
|
||||
asynStatus status = pasynManager->connectDevice(pasynUser, portname, addr);
|
||||
debug("%s: AsynDriverInterface::connectToBus(%s, %d): "
|
||||
"pasynManager->connectDevice(%p, %s, %d) = %s\n",
|
||||
clientName(), portname, addr, pasynUser,portname, addr,
|
||||
asynStatusStr[status]);
|
||||
if (status != asynSuccess)
|
||||
{
|
||||
// asynDriver does not know this busname/address
|
||||
// asynDriver does not know this portname/address
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -374,10 +455,10 @@ connectToBus(const char* busname, int addr)
|
||||
// find the asynCommon interface
|
||||
pasynInterface = pasynManager->findInterface(pasynUser,
|
||||
asynCommonType, true);
|
||||
if(!pasynInterface)
|
||||
if (!pasynInterface)
|
||||
{
|
||||
error("%s: bus %s does not support asynCommon interface\n",
|
||||
clientName(), busname);
|
||||
error("%s: asyn port %s does not support asynCommon interface\n",
|
||||
clientName(), portname);
|
||||
return false;
|
||||
}
|
||||
pasynCommon = static_cast<asynCommon*>(pasynInterface->pinterface);
|
||||
@ -386,10 +467,10 @@ connectToBus(const char* busname, int addr)
|
||||
// find the asynOctet interface
|
||||
pasynInterface = pasynManager->findInterface(pasynUser,
|
||||
asynOctetType, true);
|
||||
if(!pasynInterface)
|
||||
if (!pasynInterface)
|
||||
{
|
||||
error("%s: bus %s does not support asynOctet interface\n",
|
||||
clientName(), busname);
|
||||
error("%s: asyn port %s does not support asynOctet interface\n",
|
||||
clientName(), portname);
|
||||
return false;
|
||||
}
|
||||
pasynOctet = static_cast<asynOctet*>(pasynInterface->pinterface);
|
||||
@ -398,7 +479,7 @@ connectToBus(const char* busname, int addr)
|
||||
// is it a GPIB interface ?
|
||||
pasynInterface = pasynManager->findInterface(pasynUser,
|
||||
asynGpibType, true);
|
||||
if(pasynInterface)
|
||||
if (pasynInterface)
|
||||
{
|
||||
pasynGpib = static_cast<asynGpib*>(pasynInterface->pinterface);
|
||||
pvtGpib = pasynInterface->drvPvt;
|
||||
@ -406,50 +487,6 @@ connectToBus(const char* busname, int addr)
|
||||
// (read only one byte first).
|
||||
peeksize = inputBuffer.capacity();
|
||||
}
|
||||
|
||||
// look for interfaces for events
|
||||
pasynInterface = pasynManager->findInterface(pasynUser,
|
||||
asynInt32Type, true);
|
||||
if(pasynInterface)
|
||||
{
|
||||
pasynInt32 = static_cast<asynInt32*>(pasynInterface->pinterface);
|
||||
pvtInt32 = pasynInterface->drvPvt;
|
||||
pasynUser->reason = ASYN_REASON_SIGNAL; // required for GPIB
|
||||
if (pasynInt32->registerInterruptUser(pvtInt32, pasynUser,
|
||||
intrCallbackInt32, this, &intrPvtInt32) == asynSuccess)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
error("%s: bus %s does not allow to register for "
|
||||
"Int32 interrupts: %s\n",
|
||||
clientName(), busname, pasynUser->errorMessage);
|
||||
pasynInt32 = NULL;
|
||||
intrPvtInt32 = NULL;
|
||||
}
|
||||
|
||||
// no asynInt32 available, thus try asynUInt32
|
||||
pasynInterface = pasynManager->findInterface(pasynUser,
|
||||
asynUInt32DigitalType, true);
|
||||
if(pasynInterface)
|
||||
{
|
||||
pasynUInt32 =
|
||||
static_cast<asynUInt32Digital*>(pasynInterface->pinterface);
|
||||
pvtUInt32 = pasynInterface->drvPvt;
|
||||
pasynUser->reason = ASYN_REASON_SIGNAL;
|
||||
if (pasynUInt32->registerInterruptUser(pvtUInt32,
|
||||
pasynUser, intrCallbackUInt32, this, 0xFFFFFFFF,
|
||||
&intrPvtUInt32) == asynSuccess)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
error("%s: bus %s does not allow to register for "
|
||||
"UInt32 interrupts: %s\n",
|
||||
clientName(), busname, pasynUser->errorMessage);
|
||||
pasynUInt32 = NULL;
|
||||
intrPvtUInt32 = NULL;
|
||||
}
|
||||
|
||||
// no event interface available, never mind
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -458,23 +495,14 @@ connectToBus(const char* busname, int addr)
|
||||
bool AsynDriverInterface::
|
||||
lockRequest(unsigned long lockTimeout_ms)
|
||||
{
|
||||
int connected;
|
||||
asynStatus status;
|
||||
|
||||
debug("AsynDriverInterface::lockRequest(%s, %ld msec)\n",
|
||||
clientName(), lockTimeout_ms);
|
||||
lockTimeout = lockTimeout_ms ? lockTimeout_ms*0.001 : -1.0;
|
||||
ioAction = Lock;
|
||||
status = pasynManager->isConnected(pasynUser, &connected);
|
||||
if (status != asynSuccess)
|
||||
{
|
||||
error("%s: pasynManager->isConnected() failed: %s\n",
|
||||
clientName(), pasynUser->errorMessage);
|
||||
return false;
|
||||
}
|
||||
status = pasynManager->queueRequest(pasynUser,
|
||||
connected ? priority() : asynQueuePriorityConnect,
|
||||
lockTimeout);
|
||||
priority(), lockTimeout);
|
||||
if (status != asynSuccess)
|
||||
{
|
||||
error("%s lockRequest: pasynManager->queueRequest() failed: %s\n",
|
||||
@ -496,9 +524,13 @@ connectToAsynPort()
|
||||
debug("AsynDriverInterface::connectToAsynPort(%s)\n",
|
||||
clientName());
|
||||
status = pasynManager->isConnected(pasynUser, &connected);
|
||||
debug("%s: AsynDriverInterface::connectToAsynPort: "
|
||||
"pasynManager->isConnected(%p, %p) = %s => %s\n",
|
||||
clientName(), pasynUser, &connected, asynStatusStr[status],
|
||||
connected ? "yes" : "no");
|
||||
if (status != asynSuccess)
|
||||
{
|
||||
error("%s: pasynManager->isConnected() failed: %s\n",
|
||||
error("%s connectToAsynPort: pasynManager->isConnected() failed: %s\n",
|
||||
clientName(), pasynUser->errorMessage);
|
||||
return false;
|
||||
}
|
||||
@ -516,7 +548,7 @@ connectToAsynPort()
|
||||
status = pasynOctet->read(pvtOctet, pasynUser,
|
||||
buffer, 0, &received, &eomReason);
|
||||
debug("AsynDriverInterface::connectToAsynPort(%s): "
|
||||
"read(..., 0, ...) [timeout=%f seconds] = %s\n",
|
||||
"read(..., 0, ...) [timeout=%g sec] = %s\n",
|
||||
clientName(), pasynUser->timeout,
|
||||
asynStatusStr[status]);
|
||||
pasynManager->isConnected(pasynUser, &connected);
|
||||
@ -530,13 +562,19 @@ connectToAsynPort()
|
||||
clientName(), connected ? "already" : "not yet");
|
||||
if (!connected)
|
||||
{
|
||||
printf ("%s: AsynDriverInterface::connectToAsynPort: "
|
||||
"pasynCommon->connect(%p, %p)\n",
|
||||
clientName(), pvtCommon, pasynUser);
|
||||
status = pasynCommon->connect(pvtCommon, pasynUser);
|
||||
printf ("%s: AsynDriverInterface::connectToAsynPort: "
|
||||
"pasynCommon->connect(%p, %p) = %s\n",
|
||||
clientName(), pvtCommon, pasynUser, asynStatusStr[status]);
|
||||
debug("AsynDriverInterface::connectToAsynPort(%s): "
|
||||
"status=%s\n",
|
||||
clientName(), asynStatusStr[status]);
|
||||
if (status != asynSuccess)
|
||||
{
|
||||
error("%s: pasynCommon->connect() failed: %s\n",
|
||||
error("%s connectToAsynPort: pasynCommon->connect() failed: %s\n",
|
||||
clientName(), pasynUser->errorMessage);
|
||||
return false;
|
||||
}
|
||||
@ -554,21 +592,37 @@ connectToAsynPort()
|
||||
void AsynDriverInterface::
|
||||
lockHandler()
|
||||
{
|
||||
int connected;
|
||||
asynStatus status;
|
||||
|
||||
debug("AsynDriverInterface::lockHandler(%s)\n",
|
||||
clientName());
|
||||
pasynManager->blockProcessCallback(pasynUser, false);
|
||||
connected = connectToAsynPort();
|
||||
lockCallback(connected ? StreamIoSuccess : StreamIoFault);
|
||||
|
||||
status = pasynManager->blockProcessCallback(pasynUser, false);
|
||||
if (status != asynSuccess)
|
||||
{
|
||||
error("%s lockHandler: pasynManager->blockProcessCallback() failed: %s\n",
|
||||
clientName(), pasynUser->errorMessage);
|
||||
lockCallback(StreamIoFault);
|
||||
return;
|
||||
}
|
||||
lockCallback(StreamIoSuccess);
|
||||
}
|
||||
|
||||
// interface function: we don't need exclusive access any more
|
||||
bool AsynDriverInterface::
|
||||
unlock()
|
||||
{
|
||||
asynStatus status;
|
||||
|
||||
debug("AsynDriverInterface::unlock(%s)\n",
|
||||
clientName());
|
||||
pasynManager->unblockProcessCallback(pasynUser, false);
|
||||
status = pasynManager->unblockProcessCallback(pasynUser, false);
|
||||
if (status != asynSuccess)
|
||||
{
|
||||
error("%s unlock: pasynManager->unblockProcessCallback() failed: %s\n",
|
||||
clientName(), pasynUser->errorMessage);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -610,19 +664,39 @@ writeHandler()
|
||||
clientName());
|
||||
asynStatus status;
|
||||
size_t written = 0;
|
||||
pasynUser->timeout = writeTimeout;
|
||||
|
||||
// discard any early input or early events
|
||||
status = pasynOctet->flush(pvtOctet, pasynUser);
|
||||
receivedEvent = 0;
|
||||
|
||||
if (status != asynSuccess)
|
||||
pasynUser->timeout = 0;
|
||||
if (!pasynGpib)
|
||||
// discard any early input, but forward it to potential async records
|
||||
// thus do not use pasynOctet->flush()
|
||||
// unfortunately we cannot do this with GPIB because addressing a device as talker
|
||||
// when it has nothing to say is an error. Also timeout=0 does not help here (would need
|
||||
// a change in asynGPIB), thus use flush() for GPIB.
|
||||
do {
|
||||
char buffer [256];
|
||||
size_t received = 0;
|
||||
int eomReason = 0;
|
||||
debug("AsynDriverInterface::writeHandler(%s): reading old input\n",
|
||||
clientName());
|
||||
status = pasynOctet->read(pvtOctet, pasynUser,
|
||||
buffer, sizeof(buffer), &received, &eomReason);
|
||||
if (status == asynError || received == 0) break;
|
||||
#ifndef NO_TEMPORARY
|
||||
if (received) debug("AsynDriverInterface::writeHandler(%s): flushing %ld bytes: \"%s\"\n",
|
||||
clientName(), (long)received, StreamBuffer(buffer, received).expand()());
|
||||
#endif
|
||||
} while (status == asynSuccess);
|
||||
else
|
||||
{
|
||||
error("%s: pasynOctet->flush() failed: %s\n",
|
||||
clientName(), pasynUser->errorMessage);
|
||||
writeCallback(StreamIoFault);
|
||||
return;
|
||||
debug("AsynDriverInterface::writeHandler(%s): flushing old input\n",
|
||||
clientName());
|
||||
pasynOctet->flush(pvtOctet, pasynUser);
|
||||
}
|
||||
|
||||
// discard any early events
|
||||
receivedEvent = 0;
|
||||
|
||||
pasynUser->timeout = writeTimeout;
|
||||
|
||||
// has stream already added a terminator or should
|
||||
// asyn do so?
|
||||
@ -644,14 +718,26 @@ writeHandler()
|
||||
pasynOctet->setOutputEos(pvtOctet, pasynUser,
|
||||
NULL, 0);
|
||||
}
|
||||
pasynUser->errorMessage[0] = 0;
|
||||
status = pasynOctet->write(pvtOctet, pasynUser,
|
||||
outputBuffer, outputSize, &written);
|
||||
#ifndef NO_TEMPORARY
|
||||
debug("AsynDriverInterface::writeHandler(%s): "
|
||||
"write(..., outputSize=%ld, written=%ld) "
|
||||
"[timeout=%f seconds] = %s\n",
|
||||
clientName(), (long)outputSize, (long)written,
|
||||
pasynUser->timeout, asynStatusStr[status]);
|
||||
"write(..., \"%s\", outputSize=%ld, written=%ld) "
|
||||
"[timeout=%g sec] = %s (%s)\n",
|
||||
clientName(),
|
||||
StreamBuffer(outputBuffer, outputSize).expand()(),
|
||||
(long)outputSize, (long)written,
|
||||
pasynUser->timeout, asynStatusStr[status],
|
||||
pasynUser->errorMessage);
|
||||
#endif
|
||||
|
||||
if (oldeoslen >= 0) // restore asyn terminator
|
||||
{
|
||||
pasynOctet->setOutputEos(pvtOctet, pasynUser,
|
||||
oldeos, oldeoslen);
|
||||
}
|
||||
|
||||
// Up to asyn 4.17 I can't see when the server has disconnected. Why?
|
||||
int connected;
|
||||
pasynManager->isConnected(pasynUser, &connected);
|
||||
@ -659,17 +745,12 @@ writeHandler()
|
||||
"device is %sconnected\n",
|
||||
clientName(),connected?"":"dis");
|
||||
if (!connected) {
|
||||
error("%s: connection closed in write\n",
|
||||
error("%s: write failed because connection was closed by device\n",
|
||||
clientName());
|
||||
writeCallback(StreamIoFault);
|
||||
return;
|
||||
}
|
||||
|
||||
if (oldeoslen >= 0) // restore asyn terminator
|
||||
{
|
||||
pasynOctet->setOutputEos(pvtOctet, pasynUser,
|
||||
oldeos, oldeoslen);
|
||||
}
|
||||
switch (status)
|
||||
{
|
||||
case asynSuccess:
|
||||
@ -694,32 +775,34 @@ writeHandler()
|
||||
writeCallback(StreamIoSuccess);
|
||||
return;
|
||||
case asynTimeout:
|
||||
error("%s: asynTimeout (%g sec) in write. Asyn driver says: \"%s\"\n",
|
||||
clientName(), pasynUser->timeout, pasynUser->errorMessage);
|
||||
writeCallback(StreamIoTimeout);
|
||||
return;
|
||||
case asynOverflow:
|
||||
error("%s: asynOverflow in write: %s\n",
|
||||
error("%s: asynOverflow in write. Asyn driver says: \"%s\"\n",
|
||||
clientName(), pasynUser->errorMessage);
|
||||
writeCallback(StreamIoFault);
|
||||
return;
|
||||
case asynError:
|
||||
error("%s: asynError in write: %s\n",
|
||||
error("%s: asynError in write. Asyn driver says: \"%s\"\n",
|
||||
clientName(), pasynUser->errorMessage);
|
||||
writeCallback(StreamIoFault);
|
||||
return;
|
||||
#ifdef ASYN_VERSION // asyn >= 4.14
|
||||
case asynDisconnected:
|
||||
error("%s: asynDisconnected in write: %s\n",
|
||||
error("%s: asynDisconnected in write. Asyn driver says: \"%s\"\n",
|
||||
clientName(), pasynUser->errorMessage);
|
||||
writeCallback(StreamIoFault);
|
||||
return;
|
||||
case asynDisabled:
|
||||
error("%s: asynDisconnected in write: %s\n",
|
||||
error("%s: asynDisconnected in write. Asyn driver says: \"%s\"\n",
|
||||
clientName(), pasynUser->errorMessage);
|
||||
writeCallback(StreamIoFault);
|
||||
return;
|
||||
#endif
|
||||
default:
|
||||
error("%s: unknown asyn error in write: %s\n",
|
||||
error("%s: unknown asyn error in write. Asyn driver says: \"%s\"\n",
|
||||
clientName(), pasynUser->errorMessage);
|
||||
writeCallback(StreamIoFault);
|
||||
return;
|
||||
@ -732,7 +815,7 @@ readRequest(unsigned long replyTimeout_ms, unsigned long readTimeout_ms,
|
||||
long _expectedLength, bool async)
|
||||
{
|
||||
debug("AsynDriverInterface::readRequest(%s, %ld msec reply, "
|
||||
"%ld msec read, expect %ld bytes, asyn=%s)\n",
|
||||
"%ld msec read, expect %ld bytes, async=%s)\n",
|
||||
clientName(), replyTimeout_ms, readTimeout_ms,
|
||||
_expectedLength, async?"yes":"no");
|
||||
|
||||
@ -756,8 +839,20 @@ readRequest(unsigned long replyTimeout_ms, unsigned long readTimeout_ms,
|
||||
}
|
||||
status = pasynManager->queueRequest(pasynUser,
|
||||
priority(), queueTimeout);
|
||||
if (status != asynSuccess && !async)
|
||||
debug("AsynDriverInterface::readRequest %s: "
|
||||
"queueRequest(..., priority=%d, queueTimeout=%g sec) = %s [async=%s] %s\n",
|
||||
clientName(), priority(), queueTimeout,
|
||||
asynStatusStr[status], async? "true" : "false",
|
||||
status!=asynSuccess ? pasynUser->errorMessage : "");
|
||||
if (status != asynSuccess)
|
||||
{
|
||||
// Not queued for some reason (e.g. disconnected / already queued)
|
||||
if (async)
|
||||
{
|
||||
// silently try again later
|
||||
startTimer(replyTimeout);
|
||||
return true;
|
||||
}
|
||||
error("%s readRequest: pasynManager->queueRequest() failed: %s\n",
|
||||
clientName(), pasynUser->errorMessage);
|
||||
return false;
|
||||
@ -798,6 +893,11 @@ readHandler()
|
||||
oldeoslen = -1;
|
||||
} else do {
|
||||
// device (e.g. GPIB) might not accept full eos length
|
||||
if ((int)deveoslen == oldeoslen && strcmp(deveos, oldeos) == 0)
|
||||
{
|
||||
// nothing to do: old and new eos are the same
|
||||
break;
|
||||
}
|
||||
if (pasynOctet->setInputEos(pvtOctet, pasynUser,
|
||||
deveos, deveoslen) == asynSuccess)
|
||||
{
|
||||
@ -805,8 +905,9 @@ readHandler()
|
||||
if (ioAction != AsyncRead)
|
||||
{
|
||||
debug("AsynDriverInterface::readHandler(%s) "
|
||||
"input EOS set to %s\n",
|
||||
"input EOS changed from \"%s\" to \"%s\"\n",
|
||||
clientName(),
|
||||
StreamBuffer(oldeos, oldeoslen).expand()(),
|
||||
StreamBuffer(deveos, deveoslen).expand()());
|
||||
}
|
||||
#endif
|
||||
@ -862,28 +963,29 @@ readHandler()
|
||||
readMore = 0;
|
||||
received = 0;
|
||||
eomReason = 0;
|
||||
pasynUser->errorMessage[0] = 0;
|
||||
|
||||
debug("AsynDriverInterface::readHandler(%s): ioAction=%s "
|
||||
"read(..., bytesToRead=%ld, ...) "
|
||||
"[timeout=%g sec]\n",
|
||||
clientName(), ioActionStr[ioAction],
|
||||
bytesToRead, pasynUser->timeout);
|
||||
status = pasynOctet->read(pvtOctet, pasynUser,
|
||||
buffer, bytesToRead, &received, &eomReason);
|
||||
if (ioAction == Read || status != asynTimeout)
|
||||
{
|
||||
debug("AsynDriverInterface::readHandler(%s): "
|
||||
"read(..., bytesToRead=%ld, received=%ld...) "
|
||||
"[timeout=%f seconds] = %s\n",
|
||||
clientName(), bytesToRead, (long)received,
|
||||
pasynUser->timeout, asynStatusStr[status]);
|
||||
}
|
||||
#ifndef NO_TEMPORARY
|
||||
debug("AsynDriverInterface::readHandler(%s): "
|
||||
"read returned %s: ioAction=%s received=%ld, eomReason=%s, buffer=\"%s\"\n",
|
||||
clientName(), asynStatusStr[status], ioActionStr[ioAction],
|
||||
(long)received,eomReasonStr[eomReason&0x7],
|
||||
StreamBuffer(buffer, received).expand()());
|
||||
#endif
|
||||
pasynManager->isConnected(pasynUser, &connected);
|
||||
debug("AsynDriverInterface::readHandler(%s): "
|
||||
"device is %sconnected\n",
|
||||
clientName(),connected?"":"dis");
|
||||
if (!connected) {
|
||||
error("%s: connection closed in read\n",
|
||||
clientName());
|
||||
readCallback(StreamIoFault);
|
||||
return;
|
||||
}
|
||||
// pasynOctet->read() has already cut off terminator.
|
||||
"device is now %sconnected\n",
|
||||
clientName(),connected?"":"dis");
|
||||
// asyn 4.16 sets reason to ASYN_EOM_END when device disconnects.
|
||||
// What about earlier versions?
|
||||
if (!connected) eomReason |= ASYN_EOM_END;
|
||||
|
||||
if (status == asynTimeout &&
|
||||
pasynUser->timeout == 0.0 &&
|
||||
@ -910,6 +1012,7 @@ readHandler()
|
||||
#endif
|
||||
// ignore what we got from here.
|
||||
// input was already handeled by asynReadHandler()
|
||||
|
||||
// read until no more input is available
|
||||
readMore = -1;
|
||||
break;
|
||||
@ -959,6 +1062,9 @@ readHandler()
|
||||
// reply timeout
|
||||
if (ioAction == AsyncRead)
|
||||
{
|
||||
debug("AsynDriverInterface::readHandler(%s): "
|
||||
"no async input, retry in in %g seconds\n",
|
||||
clientName(), replyTimeout);
|
||||
// start next poll after timer expires
|
||||
if (replyTimeout != 0.0) startTimer(replyTimeout);
|
||||
// continues with:
|
||||
@ -975,7 +1081,7 @@ readHandler()
|
||||
// read timeout
|
||||
#ifndef NO_TEMPORARY
|
||||
debug("AsynDriverInterface::readHandler(%s): "
|
||||
"ioAction=%s, timeout [%f seconds] "
|
||||
"ioAction=%s, timeout [%g sec] "
|
||||
"after %ld of %ld bytes \"%s\"\n",
|
||||
clientName(), ioActionStr[ioAction], pasynUser->timeout,
|
||||
(long)received, bytesToRead,
|
||||
@ -1002,29 +1108,29 @@ readHandler()
|
||||
}
|
||||
peeksize = inputBuffer.capacity();
|
||||
// deliver whatever we could save
|
||||
error("%s: asynOverflow in read: %s\n",
|
||||
error("%s: asynOverflow in read. Asyn driver says: \"%s\"\n",
|
||||
clientName(), pasynUser->errorMessage);
|
||||
readCallback(StreamIoFault, buffer, received);
|
||||
break;
|
||||
case asynError:
|
||||
error("%s: asynError in read: %s\n",
|
||||
error("%s: asynError in read. Asyn driver says: \"%s\"\n",
|
||||
clientName(), pasynUser->errorMessage);
|
||||
readCallback(StreamIoFault, buffer, received);
|
||||
break;
|
||||
#ifdef ASYN_VERSION // asyn >= 4.14
|
||||
case asynDisconnected:
|
||||
error("%s: asynDisconnected in read: %s\n",
|
||||
error("%s: asynDisconnected in read. Asyn driver says: \"%s\"\n",
|
||||
clientName(), pasynUser->errorMessage);
|
||||
readCallback(StreamIoFault);
|
||||
return;
|
||||
case asynDisabled:
|
||||
error("%s: asynDisconnected in read: %s\n",
|
||||
error("%s: asynDisconnected in read. Asyn driver says: \"%s\"\n",
|
||||
clientName(), pasynUser->errorMessage);
|
||||
readCallback(StreamIoFault);
|
||||
return;
|
||||
#endif
|
||||
default:
|
||||
error("%s: unknown asyn error in read: %s\n",
|
||||
error("%s: unknown asyn error in read. Asyn driver says: \"%s\"\n",
|
||||
clientName(), pasynUser->errorMessage);
|
||||
readCallback(StreamIoFault);
|
||||
return;
|
||||
@ -1046,10 +1152,16 @@ readHandler()
|
||||
}
|
||||
|
||||
// restore original EOS
|
||||
if (oldeoslen >= 0)
|
||||
if (oldeoslen >= 0 && oldeoslen != (int)deveoslen && strcmp(deveos, oldeos) != 0)
|
||||
{
|
||||
pasynOctet->setInputEos(pvtOctet, pasynUser,
|
||||
oldeos, oldeoslen);
|
||||
#ifndef NO_TEMPORARY
|
||||
debug("AsynDriverInterface::readHandler(%s) "
|
||||
"input EOS restored to \"%s\"\n",
|
||||
clientName(),
|
||||
StreamBuffer(oldeos, oldeoslen).expand()());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -1187,7 +1299,7 @@ acceptEvent(unsigned long mask, unsigned long replytimeout_ms)
|
||||
}
|
||||
eventMask = mask;
|
||||
ioAction = ReceiveEvent;
|
||||
startTimer(replytimeout_ms*0.001);
|
||||
if (replytimeout_ms) startTimer(replytimeout_ms*0.001);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1236,6 +1348,9 @@ timerExpired()
|
||||
int autoconnect, connected;
|
||||
switch (ioAction)
|
||||
{
|
||||
case None:
|
||||
// Timeout of async poll crossed with parasitic input
|
||||
return;
|
||||
case ReceiveEvent:
|
||||
// timeout while waiting for event
|
||||
ioAction = None;
|
||||
@ -1254,6 +1369,8 @@ timerExpired()
|
||||
// queueRequest might fail if another request was just queued
|
||||
pasynManager->isAutoConnect(pasynUser, &autoconnect);
|
||||
pasynManager->isConnected(pasynUser, &connected);
|
||||
debug("%s: polling for I/O Intr: autoconnected: %d, connect: %d\n",
|
||||
clientName(), autoconnect, connected);
|
||||
if (autoconnect && !connected)
|
||||
{
|
||||
// has explicitely been disconnected
|
||||
@ -1264,8 +1381,14 @@ timerExpired()
|
||||
else
|
||||
{
|
||||
// queue for read poll (no timeout)
|
||||
pasynManager->queueRequest(pasynUser,
|
||||
asynStatus status = pasynManager->queueRequest(pasynUser,
|
||||
asynQueuePriorityLow, -1.0);
|
||||
// if this fails, we are already queued by another thread
|
||||
debug("AsynDriverInterface::timerExpired %s: "
|
||||
"queueRequest(..., priority=Low, queueTimeout=-1) = %s %s\n",
|
||||
clientName(), asynStatusStr[status],
|
||||
status!=asynSuccess ? pasynUser->errorMessage : "");
|
||||
if (status != asynSuccess) startTimer(replyTimeout);
|
||||
// continues with:
|
||||
// handleRequest() -> readHandler() -> readCallback()
|
||||
}
|
||||
@ -1277,14 +1400,7 @@ timerExpired()
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef EPICS_3_14
|
||||
epicsTimerNotify::expireStatus AsynDriverInterface::
|
||||
expire(const epicsTime &)
|
||||
{
|
||||
timerExpired();
|
||||
return noRestart;
|
||||
}
|
||||
#else
|
||||
#ifdef EPICS_3_13
|
||||
void AsynDriverInterface::
|
||||
expire(CALLBACK *pcallback)
|
||||
{
|
||||
@ -1292,6 +1408,13 @@ expire(CALLBACK *pcallback)
|
||||
static_cast<AsynDriverInterface*>(pcallback->user);
|
||||
interface->timerExpired();
|
||||
}
|
||||
#else
|
||||
epicsTimerNotify::expireStatus AsynDriverInterface::
|
||||
expire(const epicsTime &)
|
||||
{
|
||||
timerExpired();
|
||||
return noRestart;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool AsynDriverInterface::
|
||||
@ -1390,6 +1513,7 @@ void handleRequest(asynUser* pasynUser)
|
||||
{
|
||||
AsynDriverInterface* interface =
|
||||
static_cast<AsynDriverInterface*>(pasynUser->userPvt);
|
||||
interface->cancelTimer();
|
||||
debug("AsynDriverInterface::handleRequest(%s) %s\n",
|
||||
interface->clientName(), ioActionStr[interface->ioAction]);
|
||||
switch (interface->ioAction)
|
||||
|
@ -31,9 +31,9 @@ class BCDConverter : public StreamFormatConverter
|
||||
};
|
||||
|
||||
int BCDConverter::
|
||||
parse(const StreamFormat&, StreamBuffer&, const char*&, bool)
|
||||
parse(const StreamFormat& fmt, StreamBuffer&, const char*&, bool)
|
||||
{
|
||||
return long_format;
|
||||
return (fmt.flags & sign_flag) ? signed_format : unsigned_format;
|
||||
}
|
||||
|
||||
bool BCDConverter::
|
||||
|
@ -19,6 +19,7 @@
|
||||
***************************************************************/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
#include "StreamFormatConverter.h"
|
||||
#include "StreamError.h"
|
||||
|
||||
@ -32,51 +33,59 @@ class BinaryConverter : public StreamFormatConverter
|
||||
};
|
||||
|
||||
int BinaryConverter::
|
||||
parse(const StreamFormat& format, StreamBuffer& info,
|
||||
parse(const StreamFormat& fmt, StreamBuffer& info,
|
||||
const char*& source, bool)
|
||||
{
|
||||
if (format.conv == 'B')
|
||||
if (fmt.conv == 'b')
|
||||
{
|
||||
// user defined characters for %B (next 2 in source)
|
||||
// default characters 0 and 1 for %b
|
||||
info.append("01");
|
||||
return unsigned_format;
|
||||
}
|
||||
|
||||
// user defined characters for %B (next 2 in source)
|
||||
if (*source)
|
||||
{
|
||||
if (*source == esc) source++;
|
||||
info.append(*source++);
|
||||
if (*source)
|
||||
{
|
||||
if (*source == esc) source++;
|
||||
info.append(*source++);
|
||||
if (*source)
|
||||
{
|
||||
if (*source == esc) source++;
|
||||
info.append(*source++);
|
||||
return long_format;
|
||||
}
|
||||
return unsigned_format;
|
||||
}
|
||||
error("Missing characters after %%B format conversion\n");
|
||||
return false;
|
||||
}
|
||||
// default characters for %b
|
||||
info.append("01");
|
||||
return long_format;
|
||||
error("Missing characters after %%B format conversion\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool BinaryConverter::
|
||||
printLong(const StreamFormat& format, StreamBuffer& output, long value)
|
||||
printLong(const StreamFormat& fmt, StreamBuffer& output, long value)
|
||||
{
|
||||
int prec = format.prec;
|
||||
int prec = fmt.prec;
|
||||
if (prec == -1)
|
||||
{
|
||||
// find number of significant bits
|
||||
prec = sizeof (value) * 8;
|
||||
while (prec && (value & (1L << (prec - 1))) == 0) prec--;
|
||||
// Find number of significant bits is nothing is specified.
|
||||
unsigned long x = (unsigned long) value;
|
||||
prec = 32;
|
||||
#if (LONG_BIT > 32)
|
||||
if (x > 0xFFFFFFFF) { prec = 64; x >>=32; }
|
||||
#endif
|
||||
if (x <= 0x0000FFFF) { prec -= 16; x <<=16; }
|
||||
if (x <= 0x00FFFFFF) { prec -= 8; x <<=8; }
|
||||
if (x <= 0x0FFFFFFF) { prec -= 4; x <<=4; }
|
||||
if (x <= 0x3FFFFFFF) { prec -= 2; x <<=2; }
|
||||
if (x <= 0x7FFFFFFF) { prec -= 1; }
|
||||
}
|
||||
if (prec == 0) prec++; // print at least one bit
|
||||
int width = prec;
|
||||
if (format.width > width) width = format.width;
|
||||
char zero = format.info[0];
|
||||
char one = format.info[1];
|
||||
char fill = (format.flags & zero_flag) ? zero : ' ';
|
||||
if (format.flags & alt_flag)
|
||||
if (fmt.width > width) width = fmt.width;
|
||||
char zero = fmt.info[0];
|
||||
char one = fmt.info[1];
|
||||
char fill = (fmt.flags & zero_flag) ? zero : ' ';
|
||||
if (fmt.flags & alt_flag)
|
||||
{
|
||||
// little endian (least significant bit first)
|
||||
if (!(format.flags & left_flag))
|
||||
if (!(fmt.flags & left_flag))
|
||||
{
|
||||
// pad left
|
||||
while (width > prec)
|
||||
@ -100,7 +109,7 @@ printLong(const StreamFormat& format, StreamBuffer& output, long value)
|
||||
else
|
||||
{
|
||||
// big endian (most significant bit first)
|
||||
if (!(format.flags & left_flag))
|
||||
if (!(fmt.flags & left_flag))
|
||||
{
|
||||
// pad left
|
||||
while (width > prec)
|
||||
@ -124,17 +133,18 @@ printLong(const StreamFormat& format, StreamBuffer& output, long value)
|
||||
}
|
||||
|
||||
int BinaryConverter::
|
||||
scanLong(const StreamFormat& format, const char* input, long& value)
|
||||
scanLong(const StreamFormat& fmt, const char* input, long& value)
|
||||
{
|
||||
long val = 0;
|
||||
int width = format.width;
|
||||
int width = fmt.width;
|
||||
if (width == 0) width = -1;
|
||||
int length = 0;
|
||||
while (isspace(input[length])) length++; // skip whitespaces
|
||||
char zero = format.info[0];
|
||||
char one = format.info[1];
|
||||
char zero = fmt.info[0];
|
||||
char one = fmt.info[1];
|
||||
if (!isspace(zero) && !isspace(one))
|
||||
while (isspace(input[length])) length++; // skip whitespaces
|
||||
if (input[length] != zero && input[length] != one) return -1;
|
||||
if (format.flags & alt_flag)
|
||||
if (fmt.flags & alt_flag)
|
||||
{
|
||||
// little endian (least significan bit first)
|
||||
long mask = 1;
|
||||
|
@ -3,17 +3,17 @@
|
||||
|
||||
# You may add more record interfaces
|
||||
# This requires the naming conventions
|
||||
# dev$(RECORD)Stream.c
|
||||
# dev$(RECORDTYPE)Stream.c
|
||||
|
||||
RECORDS += ao ai
|
||||
RECORDS += bo bi
|
||||
RECORDS += mbbo mbbi
|
||||
RECORDS += mbboDirect mbbiDirect
|
||||
RECORDS += longout longin
|
||||
RECORDS += stringout stringin
|
||||
RECORDS += waveform
|
||||
RECORDS += calcout
|
||||
RECORDS += aai aao
|
||||
RECORDTYPES += ao ai
|
||||
RECORDTYPES += bo bi
|
||||
RECORDTYPES += mbbo mbbi
|
||||
RECORDTYPES += mbboDirect mbbiDirect
|
||||
RECORDTYPES += longout longin
|
||||
RECORDTYPES += stringout stringin
|
||||
RECORDTYPES += waveform
|
||||
RECORDTYPES += calcout
|
||||
RECORDTYPES += aai aao
|
||||
|
||||
# Do you have synApps and want support for scalcout?
|
||||
# Then define CALC or SYNAPPS in your RELEASE file
|
||||
@ -21,18 +21,23 @@ RECORDS += aai aao
|
||||
# Due to strange cross dependencies in synApps
|
||||
# you have to build the 'sscan' and 'genSub'
|
||||
# modules before building 'calc'.
|
||||
# See doc/scalcout.html for a required fix in scalcout.
|
||||
|
||||
SYNAPPS_RECORDS += scalcout
|
||||
# The 'calc' version must be 2-4 or higher.
|
||||
# Up to version 2-6 (synApps 5.1) the 'calc' module needs a fix.
|
||||
# See doc/scalcout.html for details.
|
||||
ifneq ($(words $(CALC) $(SYNAPPS)), 0)
|
||||
RECORDTYPES += scalcout
|
||||
endif
|
||||
|
||||
# You may add more bus interfaces
|
||||
# This requires the naming convention
|
||||
# $(BUS)Interface.cc
|
||||
# asynDriver interface is added automatically
|
||||
# if ASYN is defined in your RELEASE file.
|
||||
# asynDriver interface is added if ASYN is defined in your RELEASE file.
|
||||
|
||||
BUSSES += Debug
|
||||
BUSSES += Dummy
|
||||
ifdef ASYN
|
||||
BUSSES += AsynDriver
|
||||
endif
|
||||
|
||||
# You may add more format converters
|
||||
# This requires the naming convention
|
||||
|
@ -22,17 +22,26 @@
|
||||
#include "StreamError.h"
|
||||
#if defined(__vxworks) || defined(vxWorks) || defined(_WIN32) || defined(__rtems__)
|
||||
// These systems have no strncasecmp
|
||||
#include <epicsVersion.h>
|
||||
#ifdef BASE_VERSION
|
||||
// 3.13
|
||||
#include <ctype.h>
|
||||
static int strncasecmp(const char *s1, const char *s2, size_t n)
|
||||
{
|
||||
int r=0;
|
||||
while (n && (r = toupper(*s1)-toupper(*s2)) == 0) { n--; s1++; s2++; };
|
||||
return r;
|
||||
}
|
||||
#else
|
||||
#include <epicsString.h>
|
||||
#define strncasecmp epicsStrnCaseCmp
|
||||
#endif
|
||||
#endif
|
||||
#include <ctype.h>
|
||||
|
||||
typedef unsigned long ulong;
|
||||
typedef unsigned char uchar;
|
||||
typedef unsigned int (*checksumFunc)(const unsigned char* data, unsigned int len, unsigned int init);
|
||||
|
||||
typedef ulong (*checksumFunc)(const uchar* data, ulong len, ulong init);
|
||||
|
||||
static ulong sum(const uchar* data, ulong len, ulong sum)
|
||||
static unsigned int sum(const unsigned char* data, unsigned int len, unsigned int sum)
|
||||
{
|
||||
while (len--)
|
||||
{
|
||||
@ -41,7 +50,7 @@ static ulong sum(const uchar* data, ulong len, ulong sum)
|
||||
return sum;
|
||||
}
|
||||
|
||||
static ulong xor8(const uchar* data, ulong len, ulong sum)
|
||||
static unsigned int xor8(const unsigned char* data, unsigned int len, unsigned int sum)
|
||||
{
|
||||
while (len--)
|
||||
{
|
||||
@ -50,15 +59,15 @@ static ulong xor8(const uchar* data, ulong len, ulong sum)
|
||||
return sum;
|
||||
}
|
||||
|
||||
static ulong xor7(const uchar* data, ulong len, ulong sum)
|
||||
static unsigned int xor7(const unsigned char* data, unsigned int len, unsigned int sum)
|
||||
{
|
||||
return xor8(data, len, sum) & 0x7F;
|
||||
}
|
||||
|
||||
static ulong crc_0x07(const uchar* data, ulong len, ulong crc)
|
||||
static unsigned int crc_0x07(const unsigned char* data, unsigned int len, unsigned int crc)
|
||||
{
|
||||
// x^8 + x^2 + x^1 + x^0 (0x07)
|
||||
const static uchar table[256] = {
|
||||
const static unsigned char table[256] = {
|
||||
0x00, 0x07, 0x0E, 0x09, 0x1C, 0x1B, 0x12, 0x15,
|
||||
0x38, 0x3F, 0x36, 0x31, 0x24, 0x23, 0x2A, 0x2D,
|
||||
0x70, 0x77, 0x7E, 0x79, 0x6C, 0x6B, 0x62, 0x65,
|
||||
@ -96,10 +105,10 @@ static ulong crc_0x07(const uchar* data, ulong len, ulong crc)
|
||||
return crc;
|
||||
}
|
||||
|
||||
static ulong crc_0x31(const uchar* data, ulong len, ulong crc)
|
||||
static unsigned int crc_0x31(const unsigned char* data, unsigned int len, unsigned int crc)
|
||||
{
|
||||
// x^8 + x^5 + x^4 + x^0 (0x31)
|
||||
const static uchar table[256] = {
|
||||
const static unsigned char table[256] = {
|
||||
0x00, 0x5e, 0xbc, 0xe2, 0x61, 0x3f, 0xdd, 0x83,
|
||||
0xc2, 0x9c, 0x7e, 0x20, 0xa3, 0xfd, 0x1f, 0x41,
|
||||
0x9d, 0xc3, 0x21, 0x7f, 0xfc, 0xa2, 0x40, 0x1e,
|
||||
@ -137,90 +146,90 @@ static ulong crc_0x31(const uchar* data, ulong len, ulong crc)
|
||||
return crc;
|
||||
}
|
||||
|
||||
static ulong crc_0x8005(const uchar* data, ulong len, ulong crc)
|
||||
static unsigned int crc_0x8005(const unsigned char* data, unsigned int len, unsigned int crc)
|
||||
{
|
||||
// x^16 + x^15 + x^2 + x^0 (0x8005)
|
||||
const static unsigned short table[256] = {
|
||||
0x0000,0x8005,0x800f,0x000a,0x801b,0x001e,0x0014,0x8011,
|
||||
0x8033,0x0036,0x003c,0x8039,0x0028,0x802d,0x8027,0x0022,
|
||||
0x8063,0x0066,0x006c,0x8069,0x0078,0x807d,0x8077,0x0072,
|
||||
0x0050,0x8055,0x805f,0x005a,0x804b,0x004e,0x0044,0x8041,
|
||||
0x80c3,0x00c6,0x00cc,0x80c9,0x00d8,0x80dd,0x80d7,0x00d2,
|
||||
0x00f0,0x80f5,0x80ff,0x00fa,0x80eb,0x00ee,0x00e4,0x80e1,
|
||||
0x00a0,0x80a5,0x80af,0x00aa,0x80bb,0x00be,0x00b4,0x80b1,
|
||||
0x8093,0x0096,0x009c,0x8099,0x0088,0x808d,0x8087,0x0082,
|
||||
0x8183,0x0186,0x018c,0x8189,0x0198,0x819d,0x8197,0x0192,
|
||||
0x01b0,0x81b5,0x81bf,0x01ba,0x81ab,0x01ae,0x01a4,0x81a1,
|
||||
0x01e0,0x81e5,0x81ef,0x01ea,0x81fb,0x01fe,0x01f4,0x81f1,
|
||||
0x81d3,0x01d6,0x01dc,0x81d9,0x01c8,0x81cd,0x81c7,0x01c2,
|
||||
0x0140,0x8145,0x814f,0x014a,0x815b,0x015e,0x0154,0x8151,
|
||||
0x8173,0x0176,0x017c,0x8179,0x0168,0x816d,0x8167,0x0162,
|
||||
0x8123,0x0126,0x012c,0x8129,0x0138,0x813d,0x8137,0x0132,
|
||||
0x0110,0x8115,0x811f,0x011a,0x810b,0x010e,0x0104,0x8101,
|
||||
0x8303,0x0306,0x030c,0x8309,0x0318,0x831d,0x8317,0x0312,
|
||||
0x0330,0x8335,0x833f,0x033a,0x832b,0x032e,0x0324,0x8321,
|
||||
0x0360,0x8365,0x836f,0x036a,0x837b,0x037e,0x0374,0x8371,
|
||||
0x8353,0x0356,0x035c,0x8359,0x0348,0x834d,0x8347,0x0342,
|
||||
0x03c0,0x83c5,0x83cf,0x03ca,0x83db,0x03de,0x03d4,0x83d1,
|
||||
0x83f3,0x03f6,0x03fc,0x83f9,0x03e8,0x83ed,0x83e7,0x03e2,
|
||||
0x83a3,0x03a6,0x03ac,0x83a9,0x03b8,0x83bd,0x83b7,0x03b2,
|
||||
0x0390,0x8395,0x839f,0x039a,0x838b,0x038e,0x0384,0x8381,
|
||||
0x0280,0x8285,0x828f,0x028a,0x829b,0x029e,0x0294,0x8291,
|
||||
0x82b3,0x02b6,0x02bc,0x82b9,0x02a8,0x82ad,0x82a7,0x02a2,
|
||||
0x82e3,0x02e6,0x02ec,0x82e9,0x02f8,0x82fd,0x82f7,0x02f2,
|
||||
0x02d0,0x82d5,0x82df,0x02da,0x82cb,0x02ce,0x02c4,0x82c1,
|
||||
0x8243,0x0246,0x024c,0x8249,0x0258,0x825d,0x8257,0x0252,
|
||||
0x0270,0x8275,0x827f,0x027a,0x826b,0x026e,0x0264,0x8261,
|
||||
0x0220,0x8225,0x822f,0x022a,0x823b,0x023e,0x0234,0x8231,
|
||||
0x8213,0x0216,0x021c,0x8219,0x0208,0x820d,0x8207,0x0202 };
|
||||
0x0000, 0x8005, 0x800f, 0x000a, 0x801b, 0x001e, 0x0014, 0x8011,
|
||||
0x8033, 0x0036, 0x003c, 0x8039, 0x0028, 0x802d, 0x8027, 0x0022,
|
||||
0x8063, 0x0066, 0x006c, 0x8069, 0x0078, 0x807d, 0x8077, 0x0072,
|
||||
0x0050, 0x8055, 0x805f, 0x005a, 0x804b, 0x004e, 0x0044, 0x8041,
|
||||
0x80c3, 0x00c6, 0x00cc, 0x80c9, 0x00d8, 0x80dd, 0x80d7, 0x00d2,
|
||||
0x00f0, 0x80f5, 0x80ff, 0x00fa, 0x80eb, 0x00ee, 0x00e4, 0x80e1,
|
||||
0x00a0, 0x80a5, 0x80af, 0x00aa, 0x80bb, 0x00be, 0x00b4, 0x80b1,
|
||||
0x8093, 0x0096, 0x009c, 0x8099, 0x0088, 0x808d, 0x8087, 0x0082,
|
||||
0x8183, 0x0186, 0x018c, 0x8189, 0x0198, 0x819d, 0x8197, 0x0192,
|
||||
0x01b0, 0x81b5, 0x81bf, 0x01ba, 0x81ab, 0x01ae, 0x01a4, 0x81a1,
|
||||
0x01e0, 0x81e5, 0x81ef, 0x01ea, 0x81fb, 0x01fe, 0x01f4, 0x81f1,
|
||||
0x81d3, 0x01d6, 0x01dc, 0x81d9, 0x01c8, 0x81cd, 0x81c7, 0x01c2,
|
||||
0x0140, 0x8145, 0x814f, 0x014a, 0x815b, 0x015e, 0x0154, 0x8151,
|
||||
0x8173, 0x0176, 0x017c, 0x8179, 0x0168, 0x816d, 0x8167, 0x0162,
|
||||
0x8123, 0x0126, 0x012c, 0x8129, 0x0138, 0x813d, 0x8137, 0x0132,
|
||||
0x0110, 0x8115, 0x811f, 0x011a, 0x810b, 0x010e, 0x0104, 0x8101,
|
||||
0x8303, 0x0306, 0x030c, 0x8309, 0x0318, 0x831d, 0x8317, 0x0312,
|
||||
0x0330, 0x8335, 0x833f, 0x033a, 0x832b, 0x032e, 0x0324, 0x8321,
|
||||
0x0360, 0x8365, 0x836f, 0x036a, 0x837b, 0x037e, 0x0374, 0x8371,
|
||||
0x8353, 0x0356, 0x035c, 0x8359, 0x0348, 0x834d, 0x8347, 0x0342,
|
||||
0x03c0, 0x83c5, 0x83cf, 0x03ca, 0x83db, 0x03de, 0x03d4, 0x83d1,
|
||||
0x83f3, 0x03f6, 0x03fc, 0x83f9, 0x03e8, 0x83ed, 0x83e7, 0x03e2,
|
||||
0x83a3, 0x03a6, 0x03ac, 0x83a9, 0x03b8, 0x83bd, 0x83b7, 0x03b2,
|
||||
0x0390, 0x8395, 0x839f, 0x039a, 0x838b, 0x038e, 0x0384, 0x8381,
|
||||
0x0280, 0x8285, 0x828f, 0x028a, 0x829b, 0x029e, 0x0294, 0x8291,
|
||||
0x82b3, 0x02b6, 0x02bc, 0x82b9, 0x02a8, 0x82ad, 0x82a7, 0x02a2,
|
||||
0x82e3, 0x02e6, 0x02ec, 0x82e9, 0x02f8, 0x82fd, 0x82f7, 0x02f2,
|
||||
0x02d0, 0x82d5, 0x82df, 0x02da, 0x82cb, 0x02ce, 0x02c4, 0x82c1,
|
||||
0x8243, 0x0246, 0x024c, 0x8249, 0x0258, 0x825d, 0x8257, 0x0252,
|
||||
0x0270, 0x8275, 0x827f, 0x027a, 0x826b, 0x026e, 0x0264, 0x8261,
|
||||
0x0220, 0x8225, 0x822f, 0x022a, 0x823b, 0x023e, 0x0234, 0x8231,
|
||||
0x8213, 0x0216, 0x021c, 0x8219, 0x0208, 0x820d, 0x8207, 0x0202 };
|
||||
|
||||
while (len--) crc = table[((crc>>8) ^ *data++) & 0xFF] ^ (crc << 8);
|
||||
return crc;
|
||||
}
|
||||
|
||||
static ulong crc_0x8005_r(const uchar* data, ulong len, ulong crc)
|
||||
static unsigned int crc_0x8005_r(const unsigned char* data, unsigned int len, unsigned int crc)
|
||||
{
|
||||
// x^16 + x^15 + x^2 + x^0 (0x8005)
|
||||
// reflected
|
||||
const static unsigned short table[256] = {
|
||||
0x0000,0xC0C1,0xC181,0x0140,0xC301,0x03C0,0x0280,0xC241,
|
||||
0xC601,0x06C0,0x0780,0xC741,0x0500,0xC5C1,0xC481,0x0440,
|
||||
0xCC01,0x0CC0,0x0D80,0xCD41,0x0F00,0xCFC1,0xCE81,0x0E40,
|
||||
0x0A00,0xCAC1,0xCB81,0x0B40,0xC901,0x09C0,0x0880,0xC841,
|
||||
0xD801,0x18C0,0x1980,0xD941,0x1B00,0xDBC1,0xDA81,0x1A40,
|
||||
0x1E00,0xDEC1,0xDF81,0x1F40,0xDD01,0x1DC0,0x1C80,0xDC41,
|
||||
0x1400,0xD4C1,0xD581,0x1540,0xD701,0x17C0,0x1680,0xD641,
|
||||
0xD201,0x12C0,0x1380,0xD341,0x1100,0xD1C1,0xD081,0x1040,
|
||||
0xF001,0x30C0,0x3180,0xF141,0x3300,0xF3C1,0xF281,0x3240,
|
||||
0x3600,0xF6C1,0xF781,0x3740,0xF501,0x35C0,0x3480,0xF441,
|
||||
0x3C00,0xFCC1,0xFD81,0x3D40,0xFF01,0x3FC0,0x3E80,0xFE41,
|
||||
0xFA01,0x3AC0,0x3B80,0xFB41,0x3900,0xF9C1,0xF881,0x3840,
|
||||
0x2800,0xE8C1,0xE981,0x2940,0xEB01,0x2BC0,0x2A80,0xEA41,
|
||||
0xEE01,0x2EC0,0x2F80,0xEF41,0x2D00,0xEDC1,0xEC81,0x2C40,
|
||||
0xE401,0x24C0,0x2580,0xE541,0x2700,0xE7C1,0xE681,0x2640,
|
||||
0x2200,0xE2C1,0xE381,0x2340,0xE101,0x21C0,0x2080,0xE041,
|
||||
0xA001,0x60C0,0x6180,0xA141,0x6300,0xA3C1,0xA281,0x6240,
|
||||
0x6600,0xA6C1,0xA781,0x6740,0xA501,0x65C0,0x6480,0xA441,
|
||||
0x6C00,0xACC1,0xAD81,0x6D40,0xAF01,0x6FC0,0x6E80,0xAE41,
|
||||
0xAA01,0x6AC0,0x6B80,0xAB41,0x6900,0xA9C1,0xA881,0x6840,
|
||||
0x7800,0xB8C1,0xB981,0x7940,0xBB01,0x7BC0,0x7A80,0xBA41,
|
||||
0xBE01,0x7EC0,0x7F80,0xBF41,0x7D00,0xBDC1,0xBC81,0x7C40,
|
||||
0xB401,0x74C0,0x7580,0xB541,0x7700,0xB7C1,0xB681,0x7640,
|
||||
0x7200,0xB2C1,0xB381,0x7340,0xB101,0x71C0,0x7080,0xB041,
|
||||
0x5000,0x90C1,0x9181,0x5140,0x9301,0x53C0,0x5280,0x9241,
|
||||
0x9601,0x56C0,0x5780,0x9741,0x5500,0x95C1,0x9481,0x5440,
|
||||
0x9C01,0x5CC0,0x5D80,0x9D41,0x5F00,0x9FC1,0x9E81,0x5E40,
|
||||
0x5A00,0x9AC1,0x9B81,0x5B40,0x9901,0x59C0,0x5880,0x9841,
|
||||
0x8801,0x48C0,0x4980,0x8941,0x4B00,0x8BC1,0x8A81,0x4A40,
|
||||
0x4E00,0x8EC1,0x8F81,0x4F40,0x8D01,0x4DC0,0x4C80,0x8C41,
|
||||
0x4400,0x84C1,0x8581,0x4540,0x8701,0x47C0,0x4680,0x8641,
|
||||
0x8201,0x42C0,0x4380,0x8341,0x4100,0x81C1,0x8081,0x4040 };
|
||||
0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241,
|
||||
0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440,
|
||||
0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40,
|
||||
0x0A00, 0xCAC1, 0xCB81, 0x0B40, 0xC901, 0x09C0, 0x0880, 0xC841,
|
||||
0xD801, 0x18C0, 0x1980, 0xD941, 0x1B00, 0xDBC1, 0xDA81, 0x1A40,
|
||||
0x1E00, 0xDEC1, 0xDF81, 0x1F40, 0xDD01, 0x1DC0, 0x1C80, 0xDC41,
|
||||
0x1400, 0xD4C1, 0xD581, 0x1540, 0xD701, 0x17C0, 0x1680, 0xD641,
|
||||
0xD201, 0x12C0, 0x1380, 0xD341, 0x1100, 0xD1C1, 0xD081, 0x1040,
|
||||
0xF001, 0x30C0, 0x3180, 0xF141, 0x3300, 0xF3C1, 0xF281, 0x3240,
|
||||
0x3600, 0xF6C1, 0xF781, 0x3740, 0xF501, 0x35C0, 0x3480, 0xF441,
|
||||
0x3C00, 0xFCC1, 0xFD81, 0x3D40, 0xFF01, 0x3FC0, 0x3E80, 0xFE41,
|
||||
0xFA01, 0x3AC0, 0x3B80, 0xFB41, 0x3900, 0xF9C1, 0xF881, 0x3840,
|
||||
0x2800, 0xE8C1, 0xE981, 0x2940, 0xEB01, 0x2BC0, 0x2A80, 0xEA41,
|
||||
0xEE01, 0x2EC0, 0x2F80, 0xEF41, 0x2D00, 0xEDC1, 0xEC81, 0x2C40,
|
||||
0xE401, 0x24C0, 0x2580, 0xE541, 0x2700, 0xE7C1, 0xE681, 0x2640,
|
||||
0x2200, 0xE2C1, 0xE381, 0x2340, 0xE101, 0x21C0, 0x2080, 0xE041,
|
||||
0xA001, 0x60C0, 0x6180, 0xA141, 0x6300, 0xA3C1, 0xA281, 0x6240,
|
||||
0x6600, 0xA6C1, 0xA781, 0x6740, 0xA501, 0x65C0, 0x6480, 0xA441,
|
||||
0x6C00, 0xACC1, 0xAD81, 0x6D40, 0xAF01, 0x6FC0, 0x6E80, 0xAE41,
|
||||
0xAA01, 0x6AC0, 0x6B80, 0xAB41, 0x6900, 0xA9C1, 0xA881, 0x6840,
|
||||
0x7800, 0xB8C1, 0xB981, 0x7940, 0xBB01, 0x7BC0, 0x7A80, 0xBA41,
|
||||
0xBE01, 0x7EC0, 0x7F80, 0xBF41, 0x7D00, 0xBDC1, 0xBC81, 0x7C40,
|
||||
0xB401, 0x74C0, 0x7580, 0xB541, 0x7700, 0xB7C1, 0xB681, 0x7640,
|
||||
0x7200, 0xB2C1, 0xB381, 0x7340, 0xB101, 0x71C0, 0x7080, 0xB041,
|
||||
0x5000, 0x90C1, 0x9181, 0x5140, 0x9301, 0x53C0, 0x5280, 0x9241,
|
||||
0x9601, 0x56C0, 0x5780, 0x9741, 0x5500, 0x95C1, 0x9481, 0x5440,
|
||||
0x9C01, 0x5CC0, 0x5D80, 0x9D41, 0x5F00, 0x9FC1, 0x9E81, 0x5E40,
|
||||
0x5A00, 0x9AC1, 0x9B81, 0x5B40, 0x9901, 0x59C0, 0x5880, 0x9841,
|
||||
0x8801, 0x48C0, 0x4980, 0x8941, 0x4B00, 0x8BC1, 0x8A81, 0x4A40,
|
||||
0x4E00, 0x8EC1, 0x8F81, 0x4F40, 0x8D01, 0x4DC0, 0x4C80, 0x8C41,
|
||||
0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641,
|
||||
0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040 };
|
||||
|
||||
while (len--) crc = table[(crc ^ *data++) & 0xFF] ^ (crc >> 8);
|
||||
return crc;
|
||||
}
|
||||
|
||||
static ulong crc_0x1021(const uchar* data, ulong len, ulong crc)
|
||||
static unsigned int crc_0x1021(const unsigned char* data, unsigned int len, unsigned int crc)
|
||||
{
|
||||
// x^16 + x^12 + x^5 + x^0 (0x1021)
|
||||
const static unsigned short table[256] = {
|
||||
@ -261,7 +270,7 @@ static ulong crc_0x1021(const uchar* data, ulong len, ulong crc)
|
||||
return crc;
|
||||
}
|
||||
|
||||
static ulong crc_0x04C11DB7(const uchar* data, ulong len, ulong crc)
|
||||
static unsigned int crc_0x04C11DB7(const unsigned char* data, unsigned int len, unsigned int crc)
|
||||
{
|
||||
// x^32 + x^26 + x^23 + x^22 + x^16 + x^12 + x^11 + x^10 +
|
||||
// x^8 + x^7 + x^5 + x^4 + x^2 + x^1 + x^0 (0x04C11DB7)
|
||||
@ -335,7 +344,7 @@ static ulong crc_0x04C11DB7(const uchar* data, ulong len, ulong crc)
|
||||
return crc;
|
||||
}
|
||||
|
||||
static ulong crc_0x04C11DB7_r(const uchar* data, ulong len, ulong crc)
|
||||
static unsigned int crc_0x04C11DB7_r(const unsigned char* data, unsigned int len, unsigned int crc)
|
||||
{
|
||||
// x^32 + x^26 + x^23 + x^22 + x^16 + x^12 + x^11 + x^10 +
|
||||
// x^8 + x^7 + x^5 + x^4 + x^2 + x^1 + x^0 (0x04C11DB7)
|
||||
@ -410,13 +419,13 @@ static ulong crc_0x04C11DB7_r(const uchar* data, ulong len, ulong crc)
|
||||
return crc;
|
||||
}
|
||||
|
||||
static ulong adler32(const uchar* data, ulong len, ulong init)
|
||||
static unsigned int adler32(const unsigned char* data, unsigned int len, unsigned int init)
|
||||
{
|
||||
ulong a = init & 0xFFFF;
|
||||
ulong b = (init >> 16) & 0xFFFF;
|
||||
unsigned int a = init & 0xFFFF;
|
||||
unsigned int b = (init >> 16) & 0xFFFF;
|
||||
|
||||
while (len) {
|
||||
ulong tlen = len > 5550 ? 5550 : len;
|
||||
unsigned int tlen = len > 5550 ? 5550 : len;
|
||||
len -= tlen;
|
||||
do {
|
||||
a += *data++;
|
||||
@ -431,10 +440,10 @@ static ulong adler32(const uchar* data, ulong len, ulong init)
|
||||
return b << 16 | a;
|
||||
}
|
||||
|
||||
static ulong hexsum(const uchar* data, ulong len, ulong sum)
|
||||
static unsigned int hexsum(const unsigned char* data, unsigned int len, unsigned int sum)
|
||||
{
|
||||
// Add all hex digits, ignore all other bytes.
|
||||
ulong d;
|
||||
unsigned int d;
|
||||
while (len--)
|
||||
{
|
||||
d = toupper(*data++);
|
||||
@ -452,8 +461,8 @@ struct checksum
|
||||
{
|
||||
const char* name;
|
||||
checksumFunc func;
|
||||
ulong init;
|
||||
ulong xorout;
|
||||
unsigned int init;
|
||||
unsigned int xorout;
|
||||
signed char bytes;
|
||||
};
|
||||
|
||||
@ -465,20 +474,6 @@ static checksum checksumMap[] =
|
||||
{"sum8", sum, 0x00, 0x00, 1}, // 0xDD
|
||||
{"sum16", sum, 0x0000, 0x0000, 2}, // 0x01DD
|
||||
{"sum32", sum, 0x00000000, 0x00000000, 4}, // 0x000001DD
|
||||
{"nsum", sum, 0xFF, 0xFF, 1}, // 0x23
|
||||
{"negsum", sum, 0xFF, 0xFF, 1}, // 0x23
|
||||
{"-sum", sum, 0xFF, 0xFF, 1}, // 0x23
|
||||
{"nsum8", sum, 0xFF, 0xFF, 1}, // 0x23
|
||||
{"negsum8", sum, 0xFF, 0xFF, 1}, // 0x23
|
||||
{"-sum8", sum, 0xFF, 0xFF, 1}, // 0x23
|
||||
{"nsum16", sum, 0xFFFF, 0xFFFF, 2}, // 0xFE23
|
||||
{"negsum16",sum, 0xFFFF, 0xFFFF, 2}, // 0xFE23
|
||||
{"-sum16", sum, 0xFFFF, 0xFFFF, 2}, // 0xFE23
|
||||
{"nsum32", sum, 0xFFFFFFFF, 0xFFFFFFFF, 4}, // 0xFFFFFE23
|
||||
{"negsum32",sum, 0xFFFFFFFF, 0xFFFFFFFF, 4}, // 0xFFFFFE23
|
||||
{"-sum32", sum, 0xFFFFFFFF, 0xFFFFFFFF, 4}, // 0xFFFFFE23
|
||||
{"notsum", sum, 0x00, 0xFF, 1}, // 0x22
|
||||
{"~sum", sum, 0x00, 0xFF, 1}, // 0x22
|
||||
{"xor", xor8, 0x00, 0x00, 1}, // 0x31
|
||||
{"xor8", xor8, 0x00, 0x00, 1}, // 0x31
|
||||
{"xor7", xor7, 0x00, 0x00, 1}, // 0x31
|
||||
@ -486,6 +481,7 @@ static checksum checksumMap[] =
|
||||
{"ccitt8", crc_0x31, 0x00, 0x00, 1}, // 0xA1
|
||||
{"crc16", crc_0x8005, 0x0000, 0x0000, 2}, // 0xFEE8
|
||||
{"crc16r", crc_0x8005_r, 0x0000, 0x0000, 2}, // 0xBB3D
|
||||
{"modbus", crc_0x8005_r, 0xFFFF, 0x0000, 2}, // 0x4B37
|
||||
{"ccitt16", crc_0x1021, 0xFFFF, 0x0000, 2}, // 0x29B1
|
||||
{"ccitt16a",crc_0x1021, 0x1D0F, 0x0000, 2}, // 0xE5CC
|
||||
{"ccitt16x",crc_0x1021, 0x0000, 0x0000, 2}, // 0x31C3
|
||||
@ -498,7 +494,7 @@ static checksum checksumMap[] =
|
||||
{"hexsum8", hexsum, 0x00, 0x00, 1} // 0x2D
|
||||
};
|
||||
|
||||
static ulong mask[5] = {0, 0xFF, 0xFFFF, 0xFFFFFF, 0xFFFFFFFF};
|
||||
static unsigned int mask[5] = {0, 0xFF, 0xFFFF, 0xFFFFFF, 0xFFFFFFFF};
|
||||
|
||||
class ChecksumConverter : public StreamFormatConverter
|
||||
{
|
||||
@ -517,44 +513,94 @@ parse(const StreamFormat&, StreamBuffer& info, const char*& source, bool)
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t fnum;
|
||||
bool negflag=false;
|
||||
bool notflag=false;
|
||||
if (*source == '-')
|
||||
{
|
||||
source++;
|
||||
negflag = true;
|
||||
}
|
||||
if (strncasecmp(source, "neg", 3) == 0)
|
||||
{
|
||||
source+=3;
|
||||
negflag = true;
|
||||
}
|
||||
if (*source == '~')
|
||||
{
|
||||
source++;
|
||||
notflag = true;
|
||||
}
|
||||
if (strncasecmp(source, "not", 3) == 0)
|
||||
{
|
||||
source+=3;
|
||||
notflag = true;
|
||||
}
|
||||
unsigned fnum;
|
||||
int len = p-source;
|
||||
unsigned int init, xorout;
|
||||
for (fnum = 0; fnum < sizeof(checksumMap)/sizeof(checksum); fnum++)
|
||||
{
|
||||
if (strncasecmp(source, checksumMap[fnum].name, p-source) == 0)
|
||||
if ((strncasecmp(source, checksumMap[fnum].name, len) == 0) ||
|
||||
(*source == 'n' && len > 1 && strncasecmp(source+1, checksumMap[fnum].name, len-1) == 0 && (negflag = true)))
|
||||
{
|
||||
init = checksumMap[fnum].init;
|
||||
xorout = checksumMap[fnum].xorout;
|
||||
if (negflag)
|
||||
{
|
||||
init = ~init;
|
||||
xorout = ~xorout;
|
||||
}
|
||||
if (notflag)
|
||||
{
|
||||
xorout = ~xorout;
|
||||
}
|
||||
info.append(&init, sizeof(init));
|
||||
info.append(&xorout, sizeof(xorout));
|
||||
info.append(fnum);
|
||||
source = p+1;
|
||||
return pseudo_format;
|
||||
}
|
||||
}
|
||||
|
||||
error ("Unknown checksum algorithm \"%.*s\"\n",
|
||||
static_cast<int>(p-source), source);
|
||||
error ("Unknown checksum algorithm \"%.*s\"\n", len, source);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ChecksumConverter::
|
||||
printPseudo(const StreamFormat& format, StreamBuffer& output)
|
||||
{
|
||||
ulong sum;
|
||||
int fnum = format.info[0];
|
||||
unsigned int sum;
|
||||
const char* info = format.info;
|
||||
unsigned int init = extract<unsigned int>(info);
|
||||
unsigned int xorout = extract<unsigned int>(info);
|
||||
int fnum = extract<char>(info);
|
||||
|
||||
int start = format.width;
|
||||
int length = output.length()-format.width;
|
||||
if (format.prec > 0) length -= format.prec;
|
||||
|
||||
debug("ChecksumConverter %s: output to check: \"%s\"\n",
|
||||
checksumMap[fnum].name, output.expand(start,length)());
|
||||
|
||||
sum = (xorout ^ checksumMap[fnum].func(
|
||||
reinterpret_cast<unsigned char*>(output(start)), length, init))
|
||||
& mask[checksumMap[fnum].bytes];
|
||||
|
||||
sum = (checksumMap[fnum].xorout ^ checksumMap[fnum].func(
|
||||
reinterpret_cast<uchar*>(output(start)), length,
|
||||
checksumMap[fnum].init)) & mask[checksumMap[fnum].bytes];
|
||||
|
||||
debug("ChecksumConverter %s: output checksum is 0x%lX\n",
|
||||
debug("ChecksumConverter %s: output checksum is 0x%X\n",
|
||||
checksumMap[fnum].name, sum);
|
||||
|
||||
int i;
|
||||
unsigned outchar;
|
||||
|
||||
if (format.flags & sign_flag) // decimal
|
||||
{
|
||||
// get number of decimal digits from number of bytes: ceil(xbytes*2.5)
|
||||
i = (checksumMap[fnum].bytes+1)*25/10-2;
|
||||
output.print("%0*d", i, sum);
|
||||
debug("ChecksumConverter %s: decimal appending %0*d\n",
|
||||
checksumMap[fnum].name, i, sum);
|
||||
}
|
||||
else
|
||||
if (format.flags & alt_flag) // lsb first (little endian)
|
||||
{
|
||||
for (i = 0; i < checksumMap[fnum].bytes; i++)
|
||||
@ -563,7 +609,11 @@ printPseudo(const StreamFormat& format, StreamBuffer& output)
|
||||
debug("ChecksumConverter %s: little endian appending 0x%X\n",
|
||||
checksumMap[fnum].name, outchar);
|
||||
if (format.flags & zero_flag) // ASCII
|
||||
output.printf("%02X", outchar);
|
||||
output.print("%02X", outchar);
|
||||
else
|
||||
if (format.flags & left_flag) // poor man's hex: 0x30 - 0x3F
|
||||
output.print("%c%c",
|
||||
((outchar>>4)&0x0f)|0x30, (outchar&0x0f)|0x30);
|
||||
else // binary
|
||||
output.append(outchar);
|
||||
sum >>= 8;
|
||||
@ -578,7 +628,11 @@ printPseudo(const StreamFormat& format, StreamBuffer& output)
|
||||
debug("ChecksumConverter %s: big endian appending 0x%X\n",
|
||||
checksumMap[fnum].name, outchar);
|
||||
if (format.flags & zero_flag) // ASCII
|
||||
output.printf("%02X", outchar);
|
||||
output.print("%02X", outchar);
|
||||
else
|
||||
if (format.flags & left_flag) // poor man's hex: 0x30 - 0x3F
|
||||
output.print("%c%c",
|
||||
((outchar>>4)&0x0f)|0x30, (outchar&0x0f)|0x30);
|
||||
else // binary
|
||||
output.append(outchar);
|
||||
sum <<= 8;
|
||||
@ -590,57 +644,88 @@ printPseudo(const StreamFormat& format, StreamBuffer& output)
|
||||
int ChecksumConverter::
|
||||
scanPseudo(const StreamFormat& format, StreamBuffer& input, long& cursor)
|
||||
{
|
||||
int fnum = format.info[0];
|
||||
ulong sum;
|
||||
unsigned int sum;
|
||||
const char* info = format.info;
|
||||
unsigned int init = extract<unsigned int>(info);
|
||||
unsigned int xorout = extract<unsigned int>(info);
|
||||
int start = format.width;
|
||||
int fnum = extract<char>(info);
|
||||
int length = cursor-format.width;
|
||||
|
||||
if (format.prec > 0) length -= format.prec;
|
||||
|
||||
debug("ChecksumConverter %s: input to check: \"%s\n",
|
||||
checksumMap[fnum].name, input.expand(start,length)());
|
||||
|
||||
if (input.length() - cursor <
|
||||
(format.flags & zero_flag ? 2 : 1) * checksumMap[fnum].bytes)
|
||||
int expectedLength =
|
||||
// get number of decimal digits from number of bytes: ceil(bytes*2.5)
|
||||
format.flags & sign_flag ? (checksumMap[fnum].bytes + 1) * 25 / 10 - 2 :
|
||||
format.flags & (zero_flag|left_flag) ? 2 * checksumMap[fnum].bytes :
|
||||
checksumMap[fnum].bytes;
|
||||
|
||||
if (input.length() - cursor < expectedLength)
|
||||
{
|
||||
error("Input too short for checksum\n");
|
||||
debug("ChecksumConverter %s: Input '%s' too short for checksum\n",
|
||||
checksumMap[fnum].name, input.expand(cursor)());
|
||||
return -1;
|
||||
}
|
||||
|
||||
sum = (checksumMap[fnum].xorout ^ checksumMap[fnum].func(
|
||||
reinterpret_cast<uchar*>(input(start)), length,
|
||||
checksumMap[fnum].init)) & mask[checksumMap[fnum].bytes];
|
||||
sum = (xorout ^ checksumMap[fnum].func(
|
||||
reinterpret_cast<unsigned char*>(input(start)), length, init))
|
||||
& mask[checksumMap[fnum].bytes];
|
||||
|
||||
debug("ChecksumConverter %s: input checksum is 0x%0*lX\n",
|
||||
debug("ChecksumConverter %s: input checksum is 0x%0*X\n",
|
||||
checksumMap[fnum].name, 2*checksumMap[fnum].bytes, sum);
|
||||
|
||||
int i,j;
|
||||
int i, j;
|
||||
unsigned inchar;
|
||||
|
||||
if (format.flags & sign_flag) // decimal
|
||||
{
|
||||
ulong sumin = 0;
|
||||
// get number of decimal digits from number of bytes: ceil(xbytes*2.5)
|
||||
j = (checksumMap[fnum].bytes+1)*25/10-2;
|
||||
for (i = 0; i < j; i++)
|
||||
unsigned int sumin = 0;
|
||||
for (i = 0; i < expectedLength; i++)
|
||||
{
|
||||
inchar = input[cursor+i];
|
||||
if (isdigit(inchar)) sumin = sumin*10+inchar-'0';
|
||||
else break;
|
||||
}
|
||||
if (sumin==sum) return i;
|
||||
error("Input %0*lu does not match checksum %0*lu\n",
|
||||
i, sumin, j, sum);
|
||||
return -1;
|
||||
if (sumin != sum)
|
||||
{
|
||||
debug("ChecksumConverter %s: Input %0*u does not match checksum %0*u\n",
|
||||
checksumMap[fnum].name, i, sumin, expectedLength, sum);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
else
|
||||
if (format.flags & alt_flag) // lsb first (little endian)
|
||||
{
|
||||
for (i = 0; i < checksumMap[fnum].bytes; i++)
|
||||
{
|
||||
if (format.flags & zero_flag) // ASCII
|
||||
{
|
||||
sscanf(input(cursor+2*i), "%2X", &inchar);
|
||||
if (sscanf(input(cursor+2*i), "%2X", &inchar) != 1)
|
||||
{
|
||||
debug("ChecksumConverter %s: Input byte '%s' is not a hex byte\n",
|
||||
checksumMap[fnum].name, input.expand(cursor+2*i,2)());
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (format.flags & left_flag) // poor man's hex: 0x30 - 0x3F
|
||||
{
|
||||
if ((input[cursor+2*i] & 0xf0) != 0x30)
|
||||
{
|
||||
debug("ChecksumConverter %s: Input byte 0x%02X is not in range 0x30 - 0x3F\n",
|
||||
checksumMap[fnum].name, input[cursor+2*i]);
|
||||
return -1;
|
||||
}
|
||||
if ((input[cursor+2*i+1] & 0xf0) != 0x30)
|
||||
{
|
||||
debug("ChecksumConverter %s: Input byte 0x%02X is not in range 0x30 - 0x3F\n",
|
||||
checksumMap[fnum].name, input[cursor+2*i+1]);
|
||||
return -1;
|
||||
}
|
||||
inchar = ((input[cursor+2*i] & 0x0f) << 4) | (input[cursor+2*i+1] & 0x0f);
|
||||
}
|
||||
else // binary
|
||||
{
|
||||
@ -648,8 +733,8 @@ scanPseudo(const StreamFormat& format, StreamBuffer& input, long& cursor)
|
||||
}
|
||||
if (inchar != ((sum >> 8*i) & 0xff))
|
||||
{
|
||||
error("Input byte 0x%02X does not match checksum 0x%0*lX\n",
|
||||
inchar, 2*checksumMap[fnum].bytes, sum);
|
||||
debug("ChecksumConverter %s: Input byte 0x%02X does not match checksum 0x%0*X\n",
|
||||
checksumMap[fnum].name, inchar, 2*checksumMap[fnum].bytes, sum);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -662,21 +747,36 @@ scanPseudo(const StreamFormat& format, StreamBuffer& input, long& cursor)
|
||||
{
|
||||
sscanf(input(cursor+2*i), "%2x", &inchar);
|
||||
}
|
||||
else
|
||||
if (format.flags & left_flag) // poor man's hex: 0x30 - 0x3F
|
||||
{
|
||||
if ((input[cursor+2*i] & 0xf0) != 0x30)
|
||||
{
|
||||
debug("ChecksumConverter %s: Input byte 0x%02X is not in range 0x30 - 0x3F\n",
|
||||
checksumMap[fnum].name, input[cursor+2*i]);
|
||||
return -1;
|
||||
}
|
||||
if ((input[cursor+2*i+1] & 0xf0) != 0x30)
|
||||
{
|
||||
debug("ChecksumConverter %s: Input byte 0x%02X is not in range 0x30 - 0x3F\n",
|
||||
checksumMap[fnum].name, input[cursor+2*i+1]);
|
||||
return -1;
|
||||
}
|
||||
inchar = ((input[cursor+2*i] & 0x0f) << 4) | (input[cursor+2*i+1] & 0x0f);
|
||||
}
|
||||
else // binary
|
||||
{
|
||||
inchar = input[cursor+i] & 0xff;
|
||||
}
|
||||
if (inchar != ((sum >> 8*j) & 0xff))
|
||||
{
|
||||
error("Input byte 0x%02X does not match checksum 0x%0*lX\n",
|
||||
inchar, 2*checksumMap[fnum].bytes, sum);
|
||||
debug("ChecksumConverter %s: Input byte 0x%02X does not match checksum 0x%0*X\n",
|
||||
checksumMap[fnum].name, inchar, 2*checksumMap[fnum].bytes, sum);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (format.flags & zero_flag) // ASCII
|
||||
return 2*checksumMap[fnum].bytes;
|
||||
return checksumMap[fnum].bytes;
|
||||
return expectedLength;
|
||||
}
|
||||
|
||||
RegisterConverter (ChecksumConverter, "<");
|
||||
|
@ -36,7 +36,7 @@ class EnumConverter : public StreamFormatConverter
|
||||
|
||||
int EnumConverter::
|
||||
parse(const StreamFormat& fmt, StreamBuffer& info,
|
||||
const char*& source, bool)
|
||||
const char*& source, bool scanFormat)
|
||||
{
|
||||
if (fmt.flags & (left_flag|sign_flag|space_flag|zero_flag))
|
||||
{
|
||||
@ -56,7 +56,30 @@ parse(const StreamFormat& fmt, StreamBuffer& info,
|
||||
if (*source == '=' && (fmt.flags & alt_flag))
|
||||
{
|
||||
char* p;
|
||||
index = strtol(++source, &p, 0);
|
||||
|
||||
if (*++source == '?')
|
||||
{
|
||||
// default choice
|
||||
if (scanFormat)
|
||||
{
|
||||
error("Default value only allowed in output formats\n");
|
||||
return false;
|
||||
}
|
||||
if (*++source != '}')
|
||||
{
|
||||
error("Default value must be last\n");
|
||||
return false;
|
||||
}
|
||||
source++;
|
||||
numEnums = -(numEnums+1);
|
||||
info.append('\0');
|
||||
memcpy(info(n), &numEnums, sizeof(numEnums));
|
||||
debug("EnumConverter::parse %ld choices with default: %s\n",
|
||||
-numEnums, info.expand()());
|
||||
return enum_format;
|
||||
}
|
||||
|
||||
index = strtol(source, &p, 0);
|
||||
if (p == source || (*p != '|' && *p != '}'))
|
||||
{
|
||||
error("Integer expected after '=' "
|
||||
@ -99,6 +122,9 @@ printLong(const StreamFormat& fmt, StreamBuffer& output, long value)
|
||||
const char* s = fmt.info;
|
||||
long numEnums = extract<long>(s);
|
||||
long index = extract<long>(s);
|
||||
bool noDefault = numEnums >= 0;
|
||||
|
||||
if (numEnums < 0) numEnums=-numEnums-1;
|
||||
while (numEnums-- && (value != index))
|
||||
{
|
||||
while(*s)
|
||||
@ -109,7 +135,7 @@ printLong(const StreamFormat& fmt, StreamBuffer& output, long value)
|
||||
s++;
|
||||
index = extract<long>(s);
|
||||
}
|
||||
if (numEnums == -1)
|
||||
if (numEnums == -1 && noDefault)
|
||||
{
|
||||
error("Value %li not found in enum set\n", value);
|
||||
return false;
|
||||
|
25
src/Makefile
@ -18,7 +18,7 @@
|
||||
# #
|
||||
################################################################
|
||||
|
||||
TOP=../..
|
||||
TOP:=../$(TOP)
|
||||
|
||||
# Look if we have EPICS R3.13 or R3.14
|
||||
ifeq ($(wildcard $(TOP)/configure),)
|
||||
@ -40,13 +40,8 @@ DBD += $(LIBRARY_DEFAULT).dbd
|
||||
|
||||
ifdef ASYN
|
||||
LIB_LIBS += asyn
|
||||
BUSSES += AsynDriver
|
||||
endif
|
||||
|
||||
ifdef T_A
|
||||
ifndef BUSSES
|
||||
$(error No bus interface defined! Didn't you set ASYN in your RELEASE file?)
|
||||
endif
|
||||
else
|
||||
$(warning Asyn not included! Didn't you set ASYN in your RELEASE file?)
|
||||
endif
|
||||
|
||||
ifeq ($(LOADABLE_MODULE),YES)
|
||||
@ -54,7 +49,7 @@ SRCS += $(LIBRARY_DEFAULT)_registerRecordDeviceDriver.cpp
|
||||
endif
|
||||
SRCS += $(BUSSES:%=%Interface.cc)
|
||||
SRCS += $(FORMATS:%=%Converter.cc)
|
||||
SRCS += $(RECORDS:%=dev%Stream.c)
|
||||
SRCS += $(RECORDTYPES:%=dev%Stream.c)
|
||||
SRCS += $(STREAM_SRCS)
|
||||
|
||||
# find system wide or local PCRE header and library
|
||||
@ -79,19 +74,21 @@ include $(TOP)/configure/RULES
|
||||
|
||||
# Update version string (contains __DATE__ and __TIME__)
|
||||
# each time make runs.
|
||||
StreamVersion$(OBJ): FORCE
|
||||
FORCE:
|
||||
StreamVersion$(OBJ): ../*.c ../*.h ../*.cc ../CONFIG_STREAM ../Makefile
|
||||
|
||||
# Add references to all registrars to main file to avoid
|
||||
# missing initialization.
|
||||
StreamCore$(OBJ): streamReferences
|
||||
StreamCore$(OBJ) StreamCore$(DEP): streamReferences
|
||||
|
||||
streamReferences: ../CONFIG_STREAM
|
||||
$(PERL) ../makeref.pl Interface $(BUSSES) > $@
|
||||
$(PERL) ../makeref.pl Converter $(FORMATS) >> $@
|
||||
|
||||
# create stream.dbd from all RECORDS
|
||||
# create stream.dbd from all RECORDTYPES
|
||||
$(COMMON_DIR)/$(LIBRARY_DEFAULT).dbd: ../CONFIG_STREAM
|
||||
$(PERL) ../makedbd.pl $(RECORDS) > $@
|
||||
$(PERL) ../makedbd.pl $(RECORDTYPES) > $@
|
||||
|
||||
$(LIBRARY_DEFAULT).dbd$(DEP): ../CONFIG_STREAM
|
||||
echo $(LIBRARY_DEFAULT).dbd: $< > $@
|
||||
|
||||
endif
|
||||
|
@ -18,14 +18,11 @@
|
||||
# #
|
||||
################################################################
|
||||
|
||||
TOP = ../../..
|
||||
TOP := ../../$(TOP)
|
||||
|
||||
include $(TOP)/config/CONFIG_APP
|
||||
include ../CONFIG_STREAM
|
||||
|
||||
# In 3.13, calcout has no device support
|
||||
RECORDS_3_13 = $(filter-out calcout,$(RECORDS))
|
||||
|
||||
DBDNAME = stream.dbd
|
||||
|
||||
INC += devStream.h
|
||||
@ -35,11 +32,9 @@ INC += devStream.h
|
||||
CONFIGS = RULES.munch
|
||||
SCRIPTS = munch.pl
|
||||
|
||||
include $(TOP)/config/RULES.Host
|
||||
include $(EPICS_BASE)/config/RULES.Host
|
||||
|
||||
# create stream.dbd from all RECORDS
|
||||
# create stream.dbd from all RECORDTYPES
|
||||
# In 3.13, calcout has no device support
|
||||
stream.dbd: ../CONFIG_STREAM
|
||||
@for r in $(RECORDS_3_13); \
|
||||
do echo "device($$r,INST_IO,dev$${r}Stream,\"stream\")"; \
|
||||
done > $@
|
||||
@echo "driver(stream)" >> $@
|
||||
$(PERL) ../makedbd.pl -3.13 $(filter-out calcout,$(RECORDTYPES)) > $@
|
||||
|
@ -18,29 +18,23 @@
|
||||
# #
|
||||
################################################################
|
||||
|
||||
TOP = ../../..
|
||||
TOP := ../../$(TOP)
|
||||
|
||||
include $(TOP)/config/CONFIG_APP
|
||||
include ../CONFIG_STREAM
|
||||
|
||||
LIBNAME = streamLib
|
||||
|
||||
# In 3.13, calcout has no device support
|
||||
RECORDS_3_13 = $(filter-out calcout,$(RECORDS))
|
||||
|
||||
ifdef ASYN
|
||||
BUSSES += AsynDriver
|
||||
endif
|
||||
|
||||
SRCS.cc += $(patsubst %,../%,$(filter %.cc,$(STREAM_SRCS)))
|
||||
SRCS.cc += $(BUSSES:%=../%Interface.cc)
|
||||
SRCS.cc += $(FORMATS:%=../%Converter.cc)
|
||||
SRCS.c += $(patsubst %,../%,$(filter %.c,$(STREAM_SRCS)))
|
||||
SRCS.c += $(RECORDS_3_13:%=../dev%Stream.c)
|
||||
# In 3.13, calcout has no device support
|
||||
SRCS.c += $(patsubst %,../dev%Stream.c,$(filter-out calcout,$(RECORDTYPES)))
|
||||
|
||||
LIBOBJS = $(patsubst ../%,%.o,$(basename $(SRCS.cc) $(SRCS.c)))
|
||||
|
||||
include $(TOP)/config/RULES.Vx
|
||||
include $(EPICS_BASE)/config/RULES.Vx
|
||||
include $(TOP)/config/RULES.munch
|
||||
|
||||
build:: depends
|
||||
|
@ -75,7 +75,7 @@ printDouble(const StreamFormat& fmt, StreamBuffer& output, double value)
|
||||
int prec = fmt.prec;
|
||||
|
||||
if (prec < 1) prec = 6;
|
||||
buf.printf("%.*e", prec-1, fabs(value)/pow(10.0, prec-1));
|
||||
buf.print("%.*e", prec-1, fabs(value)/pow(10.0, prec-1));
|
||||
buf.remove(1,1);
|
||||
buf.remove(buf.find('e'),1);
|
||||
|
||||
|
@ -31,23 +31,23 @@ class RawConverter : public StreamFormatConverter
|
||||
};
|
||||
|
||||
int RawConverter::
|
||||
parse(const StreamFormat&, StreamBuffer&,
|
||||
parse(const StreamFormat& fmt, StreamBuffer&,
|
||||
const char*&, bool)
|
||||
{
|
||||
return long_format;
|
||||
return (fmt.flags & (sign_flag|zero_flag)) ? signed_format : unsigned_format;
|
||||
}
|
||||
|
||||
bool RawConverter::
|
||||
printLong(const StreamFormat& format, StreamBuffer& output, long value)
|
||||
printLong(const StreamFormat& fmt, StreamBuffer& output, long value)
|
||||
{
|
||||
int prec = format.prec; // number of bytes from value
|
||||
int prec = fmt.prec; // number of bytes from value
|
||||
if (prec == -1) prec = 1; // default: 1 byte
|
||||
int width = prec; // number of bytes in output
|
||||
if (prec > (int)sizeof(long)) prec=sizeof(long);
|
||||
if (format.width > width) width = format.width;
|
||||
if (fmt.width > width) width = fmt.width;
|
||||
|
||||
char byte = 0;
|
||||
if (format.flags & alt_flag) // little endian (lsb first)
|
||||
if (fmt.flags & alt_flag) // little endian (lsb first)
|
||||
{
|
||||
while (prec--)
|
||||
{
|
||||
@ -56,7 +56,7 @@ printLong(const StreamFormat& format, StreamBuffer& output, long value)
|
||||
value >>= 8;
|
||||
width--;
|
||||
}
|
||||
if (format.flags & zero_flag)
|
||||
if (fmt.flags & zero_flag)
|
||||
{
|
||||
// fill with zero
|
||||
byte = 0;
|
||||
@ -73,7 +73,7 @@ printLong(const StreamFormat& format, StreamBuffer& output, long value)
|
||||
}
|
||||
else // big endian (msb first)
|
||||
{
|
||||
if (format.flags & zero_flag)
|
||||
if (fmt.flags & zero_flag)
|
||||
{
|
||||
// fill with zero
|
||||
byte = 0;
|
||||
@ -97,17 +97,17 @@ printLong(const StreamFormat& format, StreamBuffer& output, long value)
|
||||
}
|
||||
|
||||
int RawConverter::
|
||||
scanLong(const StreamFormat& format, const char* input, long& value)
|
||||
scanLong(const StreamFormat& fmt, const char* input, long& value)
|
||||
{
|
||||
long length = 0;
|
||||
long val = 0;
|
||||
int width = format.width;
|
||||
int width = fmt.width;
|
||||
if (width == 0) width = 1; // default: 1 byte
|
||||
if (format.flags & skip_flag)
|
||||
if (fmt.flags & skip_flag)
|
||||
{
|
||||
return width; // just skip input
|
||||
}
|
||||
if (format.flags & alt_flag)
|
||||
if (fmt.flags & alt_flag)
|
||||
{
|
||||
// little endian (lsb first)
|
||||
unsigned int shift = 0;
|
||||
@ -118,7 +118,7 @@ scanLong(const StreamFormat& format, const char* input, long& value)
|
||||
}
|
||||
if (width == 0)
|
||||
{
|
||||
if (format.flags & zero_flag)
|
||||
if (fmt.flags & zero_flag)
|
||||
{
|
||||
// fill with zero
|
||||
val |= ((unsigned char) input[length++]) << shift;
|
||||
@ -134,7 +134,7 @@ scanLong(const StreamFormat& format, const char* input, long& value)
|
||||
else
|
||||
{
|
||||
// big endian (msb first)
|
||||
if (format.flags & zero_flag)
|
||||
if (fmt.flags & zero_flag)
|
||||
{
|
||||
// fill with zero
|
||||
val = (unsigned char) input[length++];
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include "string.h"
|
||||
#include "pcre.h"
|
||||
|
||||
// Perl regular expressions (PCRE) %/regexp/
|
||||
// Perl regular expressions (PCRE) %/regexp/ and %#/regexp/subst/
|
||||
|
||||
/* Notes:
|
||||
- Memory for compiled regexp is allocated in parse but never freed.
|
||||
@ -37,15 +37,17 @@
|
||||
|
||||
class RegexpConverter : public StreamFormatConverter
|
||||
{
|
||||
int parse (const StreamFormat&, StreamBuffer&, const char*&, bool);
|
||||
int scanString(const StreamFormat&, const char*, char*, size_t);
|
||||
int parse (const StreamFormat& fmt, StreamBuffer&, const char*&, bool);
|
||||
int scanString(const StreamFormat& fmt, const char*, char*, size_t);
|
||||
int scanPseudo(const StreamFormat& fmt, StreamBuffer& input, long& cursor);
|
||||
bool printPseudo(const StreamFormat& fmt, StreamBuffer& output);
|
||||
};
|
||||
|
||||
int RegexpConverter::
|
||||
parse(const StreamFormat& fmt, StreamBuffer& info,
|
||||
const char*& source, bool scanFormat)
|
||||
{
|
||||
if (!scanFormat)
|
||||
if (!scanFormat && !(fmt.flags & alt_flag))
|
||||
{
|
||||
error("Format conversion %%/regexp/ is only allowed in input formats\n");
|
||||
return false;
|
||||
@ -55,28 +57,31 @@ parse(const StreamFormat& fmt, StreamBuffer& info,
|
||||
error("Subexpression index %d too big (>9)\n", fmt.prec);
|
||||
return false;
|
||||
}
|
||||
if (fmt.flags & (left_flag|space_flag|zero_flag|alt_flag))
|
||||
{
|
||||
error("Use of modifiers '-', ' ', '0', '#'"
|
||||
"not allowed with %%/regexp/ conversion\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
StreamBuffer pattern;
|
||||
while (*source != '/')
|
||||
{
|
||||
if (!*source) {
|
||||
error("Missing closing '/' after %%/ format conversion\n");
|
||||
error("Missing closing '/' after %%/%s format conversion\n", pattern());
|
||||
return false;
|
||||
}
|
||||
if (*source == esc) {
|
||||
source++;
|
||||
pattern.printf("\\x%02x", *source++ & 0xFF);
|
||||
continue;
|
||||
if (*source == esc) { // handle escaped chars
|
||||
if (*++source != '/') // just un-escape /
|
||||
{
|
||||
pattern.append('\\');
|
||||
if ((*source & 0x7f) < 0x30) // handle control chars
|
||||
{
|
||||
pattern.print("x%02x", *source++);
|
||||
continue;
|
||||
}
|
||||
// fall through for PCRE codes like \B
|
||||
}
|
||||
}
|
||||
pattern.append(*source++);
|
||||
}
|
||||
source++;
|
||||
debug("regexp = \"%s\"\n", pattern());
|
||||
debug("regexp = \"%s\"\n", pattern.expand()());
|
||||
|
||||
const char* errormsg;
|
||||
int eoffset;
|
||||
pcre* code = pcre_compile(pattern(), 0,
|
||||
@ -87,6 +92,26 @@ parse(const StreamFormat& fmt, StreamBuffer& info,
|
||||
return false;
|
||||
}
|
||||
info.append(&code, sizeof(code));
|
||||
|
||||
if (fmt.flags & alt_flag)
|
||||
{
|
||||
StreamBuffer subst;
|
||||
debug("check for subst in \"%s\"\n", StreamBuffer(source).expand()());
|
||||
while (*source != '/')
|
||||
{
|
||||
if (!*source) {
|
||||
error("Missing closing '/' after %%#/%s/%s format conversion\n", pattern(), subst());
|
||||
return false;
|
||||
}
|
||||
if (*source == esc)
|
||||
subst.append(*source++);
|
||||
subst.append(*source++);
|
||||
}
|
||||
source++;
|
||||
debug("subst = \"%s\"\n", subst.expand()());
|
||||
info.append(subst).append('\0');
|
||||
return pseudo_format;
|
||||
}
|
||||
return string_format;
|
||||
}
|
||||
|
||||
@ -94,32 +119,130 @@ int RegexpConverter::
|
||||
scanString(const StreamFormat& fmt, const char* input,
|
||||
char* value, size_t maxlen)
|
||||
{
|
||||
pcre* code;
|
||||
size_t len;
|
||||
int ovector[30];
|
||||
int rc;
|
||||
int subexpr = 0;
|
||||
unsigned int l;
|
||||
|
||||
memcpy (&code, fmt.info, sizeof(code));
|
||||
const char* info = fmt.info;
|
||||
pcre* code = extract<pcre*>(info);
|
||||
int length = fmt.width > 0 ? fmt.width : strlen(input);
|
||||
int subexpr = fmt.prec > 0 ? fmt.prec : 0;
|
||||
|
||||
len = fmt.width > 0 ? fmt.width : strlen(input);
|
||||
subexpr = fmt.prec > 0 ? fmt.prec : 0;
|
||||
rc = pcre_exec(code, NULL, input, len, 0, 0, ovector, 30);
|
||||
if (rc < 1) return -1;
|
||||
if (fmt.flags & skip_flag) return ovector[1];
|
||||
len = ovector[subexpr*2+1] - ovector[subexpr*2];
|
||||
if (len >= maxlen) {
|
||||
debug("input = \"%s\"\n", input);
|
||||
debug("length=%d\n", length);
|
||||
|
||||
rc = pcre_exec(code, NULL, input, length, 0, 0, ovector, 30);
|
||||
debug("pcre_exec match \"%.*s\" result = %d\n", length, input, rc);
|
||||
if ((subexpr && rc <= subexpr) || rc < 0)
|
||||
{
|
||||
// error or no match or not enough sub-expressions
|
||||
return -1;
|
||||
}
|
||||
if (fmt.flags & skip_flag) return ovector[subexpr*2+1];
|
||||
|
||||
l = ovector[subexpr*2+1] - ovector[subexpr*2];
|
||||
if (l >= maxlen) {
|
||||
if (!(fmt.flags & sign_flag)) {
|
||||
debug("Matching string \"%s\" too long (%d>%d bytes)\n",
|
||||
StreamBuffer(input+ovector[subexpr*2], len).expand()(),
|
||||
(int)len, (int)maxlen-1);
|
||||
error("Regexp: Matching string \"%s\" too long (%d>%ld bytes). You may want to try the + flag: \"%%+/.../\"\n",
|
||||
StreamBuffer(input + ovector[subexpr*2],l).expand()(),
|
||||
l, (long)maxlen-1);
|
||||
return -1;
|
||||
}
|
||||
len = maxlen-1;
|
||||
l = maxlen-1;
|
||||
}
|
||||
memcpy(value, input+ovector[subexpr*2], len);
|
||||
value[len]=0;
|
||||
return ovector[1];
|
||||
memcpy(value, input + ovector[subexpr*2], l);
|
||||
value[l] = '\0';
|
||||
return ovector[1]; // consume input until end of match
|
||||
}
|
||||
|
||||
static void regsubst(const StreamFormat& fmt, StreamBuffer& buffer, long start)
|
||||
{
|
||||
const char* subst = fmt.info;
|
||||
pcre* code = extract<pcre*>(subst);
|
||||
long length;
|
||||
int rc, l, c, r, rl, n;
|
||||
int ovector[30];
|
||||
StreamBuffer s;
|
||||
|
||||
length = buffer.length() - start;
|
||||
if (fmt.width && fmt.width < length)
|
||||
length = fmt.width;
|
||||
if (fmt.flags & sign_flag)
|
||||
start = buffer.length() - length;
|
||||
|
||||
debug("regsubst buffer=\"%s\", start=%ld, length=%ld, subst = \"%s\"\n",
|
||||
buffer.expand()(), start, length, subst);
|
||||
|
||||
for (c = 0, n = 1; c < length; n++)
|
||||
{
|
||||
rc = pcre_exec(code, NULL, buffer(start+c), length-c, 0, 0, ovector, 30);
|
||||
debug("pcre_exec match \"%.*s\" result = %d\n", (int)length-c, buffer(start+c), rc);
|
||||
if (rc < 0) // no match
|
||||
return;
|
||||
|
||||
if (!(fmt.flags & sign_flag) && n < fmt.prec) // without + flag
|
||||
{
|
||||
// do not yet replace this match
|
||||
c += ovector[1];
|
||||
continue;
|
||||
}
|
||||
// replace & by match in subst
|
||||
l = ovector[1] - ovector[0];
|
||||
debug("start = \"%s\"\n", buffer(start+c));
|
||||
debug("match = \"%.*s\"\n", l, buffer(start+c+ovector[0]));
|
||||
for (r = 1; r < rc; r++)
|
||||
debug("sub%d = \"%.*s\"\n", r, ovector[r*2+1]-ovector[r*2], buffer(start+c+ovector[r*2]));
|
||||
debug("rest = \"%s\"\n", buffer(start+c+ovector[1]));
|
||||
s = subst;
|
||||
debug("subs = \"%s\"\n", s.expand()());
|
||||
for (r = 0; r < s.length(); r++)
|
||||
{
|
||||
debug("check \"%s\"\n", s.expand(r)());
|
||||
if (s[r] == esc)
|
||||
{
|
||||
unsigned char ch = s[r+1];
|
||||
if (ch < 9) // escaped 0 - 9 : replace with subexpr
|
||||
{
|
||||
ch *= 2;
|
||||
rl = ovector[ch+1] - ovector[ch];
|
||||
debug("replace \\%d: \"%.*s\"\n", ch/2, rl, buffer(start+c+ovector[ch]));
|
||||
s.replace(r, 2, buffer(start+c+ovector[ch]), rl);
|
||||
r += rl - 1;
|
||||
}
|
||||
else
|
||||
s.remove(r, 1); // just remove escape
|
||||
}
|
||||
else if (s[r] == '&') // unescaped & : replace with match
|
||||
{
|
||||
debug("replace &: \"%.*s\"\n", l, buffer(start+c+ovector[0]));
|
||||
s.replace(r, 1, buffer(start+c+ovector[0]), l);
|
||||
r += l - 1;
|
||||
}
|
||||
else continue;
|
||||
debug("subs = \"%s\"\n", s());
|
||||
}
|
||||
buffer.replace(start+c+ovector[0], l, s);
|
||||
length += s.length() - l;
|
||||
c += s.length();
|
||||
if (n == fmt.prec) // max match reached
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int RegexpConverter::
|
||||
scanPseudo(const StreamFormat& fmt, StreamBuffer& input, long& cursor)
|
||||
{
|
||||
/* re-write input buffer */
|
||||
regsubst(fmt, input, cursor);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool RegexpConverter::
|
||||
printPseudo(const StreamFormat& fmt, StreamBuffer& output)
|
||||
{
|
||||
/* re-write output buffer */
|
||||
regsubst(fmt, output, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
RegisterConverter (RegexpConverter, "/");
|
||||
|
@ -26,19 +26,20 @@
|
||||
|
||||
#if defined(__vxworks) || defined(vxWorks) || defined(_WIN32) || defined(__rtems__)
|
||||
// These systems have no vsnprintf
|
||||
#include <epicsStdio.h>
|
||||
#define vsnprintf epicsVsnprintf
|
||||
#define vsnprintf(p,l,f,v) vsprintf(p,f,v)
|
||||
#endif
|
||||
|
||||
#define P PRINTF_SIZE_T_PREFIX
|
||||
|
||||
void StreamBuffer::
|
||||
init(const void* s, long minsize)
|
||||
init(const void* s, ssize_t minsize)
|
||||
{
|
||||
len = 0;
|
||||
offs = 0;
|
||||
buffer = local;
|
||||
cap = sizeof(local);
|
||||
if (minsize < 0) minsize = 0;
|
||||
if (minsize >= cap)
|
||||
if ((size_t)minsize >= cap)
|
||||
{
|
||||
// use allocated buffer
|
||||
grow(minsize);
|
||||
@ -55,18 +56,18 @@ init(const void* s, long minsize)
|
||||
}
|
||||
|
||||
// How the buffer looks like:
|
||||
// |----free-----|####used####|-------free-------|
|
||||
// |----free-----|####used####|--------00--------|
|
||||
///|<--- offs -->|<-- len --->|<- cap-offs-len ->|
|
||||
// 0 offs offs+len cap
|
||||
// |<-------------- minsize --------------->
|
||||
|
||||
|
||||
void StreamBuffer::
|
||||
grow(long minsize)
|
||||
grow(size_t minsize)
|
||||
{
|
||||
// make space for minsize + 1 (for termination) bytes
|
||||
char* newbuffer;
|
||||
long newcap;
|
||||
size_t newcap;
|
||||
#ifdef EXPLODE
|
||||
if (minsize > 1000000)
|
||||
{
|
||||
@ -117,12 +118,12 @@ grow(long minsize)
|
||||
}
|
||||
|
||||
StreamBuffer& StreamBuffer::
|
||||
append(const void* s, long size)
|
||||
append(const void* s, ssize_t size)
|
||||
{
|
||||
if (size <= 0)
|
||||
{
|
||||
// append negative number of bytes? let's delete some
|
||||
if (size < -len) size = -len;
|
||||
if (size < -(ssize_t)len) size = -(ssize_t)len;
|
||||
memset (buffer+offs+len+size, 0, -size);
|
||||
}
|
||||
else
|
||||
@ -134,8 +135,8 @@ append(const void* s, long size)
|
||||
return *this;
|
||||
}
|
||||
|
||||
long int StreamBuffer::
|
||||
find(const void* m, long size, long start) const
|
||||
ssize_t StreamBuffer::
|
||||
find(const void* m, size_t size, ssize_t start) const
|
||||
{
|
||||
if (start < 0)
|
||||
{
|
||||
@ -147,7 +148,7 @@ find(const void* m, long size, long start) const
|
||||
const char* s = static_cast<const char*>(m);
|
||||
char* b = buffer+offs;
|
||||
char* p = b+start;
|
||||
long i;
|
||||
size_t i;
|
||||
while ((p = static_cast<char*>(memchr(p, s[0], b-p+len-size+1))))
|
||||
{
|
||||
for (i = 1; i < size; i++)
|
||||
@ -161,7 +162,7 @@ next: p++;
|
||||
}
|
||||
|
||||
StreamBuffer& StreamBuffer::
|
||||
replace(long remstart, long remlen, const void* ins, long inslen)
|
||||
replace(ssize_t remstart, ssize_t remlen, const void* ins, ssize_t inslen)
|
||||
{
|
||||
if (remstart < 0)
|
||||
{
|
||||
@ -187,12 +188,12 @@ replace(long remstart, long remlen, const void* ins, long inslen)
|
||||
remlen += remstart;
|
||||
remstart = 0;
|
||||
}
|
||||
if (remstart > len)
|
||||
if ((size_t)remstart > len)
|
||||
{
|
||||
// remove begins after bufferend
|
||||
remstart = len;
|
||||
}
|
||||
if (remlen >= len-remstart)
|
||||
if ((size_t)remlen >= len-remstart)
|
||||
{
|
||||
// truncate remove after bufferend
|
||||
remlen = len-remstart;
|
||||
@ -205,12 +206,12 @@ replace(long remstart, long remlen, const void* ins, long inslen)
|
||||
return *this;
|
||||
}
|
||||
if (inslen < 0) inslen = 0;
|
||||
long remend = remstart+remlen;
|
||||
long newlen = len+inslen-remlen;
|
||||
size_t remend = remstart+remlen;
|
||||
size_t newlen = len+inslen-remlen;
|
||||
if (cap <= newlen)
|
||||
{
|
||||
// buffer too short
|
||||
long newcap;
|
||||
size_t newcap;
|
||||
for (newcap = sizeof(local)*2; newcap <= newlen; newcap *= 2);
|
||||
char* newbuffer = new char[newcap];
|
||||
memcpy(newbuffer, buffer+offs, remstart);
|
||||
@ -248,16 +249,16 @@ replace(long remstart, long remlen, const void* ins, long inslen)
|
||||
}
|
||||
|
||||
StreamBuffer& StreamBuffer::
|
||||
printf(const char* fmt, ...)
|
||||
print(const char* fmt, ...)
|
||||
{
|
||||
va_list va;
|
||||
int printed;
|
||||
ssize_t printed;
|
||||
while (1)
|
||||
{
|
||||
va_start(va, fmt);
|
||||
printed = vsnprintf(buffer+offs+len, cap-offs-len, fmt, va);
|
||||
va_end(va);
|
||||
if (printed > -1 && printed < (int)(cap-offs-len))
|
||||
if (printed > -1 && printed < (ssize_t)(cap-offs-len))
|
||||
{
|
||||
len += printed;
|
||||
return *this;
|
||||
@ -267,9 +268,9 @@ printf(const char* fmt, ...)
|
||||
}
|
||||
}
|
||||
|
||||
StreamBuffer StreamBuffer::expand(long start, long length) const
|
||||
StreamBuffer StreamBuffer::expand(ssize_t start, ssize_t length) const
|
||||
{
|
||||
long end;
|
||||
size_t end;
|
||||
if (start < 0)
|
||||
{
|
||||
start += len;
|
||||
@ -289,14 +290,14 @@ StreamBuffer StreamBuffer::expand(long start, long length) const
|
||||
StreamBuffer result((end-start)*2);
|
||||
start += offs;
|
||||
end += offs;
|
||||
long i;
|
||||
size_t i;
|
||||
char c;
|
||||
for (i = start; i < end; i++)
|
||||
{
|
||||
c = buffer[i];
|
||||
if ((c & 0x7f) < 0x20 || (c & 0x7f) == 0x7f)
|
||||
if (c < 0x20 || c >= 0x7f)
|
||||
{
|
||||
result.printf("<%02x>", c & 0xff);
|
||||
result.print("<%02x>", c & 0xff);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -311,18 +312,18 @@ dump() const
|
||||
{
|
||||
StreamBuffer result(256+cap*5);
|
||||
result.append("\033[0m");
|
||||
long i;
|
||||
result.printf("%ld,%ld,%ld:\033[37m", offs, len, cap);
|
||||
size_t i;
|
||||
result.print("%" P "d,%" P "d,%" P "d:\033[37m", offs, len, cap);
|
||||
for (i = 0; i < cap; i++)
|
||||
{
|
||||
if (i == offs) result.append("\033[34m[\033[0m");
|
||||
if ((buffer[i] & 0x7f) < 0x20 || (buffer[i] & 0x7f) == 0x7f)
|
||||
{
|
||||
if (i < offs || i >= offs+len)
|
||||
result.printf(
|
||||
result.print(
|
||||
"<%02x>", buffer[i] & 0xff);
|
||||
else
|
||||
result.printf(
|
||||
result.print(
|
||||
"\033[34m<%02x>\033[37m", buffer[i] & 0xff);
|
||||
}
|
||||
else
|
||||
|
@ -21,30 +21,36 @@
|
||||
#define StreamBuffer_h
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifndef __GNUC__
|
||||
#define __attribute__(x)
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#define ssize_t ptrdiff_t
|
||||
#endif
|
||||
|
||||
class StreamBuffer
|
||||
{
|
||||
char local[64];
|
||||
long len;
|
||||
long cap;
|
||||
long offs;
|
||||
size_t len;
|
||||
size_t cap;
|
||||
size_t offs;
|
||||
char* buffer;
|
||||
|
||||
void init(const void* s, long minsize);
|
||||
void init(const void* s, ssize_t minsize);
|
||||
|
||||
void check(long size)
|
||||
void check(size_t size)
|
||||
{if (len+offs+size >= cap) grow(len+size);}
|
||||
|
||||
void grow(long minsize);
|
||||
void grow(size_t minsize);
|
||||
|
||||
public:
|
||||
// Hints:
|
||||
// * Any index parameter (long) can be negative
|
||||
// * Any index parameter (ssize_t) can be negative
|
||||
// meaning "count from end" (-1 is the last byte)
|
||||
// * Appending negative count deletes from end
|
||||
// * Any returned char* pointer becomes invalid when
|
||||
@ -55,7 +61,7 @@ public:
|
||||
StreamBuffer()
|
||||
{init(NULL, 0);}
|
||||
|
||||
StreamBuffer(const void* s, long size)
|
||||
StreamBuffer(const void* s, ssize_t size)
|
||||
{init(s, size);}
|
||||
|
||||
StreamBuffer(const char* s)
|
||||
@ -64,24 +70,24 @@ public:
|
||||
StreamBuffer(const StreamBuffer& s)
|
||||
{init(s.buffer+s.offs, s.len);}
|
||||
|
||||
StreamBuffer(long size)
|
||||
StreamBuffer(ssize_t size)
|
||||
{init(NULL, size);}
|
||||
|
||||
~StreamBuffer()
|
||||
{if (buffer != local) delete buffer;}
|
||||
|
||||
// operator (): get char* pointing to index
|
||||
const char* operator()(long index=0) const
|
||||
const char* operator()(ssize_t index=0) const
|
||||
{return buffer+offs+(index<0?index+len:index);}
|
||||
|
||||
char* operator()(long index=0)
|
||||
char* operator()(ssize_t index=0)
|
||||
{return buffer+offs+(index<0?index+len:index);}
|
||||
|
||||
// operator []: get byte at index
|
||||
char operator[](long index) const
|
||||
char operator[](ssize_t index) const
|
||||
{return buffer[offs+(index<0?index+len:index)];}
|
||||
|
||||
char& operator[](long index)
|
||||
char& operator[](ssize_t index)
|
||||
{return buffer[offs+(index<0?index+len:index)];}
|
||||
|
||||
// cast to bool: not empty?
|
||||
@ -89,11 +95,11 @@ public:
|
||||
{return len>0;}
|
||||
|
||||
// length: get current data length
|
||||
long length() const
|
||||
ssize_t length() const
|
||||
{return len;}
|
||||
|
||||
// capacity: get current max data length (spare one byte for end)
|
||||
long capacity() const
|
||||
ssize_t capacity() const
|
||||
{return cap-1;}
|
||||
|
||||
// end: get pointer to byte after last data byte
|
||||
@ -106,19 +112,19 @@ public:
|
||||
|
||||
// reserve: reserve size bytes of memory and return
|
||||
// pointer to that memory (for copying something to it)
|
||||
char* reserve(long size)
|
||||
char* reserve(size_t size)
|
||||
{check(size); char* p=buffer+offs+len; len+=size; return p;}
|
||||
|
||||
// append: append data at the end of the buffer
|
||||
StreamBuffer& append(char c)
|
||||
{check(1); buffer[offs+len++]=c; return *this;}
|
||||
|
||||
StreamBuffer& append(char c, long count)
|
||||
StreamBuffer& append(char c, ssize_t count)
|
||||
{if (count < 0) truncate(count);
|
||||
else {check(count); memset(buffer+offs+len, c, count); len+=count;}
|
||||
return *this;}
|
||||
|
||||
StreamBuffer& append(const void* s, long size);
|
||||
StreamBuffer& append(const void* s, ssize_t size);
|
||||
|
||||
StreamBuffer& append(const char* s)
|
||||
{return append(s, s?strlen(s):0);}
|
||||
@ -126,7 +132,7 @@ public:
|
||||
StreamBuffer& append(const StreamBuffer& s)
|
||||
{return append(s.buffer+s.offs, s.len);}
|
||||
|
||||
// operator += alias for set
|
||||
// operator += alias for append
|
||||
StreamBuffer& operator+=(char c)
|
||||
{return append(c);}
|
||||
|
||||
@ -137,7 +143,7 @@ public:
|
||||
{return append(s);}
|
||||
|
||||
// set: clear buffer and fill with new data
|
||||
StreamBuffer& set(const void* s, long size)
|
||||
StreamBuffer& set(const void* s, size_t size)
|
||||
{clear(); return append(s, size);}
|
||||
|
||||
StreamBuffer& set(const char* s)
|
||||
@ -155,61 +161,61 @@ public:
|
||||
|
||||
// replace: delete part of buffer (pos/length) and insert new data
|
||||
StreamBuffer& replace(
|
||||
long pos, long length, const void* s, long size);
|
||||
ssize_t pos, ssize_t length, const void* s, ssize_t size);
|
||||
|
||||
StreamBuffer& replace(long pos, long length, const char* s)
|
||||
StreamBuffer& replace(ssize_t pos, ssize_t length, const char* s)
|
||||
{return replace(pos, length, s, s?strlen(s):0);}
|
||||
|
||||
StreamBuffer& replace(long pos, long length, const StreamBuffer& s)
|
||||
StreamBuffer& replace(ssize_t pos, ssize_t length, const StreamBuffer& s)
|
||||
{return replace(pos, length, s.buffer+s.offs, s.len);}
|
||||
|
||||
// remove: delete from start/pos
|
||||
StreamBuffer& remove(long pos, long length)
|
||||
StreamBuffer& remove(ssize_t pos, ssize_t length)
|
||||
{return replace(pos, length, NULL, 0);}
|
||||
|
||||
// remove from start: no memset, no function call, fast!
|
||||
StreamBuffer& remove(long length)
|
||||
StreamBuffer& remove(size_t length)
|
||||
{if (length>len) length=len;
|
||||
offs+=length; len-=length; return *this;}
|
||||
|
||||
// truncate: delete end of buffer
|
||||
StreamBuffer& truncate(long pos)
|
||||
StreamBuffer& truncate(ssize_t pos)
|
||||
{return replace(pos, len, NULL, 0);}
|
||||
|
||||
// insert: insert new data into buffer
|
||||
StreamBuffer& insert(long pos, const void* s, long size)
|
||||
StreamBuffer& insert(ssize_t pos, const void* s, ssize_t size)
|
||||
{return replace(pos, 0, s, size);}
|
||||
|
||||
StreamBuffer& insert(long pos, const char* s)
|
||||
StreamBuffer& insert(ssize_t pos, const char* s)
|
||||
{return replace(pos, 0, s, s?strlen(s):0);}
|
||||
|
||||
StreamBuffer& insert(long pos, const StreamBuffer& s)
|
||||
StreamBuffer& insert(ssize_t pos, const StreamBuffer& s)
|
||||
{return replace(pos, 0, s.buffer+s.offs, s.len);}
|
||||
|
||||
StreamBuffer& insert(long pos, char c)
|
||||
StreamBuffer& insert(ssize_t pos, char c)
|
||||
{return replace(pos, 0, &c, 1);}
|
||||
|
||||
StreamBuffer& printf(const char* fmt, ...)
|
||||
StreamBuffer& print(const char* fmt, ...)
|
||||
__attribute__ ((format(printf,2,3)));
|
||||
|
||||
// find: get index of data in buffer or -1
|
||||
long find(char c, long start=0) const
|
||||
ssize_t find(char c, ssize_t start=0) const
|
||||
{char* p;
|
||||
return (p = static_cast<char*>(
|
||||
memchr(buffer+offs+(start<0?start+len:start),
|
||||
c, start<0?-start:len-start)))?
|
||||
p-(buffer+offs) : -1;}
|
||||
|
||||
long find(const void* s, long size, long start=0) const;
|
||||
ssize_t find(const void* s, size_t size, ssize_t start=0) const;
|
||||
|
||||
long find(const char* s, long start=0) const
|
||||
ssize_t find(const char* s, ssize_t start=0) const
|
||||
{return find(s, s?strlen(s):0, start);}
|
||||
|
||||
long int find(const StreamBuffer& s, long start=0) const
|
||||
ssize_t find(const StreamBuffer& s, ssize_t start=0) const
|
||||
{return find(s.buffer+s.offs, s.len, start);}
|
||||
|
||||
// startswith: returns true if first size bytes are equal
|
||||
bool startswith(const void* s, long size) const
|
||||
bool startswith(const void* s, size_t size) const
|
||||
{return len>=size ? memcmp(buffer+offs, s, size) == 0 : false;}
|
||||
|
||||
// startswith: returns true if first string is equal (empty string matches)
|
||||
@ -218,9 +224,9 @@ public:
|
||||
|
||||
// expand: create copy of StreamBuffer where all nonprintable characters
|
||||
// are replaced by <xx> with xx being the hex code of the characters
|
||||
StreamBuffer expand(long start, long length) const;
|
||||
StreamBuffer expand(ssize_t start, ssize_t length) const;
|
||||
|
||||
StreamBuffer expand(long start=0) const
|
||||
StreamBuffer expand(ssize_t start=0) const
|
||||
{return expand(start, len);}
|
||||
|
||||
// dump: debug function, like expand but also show the 'hidden' memory
|
||||
@ -228,4 +234,13 @@ public:
|
||||
StreamBuffer dump() const;
|
||||
};
|
||||
|
||||
// printf size prefix for size_t and ssize_t
|
||||
#if defined (__GNUC__) && __GNUC__ >= 3
|
||||
#define PRINTF_SIZE_T_PREFIX "z"
|
||||
#elif defined (_WIN32)
|
||||
#define PRINTF_SIZE_T_PREFIX "I"
|
||||
#else
|
||||
#define PRINTF_SIZE_T_PREFIX ""
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -18,14 +18,9 @@
|
||||
***************************************************************/
|
||||
|
||||
#include "StreamBusInterface.h"
|
||||
#include "StreamError.h"
|
||||
|
||||
const char* StreamIoStatusStr[] = {
|
||||
"StreamIoSuccess",
|
||||
"StreamIoTimeout",
|
||||
"StreamIoNoReply",
|
||||
"StreamIoEnd",
|
||||
"StreamIoFault"
|
||||
};
|
||||
StreamIoStatusStrClass StreamIoStatusStr;
|
||||
|
||||
StreamBusInterfaceRegistrarBase* StreamBusInterfaceRegistrarBase::first;
|
||||
|
||||
@ -64,11 +59,17 @@ supportsAsyncRead()
|
||||
StreamBusInterface* StreamBusInterface::
|
||||
find(Client* client, const char* busname, int addr, const char* param)
|
||||
{
|
||||
debug("StreamBusInterface::find(%s, %s, %d, \"%s\")\n",
|
||||
client->name(), busname, addr, param);
|
||||
StreamBusInterfaceRegistrarBase* r;
|
||||
StreamBusInterface* bus;
|
||||
for (r = r->first; r; r = r->next)
|
||||
for (r = StreamBusInterfaceRegistrarBase::first; r; r = r->next)
|
||||
{
|
||||
debug("StreamBusInterface::find %s check %s\n",
|
||||
client->name(), r->name);
|
||||
bus = r->find(client, busname, addr, param);
|
||||
debug("StreamBusInterface::find %s %s\n",
|
||||
r->name, bus ? "matches" : "does not match");
|
||||
if (bus) return bus;
|
||||
}
|
||||
return NULL;
|
||||
|
@ -21,13 +21,26 @@
|
||||
#define StreamBusInterface_h
|
||||
|
||||
#include <stddef.h>
|
||||
#include <StreamBuffer.h>
|
||||
|
||||
enum StreamIoStatus {
|
||||
StreamIoSuccess, StreamIoTimeout, StreamIoNoReply,
|
||||
StreamIoEnd, StreamIoFault
|
||||
};
|
||||
|
||||
extern const char* StreamIoStatusStr[];
|
||||
class StreamIoStatusStrClass {
|
||||
public:
|
||||
const char* operator [] (int index) {
|
||||
switch (index) {
|
||||
case StreamIoSuccess: return "StreamIoSuccess";
|
||||
case StreamIoTimeout: return "StreamIoTimeout";
|
||||
case StreamIoNoReply: return "StreamIoNoReply";
|
||||
case StreamIoEnd: return "StreamIoEnd";
|
||||
case StreamIoFault: return "StreamIoFault";
|
||||
default: return "illegal status";
|
||||
}
|
||||
}
|
||||
} extern StreamIoStatusStr;
|
||||
|
||||
class StreamBusInterface
|
||||
{
|
||||
@ -44,50 +57,53 @@ public:
|
||||
virtual void connectCallback(StreamIoStatus status);
|
||||
virtual void disconnectCallback(StreamIoStatus status);
|
||||
virtual long priority();
|
||||
virtual const char* name() = 0;
|
||||
virtual const char* getInTerminator(size_t& length) = 0;
|
||||
virtual const char* getOutTerminator(size_t& length) = 0;
|
||||
public:
|
||||
virtual const char* name() = 0;
|
||||
virtual ~Client();
|
||||
protected:
|
||||
StreamBusInterface* businterface;
|
||||
bool busSupportsEvent() {
|
||||
return businterface->supportsEvent();
|
||||
return businterface && businterface->supportsEvent();
|
||||
}
|
||||
bool busSupportsAsyncRead() {
|
||||
return businterface->supportsAsyncRead();
|
||||
return businterface && businterface->supportsAsyncRead();
|
||||
}
|
||||
bool busAcceptEvent(unsigned long mask,
|
||||
unsigned long replytimeout_ms) {
|
||||
return businterface->acceptEvent(mask, replytimeout_ms);
|
||||
return businterface && businterface->acceptEvent(mask, replytimeout_ms);
|
||||
}
|
||||
void busRelease() {
|
||||
businterface->release();
|
||||
if (businterface) businterface->release();
|
||||
}
|
||||
bool busLockRequest(unsigned long timeout_ms) {
|
||||
return businterface->lockRequest(timeout_ms);
|
||||
return businterface && businterface->lockRequest(timeout_ms);
|
||||
}
|
||||
bool busUnlock() {
|
||||
return businterface->unlock();
|
||||
return businterface && businterface->unlock();
|
||||
}
|
||||
bool busWriteRequest(const void* output, size_t size,
|
||||
unsigned long timeout_ms) {
|
||||
return businterface->writeRequest(output, size, timeout_ms);
|
||||
return businterface && businterface->writeRequest(output, size, timeout_ms);
|
||||
}
|
||||
bool busReadRequest(unsigned long replytimeout_ms,
|
||||
unsigned long readtimeout_ms, long expectedLength,
|
||||
bool async) {
|
||||
return businterface->readRequest(replytimeout_ms,
|
||||
readtimeout_ms, expectedLength, async);
|
||||
return businterface && businterface->readRequest(replytimeout_ms,
|
||||
readtimeout_ms, expectedLength, async);
|
||||
}
|
||||
void busFinish() {
|
||||
businterface->finish();
|
||||
if (businterface) businterface->finish();
|
||||
}
|
||||
bool busConnectRequest(unsigned long timeout_ms) {
|
||||
return businterface->connectRequest(timeout_ms);
|
||||
return businterface && businterface->connectRequest(timeout_ms);
|
||||
}
|
||||
bool busDisconnect() {
|
||||
return businterface->disconnectRequest();
|
||||
return businterface && businterface->disconnectRequest();
|
||||
}
|
||||
void busPrintStatus(StreamBuffer& buffer) {
|
||||
if (businterface) businterface->printStatus(buffer);
|
||||
}
|
||||
};
|
||||
|
||||
@ -137,6 +153,7 @@ protected:
|
||||
virtual bool connectRequest(unsigned long connecttimeout_ms);
|
||||
virtual bool disconnectRequest();
|
||||
virtual void finish();
|
||||
virtual void printStatus(StreamBuffer& buffer) {};
|
||||
|
||||
// pure virtual
|
||||
virtual bool lockRequest(unsigned long timeout_ms) = 0;
|
||||
|
@ -23,6 +23,8 @@
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define P PRINTF_SIZE_T_PREFIX
|
||||
|
||||
enum Commands { end_cmd, in_cmd, out_cmd, wait_cmd, event_cmd, exec_cmd,
|
||||
connect_cmd, disconnect_cmd };
|
||||
const char* commandStr[] = { "end", "in", "out", "wait", "event", "exec",
|
||||
@ -57,12 +59,12 @@ static char* printCommands(StreamBuffer& buffer, const char* c)
|
||||
break;
|
||||
case wait_cmd:
|
||||
timeout = extract<unsigned long>(c);
|
||||
buffer.printf(" wait %ld;\n # ms", timeout);
|
||||
buffer.print(" wait %ld; # ms\n", timeout);
|
||||
break;
|
||||
case event_cmd:
|
||||
eventnumber = extract<unsigned long>(c);
|
||||
timeout = extract<unsigned long>(c);
|
||||
buffer.printf(" event(%ld) %ld; # ms\n", eventnumber, timeout);
|
||||
buffer.print(" event(%ld) %ld; # ms\n", eventnumber, timeout);
|
||||
break;
|
||||
case exec_cmd:
|
||||
buffer.append(" exec \"");
|
||||
@ -71,7 +73,7 @@ static char* printCommands(StreamBuffer& buffer, const char* c)
|
||||
break;
|
||||
case connect_cmd:
|
||||
timeout = extract<unsigned long>(c);
|
||||
buffer.printf(" connect %ld; # ms\n", timeout);
|
||||
buffer.print(" connect %ld; # ms\n", timeout);
|
||||
break;
|
||||
case disconnect_cmd:
|
||||
buffer.append(" disconnect;\n");
|
||||
@ -118,7 +120,6 @@ printProtocol()
|
||||
if (onMismatch)
|
||||
printf(" @Mismatch {\n%s }\n",
|
||||
printCommands(buffer.clear(), onMismatch()));
|
||||
debug("StreamCore::printProtocol: commands=%s\n", commands.expand()());
|
||||
printf("\n%s}\n",
|
||||
printCommands(buffer.clear(), commands()));
|
||||
}
|
||||
@ -164,7 +165,7 @@ attachBus(const char* busname, int addr, const char* param)
|
||||
businterface = StreamBusInterface::find(this, busname, addr, param);
|
||||
if (!businterface)
|
||||
{
|
||||
error("Businterface '%s' not found for '%s'\n",
|
||||
error("Cannot find a bus named '%s' for '%s'\n",
|
||||
busname, name());
|
||||
return false;
|
||||
}
|
||||
@ -342,6 +343,7 @@ compileCommand(StreamProtocolParser::Protocol* protocol,
|
||||
return false;
|
||||
}
|
||||
args++;
|
||||
while (isspace(*args)) args++;
|
||||
}
|
||||
buffer.append(&eventmask, sizeof(eventmask));
|
||||
if (*args)
|
||||
@ -458,7 +460,7 @@ finishProtocol(ProtocolResult status)
|
||||
status = Fault;
|
||||
}
|
||||
//// flags &= ~(AcceptInput|AcceptEvent);
|
||||
if (runningHandler)
|
||||
if (runningHandler || flags & InitRun)
|
||||
{
|
||||
// get original error status
|
||||
if (status == Success) status = runningHandler;
|
||||
@ -747,7 +749,7 @@ printSeparator()
|
||||
bool StreamCore::
|
||||
printValue(const StreamFormat& fmt, long value)
|
||||
{
|
||||
if (fmt.type != long_format && fmt.type != enum_format)
|
||||
if (fmt.type != unsigned_format && fmt.type != signed_format && fmt.type != enum_format)
|
||||
{
|
||||
error("%s: printValue(long) called with %%%c format\n",
|
||||
name(), fmt.conv);
|
||||
@ -761,8 +763,8 @@ printValue(const StreamFormat& fmt, long value)
|
||||
name(), value);
|
||||
return false;
|
||||
}
|
||||
debug("StreamCore::printValue(%s, long): \"%s\"\n",
|
||||
name(), outputLine.expand()());
|
||||
debug("StreamCore::printValue %s %%%c long %ld (%lx): \"%s\"\n",
|
||||
name(), fmt.conv, value, value, outputLine.expand()());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -783,8 +785,8 @@ printValue(const StreamFormat& fmt, double value)
|
||||
name(), value);
|
||||
return false;
|
||||
}
|
||||
debug("StreamCore::printValue(%s, double): \"%s\"\n",
|
||||
name(), outputLine.expand()());
|
||||
debug("StreamCore::printValue %s %%%c double %#g: \"%s\"\n",
|
||||
name(), fmt.conv, value, outputLine.expand()());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -806,8 +808,8 @@ printValue(const StreamFormat& fmt, char* value)
|
||||
name(), buffer.expand()());
|
||||
return false;
|
||||
}
|
||||
debug("StreamCore::printValue(%s, char*): \"%s\"\n",
|
||||
name(), outputLine.expand()());
|
||||
debug("StreamCore::printValue %s %%%c char* \"%s\"): \"%s\"\n",
|
||||
name(), fmt.conv, value, outputLine.expand()());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -816,7 +818,7 @@ lockCallback(StreamIoStatus status)
|
||||
{
|
||||
MutexLock lock(this);
|
||||
debug("StreamCore::lockCallback(%s, status=%s)\n",
|
||||
name(), status ? "Timeout" : "Success");
|
||||
name(), StreamIoStatusStr[status]);
|
||||
if (!(flags & LockPending))
|
||||
{
|
||||
error("StreamCore::lockCallback(%s) called unexpectedly\n",
|
||||
@ -830,9 +832,21 @@ lockCallback(StreamIoStatus status)
|
||||
case StreamIoSuccess:
|
||||
break;
|
||||
case StreamIoTimeout:
|
||||
debug("%s: Cannot lock device within %ld ms, device seems to be busy\n",
|
||||
name(), lockTimeout);
|
||||
flags &= ~BusOwner;
|
||||
finishProtocol(LockTimeout);
|
||||
return;
|
||||
case StreamIoFault:
|
||||
error("%s: Locking failed because of a device fault\n",
|
||||
name());
|
||||
flags &= ~BusOwner;
|
||||
finishProtocol(LockTimeout);
|
||||
return;
|
||||
default:
|
||||
error("StreamCore::lockCallback(%s) unexpected status %s\n",
|
||||
name(), StreamIoStatusStr[status]);
|
||||
flags &= ~BusOwner;
|
||||
finishProtocol(Fault);
|
||||
return;
|
||||
}
|
||||
@ -977,13 +991,13 @@ readCallback(StreamIoStatus status,
|
||||
evalIn();
|
||||
return 0;
|
||||
}
|
||||
error("%s: No reply from device within %ld ms\n",
|
||||
debug("StreamCore::readCallback(%s): No reply from device within %ld ms\n",
|
||||
name(), replyTimeout);
|
||||
inputBuffer.clear();
|
||||
finishProtocol(ReplyTimeout);
|
||||
return 0;
|
||||
case StreamIoFault:
|
||||
error("%s: I/O error after reading %ld byte%s: \"%s%s\"\n",
|
||||
error("%s: I/O error after reading %" P "d byte%s: \"%s%s\"\n",
|
||||
name(),
|
||||
inputBuffer.length(), inputBuffer.length()==1 ? "" : "s",
|
||||
inputBuffer.length() > 20 ? "..." : "",
|
||||
@ -992,7 +1006,7 @@ readCallback(StreamIoStatus status,
|
||||
return 0;
|
||||
}
|
||||
inputBuffer.append(input, size);
|
||||
debug("StreamCore::readCallback(%s) inputBuffer=\"%s\", size %ld\n",
|
||||
debug("StreamCore::readCallback(%s) inputBuffer=\"%s\", size %" P "d\n",
|
||||
name(), inputBuffer.expand()(), inputBuffer.length());
|
||||
if (*activeCommand != in_cmd)
|
||||
{
|
||||
@ -1159,8 +1173,7 @@ matchInput()
|
||||
*/
|
||||
char command;
|
||||
const char* fieldName = NULL;
|
||||
const char* formatstring;
|
||||
int formatstringlen;
|
||||
StreamBuffer formatstring;
|
||||
|
||||
consumedInput = 0;
|
||||
|
||||
@ -1186,22 +1199,15 @@ normal_format:
|
||||
int consumed;
|
||||
// code layout:
|
||||
// formatstring <eos> StreamFormat [info]
|
||||
formatstring = commandIndex;
|
||||
// jump after <eos>
|
||||
while (*commandIndex)
|
||||
{
|
||||
if (*commandIndex == esc) commandIndex++;
|
||||
commandIndex++;
|
||||
}
|
||||
formatstringlen = commandIndex-formatstring;
|
||||
commandIndex++;
|
||||
formatstring.clear();
|
||||
commandIndex = StreamProtocolParser::printString(formatstring, commandIndex);
|
||||
|
||||
StreamFormat fmt = extract<StreamFormat>(commandIndex);
|
||||
fmt.info = commandIndex; // point to info string
|
||||
commandIndex += fmt.infolen;
|
||||
#ifndef NO_TEMPORARY
|
||||
debug("StreamCore::matchInput(%s): format = %%%s\n",
|
||||
name(), StreamBuffer(formatstring, formatstringlen).expand()());
|
||||
debug("StreamCore::matchInput(%s): format = \"%%%s\"\n",
|
||||
name(), formatstring());
|
||||
#endif
|
||||
|
||||
if (fmt.flags & skip_flag || fmt.type == pseudo_format)
|
||||
@ -1210,7 +1216,8 @@ normal_format:
|
||||
double ddummy;
|
||||
switch (fmt.type)
|
||||
{
|
||||
case long_format:
|
||||
case unsigned_format:
|
||||
case signed_format:
|
||||
case enum_format:
|
||||
consumed = StreamFormatConverter::find(fmt.conv)->
|
||||
scanLong(fmt, inputLine(consumedInput), ldummy);
|
||||
@ -1243,10 +1250,10 @@ normal_format:
|
||||
{
|
||||
if (!(flags & AsyncMode) && onMismatch[0] != in_cmd)
|
||||
{
|
||||
error("%s: Input \"%s%s\" does not match format %%%s\n",
|
||||
error("%s: Input \"%s%s\" does not match format \"%%%s\"\n",
|
||||
name(), inputLine.expand(consumedInput, 20)(),
|
||||
inputLine.length()-consumedInput > 20 ? "..." : "",
|
||||
formatstring);
|
||||
formatstring());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -1260,13 +1267,12 @@ normal_format:
|
||||
flags &= ~Separator;
|
||||
if (!formatValue(fmt, fieldAddress ? fieldAddress() : NULL))
|
||||
{
|
||||
StreamBuffer formatstr(formatstring, formatstringlen);
|
||||
if (fieldAddress)
|
||||
error("%s: Cannot format field '%s' with '%%%s'\n",
|
||||
name(), fieldName, formatstr.expand()());
|
||||
error("%s: Cannot format variable \"%s\" with \"%%%s\"\n",
|
||||
name(), fieldName, formatstring());
|
||||
else
|
||||
error("%s: Cannot format value with '%%%s'\n",
|
||||
name(), formatstr.expand()());
|
||||
error("%s: Cannot format value with \"%%%s\"\n",
|
||||
name(), formatstring());
|
||||
return false;
|
||||
}
|
||||
#ifndef NO_TEMPORARY
|
||||
@ -1279,11 +1285,11 @@ normal_format:
|
||||
if (!(flags & AsyncMode) && onMismatch[0] != in_cmd)
|
||||
{
|
||||
error("%s: Input \"%s%s\" too short."
|
||||
" No match for format %%%s (\"%s\")\n",
|
||||
" No match for format \"%%%s\" (\"%s\")\n",
|
||||
name(),
|
||||
inputLine.length() > 20 ? "..." : "",
|
||||
inputLine.expand(-20)(),
|
||||
formatstring,
|
||||
formatstring(),
|
||||
outputLine.expand()());
|
||||
}
|
||||
return false;
|
||||
@ -1292,11 +1298,10 @@ normal_format:
|
||||
{
|
||||
if (!(flags & AsyncMode) && onMismatch[0] != in_cmd)
|
||||
{
|
||||
error("%s: Input \"%s%s\" does not match"
|
||||
" format %%%s (\"%s\")\n",
|
||||
error("%s: Input \"%s%s\" does not match format \"%%%s\" (\"%s\")\n",
|
||||
name(), inputLine.expand(consumedInput, 20)(),
|
||||
inputLine.length()-consumedInput > 20 ? "..." : "",
|
||||
formatstring,
|
||||
formatstring(),
|
||||
outputLine.expand()());
|
||||
}
|
||||
return false;
|
||||
@ -1310,13 +1315,13 @@ normal_format:
|
||||
if (!(flags & AsyncMode) && onMismatch[0] != in_cmd)
|
||||
{
|
||||
if (flags & ScanTried)
|
||||
error("%s: Input \"%s%s\" does not match format %%%s\n",
|
||||
error("%s: Input \"%s%s\" does not match format \"%%%s\"\n",
|
||||
name(), inputLine.expand(consumedInput, 20)(),
|
||||
inputLine.length()-consumedInput > 20 ? "..." : "",
|
||||
formatstring);
|
||||
formatstring());
|
||||
else
|
||||
error("%s: Format %%%s has data type %s which does not match this variable.\n",
|
||||
name(), formatstring, StreamFormatTypeStr[fmt.type] );
|
||||
error("%s: Format \"%%%s\" has data type %s which does not match the type of \"%s\".\n",
|
||||
name(), formatstring(), StreamFormatTypeStr[fmt.type], fieldAddress ? fieldName : name());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -1453,7 +1458,7 @@ matchSeparator()
|
||||
long StreamCore::
|
||||
scanValue(const StreamFormat& fmt, long& value)
|
||||
{
|
||||
if (fmt.type != long_format && fmt.type != enum_format)
|
||||
if (fmt.type != unsigned_format && fmt.type != signed_format && fmt.type != enum_format)
|
||||
{
|
||||
error("%s: scanValue(long&) called with %%%c format\n",
|
||||
name(), fmt.conv);
|
||||
@ -1474,6 +1479,7 @@ scanValue(const StreamFormat& fmt, long& value)
|
||||
}
|
||||
else return -1;
|
||||
}
|
||||
if (fmt.flags & fix_width_flag && consumed != fmt.width) return -1;
|
||||
if (consumed > inputLine.length()-consumedInput) return -1;
|
||||
debug("StreamCore::scanValue(%s) scanned %li\n",
|
||||
name(), value);
|
||||
@ -1505,6 +1511,7 @@ scanValue(const StreamFormat& fmt, double& value)
|
||||
}
|
||||
else return -1;
|
||||
}
|
||||
if (fmt.flags & fix_width_flag && (consumed != (fmt.width + fmt.prec + 1))) return -1;
|
||||
if (consumed > inputLine.length()-consumedInput) return -1;
|
||||
debug("StreamCore::scanValue(%s) scanned %#g\n",
|
||||
name(), value);
|
||||
@ -1537,6 +1544,7 @@ scanValue(const StreamFormat& fmt, char* value, long maxlen)
|
||||
}
|
||||
else return -1;
|
||||
}
|
||||
if (fmt.flags & fix_width_flag && consumed != fmt.width) return -1;
|
||||
if (consumed > inputLine.length()-consumedInput) return -1;
|
||||
#ifndef NO_TEMPORARY
|
||||
debug("StreamCore::scanValue(%s) scanned \"%s\"\n",
|
||||
@ -1649,7 +1657,11 @@ timerCallback()
|
||||
bool StreamCore::
|
||||
evalExec()
|
||||
{
|
||||
formatOutput();
|
||||
if (!formatOutput())
|
||||
{
|
||||
finishProtocol(FormatError);
|
||||
return false;
|
||||
}
|
||||
debug ("StreamCore::evalExec: command = \"%s\"\n", outputLine.expand()());
|
||||
// release bus
|
||||
if (flags & BusOwner)
|
||||
@ -1746,4 +1758,25 @@ disconnectCallback(StreamIoStatus status)
|
||||
}
|
||||
}
|
||||
|
||||
void StreamCore::
|
||||
printStatus(StreamBuffer& buffer)
|
||||
{
|
||||
buffer.print("active command=%s ",
|
||||
activeCommand ? commandName(*activeCommand) : "NULL");
|
||||
buffer.print("flags=0x%04lx ", flags);
|
||||
if (flags & IgnoreExtraInput) buffer.append("IgnoreExtraInput ");
|
||||
if (flags & InitRun) buffer.append("InitRun ");
|
||||
if (flags & AsyncMode) buffer.append("AsyncMode ");
|
||||
if (flags & GotValue) buffer.append("GotValue ");
|
||||
if (flags & BusOwner) buffer.append("BusOwner ");
|
||||
if (flags & Separator) buffer.append("Separator ");
|
||||
if (flags & ScanTried) buffer.append("ScanTried ");
|
||||
if (flags & AcceptInput) buffer.append("AcceptInput ");
|
||||
if (flags & AcceptEvent) buffer.append("AcceptEvent ");
|
||||
if (flags & LockPending) buffer.append("LockPending ");
|
||||
if (flags & WritePending) buffer.append("WritePending ");
|
||||
if (flags & WaitPending) buffer.append("WaitPending ");
|
||||
busPrintStatus(buffer);
|
||||
}
|
||||
|
||||
#include "streamReferences"
|
||||
|
@ -219,6 +219,7 @@ public:
|
||||
bool parse(const char* filename, const char* protocolname);
|
||||
void printProtocol();
|
||||
const char* name() { return streamname; }
|
||||
void printStatus(StreamBuffer& buffer);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -18,14 +18,24 @@
|
||||
* *
|
||||
***************************************************************/
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include "devStream.h"
|
||||
#undef epicsExportSharedSymbols
|
||||
#include "StreamCore.h"
|
||||
#include "StreamError.h"
|
||||
#include "devStream.h"
|
||||
|
||||
#ifndef EPICS_3_14
|
||||
#include <epicsVersion.h>
|
||||
#ifdef BASE_VERSION
|
||||
#define EPICS_3_13
|
||||
#endif
|
||||
|
||||
#ifdef EPICS_3_13
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define epicsAlarmGLOBAL
|
||||
#include <alarm.h>
|
||||
#undef epicsAlarmGLOBAL
|
||||
#include <ctype.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
@ -34,10 +44,9 @@ extern "C" {
|
||||
#include <recSup.h>
|
||||
#include <recGbl.h>
|
||||
#include <devLib.h>
|
||||
#include <alarm.h>
|
||||
#include <callback.h>
|
||||
|
||||
#ifndef EPICS_3_14
|
||||
#ifdef EPICS_3_13
|
||||
|
||||
#include <semLib.h>
|
||||
#include <wdLib.h>
|
||||
@ -87,26 +96,25 @@ extern "C" void streamRecordProcessCallback(CALLBACK *pcallback);
|
||||
extern "C" long streamReload(char* recordname);
|
||||
|
||||
class Stream : protected StreamCore
|
||||
#ifdef EPICS_3_14
|
||||
#ifndef EPICS_3_13
|
||||
, epicsTimerNotify
|
||||
#endif
|
||||
{
|
||||
dbCommon* record;
|
||||
struct link *ioLink;
|
||||
const struct link *ioLink;
|
||||
streamIoFunction readData;
|
||||
streamIoFunction writeData;
|
||||
#ifdef EPICS_3_14
|
||||
epicsTimerQueueActive* timerQueue;
|
||||
epicsTimer* timer;
|
||||
epicsMutex mutex;
|
||||
epicsEvent initDone;
|
||||
#else
|
||||
#ifdef EPICS_3_13
|
||||
WDOG_ID timer;
|
||||
CALLBACK timeoutCallback;
|
||||
SEM_ID mutex;
|
||||
SEM_ID initDone;
|
||||
#else
|
||||
epicsTimerQueueActive* timerQueue;
|
||||
epicsTimer* timer;
|
||||
epicsMutex mutex;
|
||||
epicsEvent initDone;
|
||||
#endif
|
||||
StreamBuffer fieldBuffer;
|
||||
int status;
|
||||
int convert;
|
||||
long currentValueLength;
|
||||
@ -115,11 +123,11 @@ class Stream : protected StreamCore
|
||||
CALLBACK processCallback;
|
||||
|
||||
|
||||
#ifdef EPICS_3_14
|
||||
#ifdef EPICS_3_13
|
||||
static void expire(CALLBACK *pcallback);
|
||||
#else
|
||||
// epicsTimerNotify method
|
||||
expireStatus expire(const epicsTime&);
|
||||
#else
|
||||
static void expire(CALLBACK *pcallback);
|
||||
#endif
|
||||
|
||||
// StreamCore methods
|
||||
@ -139,16 +147,19 @@ class Stream : protected StreamCore
|
||||
friend void streamRecordProcessCallback(CALLBACK *pcallback);
|
||||
|
||||
// Stream Epics methods
|
||||
long initRecord();
|
||||
Stream(dbCommon* record, struct link *ioLink,
|
||||
Stream(dbCommon* record, const struct link *ioLink,
|
||||
streamIoFunction readData, streamIoFunction writeData);
|
||||
~Stream();
|
||||
long parseLink(const struct link *ioLink, char* filename, char* protocol,
|
||||
char* busname, int* addr, char* busparam);
|
||||
long initRecord(const char* filename, const char* protocol,
|
||||
const char* busname, int addr, const char* busparam);
|
||||
bool print(format_t *format, va_list ap);
|
||||
bool scan(format_t *format, void* pvalue, size_t maxStringSize);
|
||||
bool process();
|
||||
|
||||
// device support functions
|
||||
friend long streamInitRecord(dbCommon *record, struct link *ioLink,
|
||||
friend long streamInitRecord(dbCommon *record, const struct link *ioLink,
|
||||
streamIoFunction readData, streamIoFunction writeData);
|
||||
friend long streamReadWrite(dbCommon *record);
|
||||
friend long streamGetIointInfo(int cmd, dbCommon *record,
|
||||
@ -166,9 +177,10 @@ public:
|
||||
|
||||
|
||||
// shell functions ///////////////////////////////////////////////////////
|
||||
#ifdef EPICS_3_14
|
||||
#ifndef EPICS_3_13
|
||||
extern "C" {
|
||||
epicsExportAddress(int, streamDebug);
|
||||
epicsExportAddress(int, streamError);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -225,7 +237,7 @@ extern "C" long streamReload(char* recordname)
|
||||
return OK;
|
||||
}
|
||||
|
||||
#ifdef EPICS_3_14
|
||||
#ifndef EPICS_3_13
|
||||
static const iocshArg streamReloadArg0 =
|
||||
{ "recordname", iocshArgString };
|
||||
static const iocshArg * const streamReloadArgs[] =
|
||||
@ -251,33 +263,27 @@ static void streamRegistrar ()
|
||||
extern "C" {
|
||||
epicsExportRegistrar(streamRegistrar);
|
||||
}
|
||||
#endif // EPICS_3_14
|
||||
#endif
|
||||
|
||||
// driver support ////////////////////////////////////////////////////////
|
||||
|
||||
struct stream_drvsup {
|
||||
long number;
|
||||
long (*report)(int);
|
||||
DRVSUPFUN init;
|
||||
long (*init)();
|
||||
} stream = {
|
||||
2,
|
||||
Stream::report,
|
||||
Stream::drvInit
|
||||
};
|
||||
|
||||
#ifdef EPICS_3_14
|
||||
#ifndef EPICS_3_13
|
||||
extern "C" {
|
||||
epicsExportAddress(drvet, stream);
|
||||
}
|
||||
#endif
|
||||
|
||||
void streamEpicsPrintTimestamp(char* buffer, int size)
|
||||
{
|
||||
int tlen;
|
||||
epicsTime tm = epicsTime::getCurrent();
|
||||
tlen = tm.strftime(buffer, size, "%Y/%m/%d %H:%M:%S.%03f");
|
||||
sprintf(buffer+tlen, " %.*s", size-tlen-2, epicsThreadGetNameSelf());
|
||||
}
|
||||
#else
|
||||
#ifdef EPICS_3_13
|
||||
void streamEpicsPrintTimestamp(char* buffer, int size)
|
||||
{
|
||||
int tlen;
|
||||
@ -292,6 +298,14 @@ void streamEpicsPrintTimestamp(char* buffer, int size)
|
||||
tlen = strlen(buffer);
|
||||
sprintf(buffer+tlen, " %.*s", size-tlen-2, taskName(0));
|
||||
}
|
||||
#else
|
||||
void streamEpicsPrintTimestamp(char* buffer, int size)
|
||||
{
|
||||
int tlen;
|
||||
epicsTime tm = epicsTime::getCurrent();
|
||||
tlen = tm.strftime(buffer, size, "%Y/%m/%d %H:%M:%S.%06f");
|
||||
sprintf(buffer+tlen, " %.*s", size-tlen-2, epicsThreadGetNameSelf());
|
||||
}
|
||||
#endif
|
||||
|
||||
long Stream::
|
||||
@ -336,6 +350,12 @@ report(int interest)
|
||||
{
|
||||
printf(" %s: %s\n", pstream->name(),
|
||||
pstream->ioLink->value.instio.string);
|
||||
if (interest == 3)
|
||||
{
|
||||
StreamBuffer buffer;
|
||||
pstream->printStatus(buffer);
|
||||
printf(" %s\n", buffer());
|
||||
}
|
||||
}
|
||||
}
|
||||
return OK;
|
||||
@ -393,30 +413,52 @@ long streamInit(int after)
|
||||
return OK;
|
||||
}
|
||||
|
||||
long streamInitRecord(dbCommon* record, struct link *ioLink,
|
||||
long streamInitRecord(dbCommon* record, const struct link *ioLink,
|
||||
streamIoFunction readData, streamIoFunction writeData)
|
||||
{
|
||||
long status;
|
||||
char filename[80];
|
||||
char protocol[80];
|
||||
char busname[80];
|
||||
int addr = -1;
|
||||
char busparam[80];
|
||||
memset(busparam, 0 ,sizeof(busparam));
|
||||
|
||||
debug("streamInitRecord(%s): SEVR=%d\n", record->name, record->sevr);
|
||||
Stream* pstream = (Stream*)record->dpvt;
|
||||
if (!pstream)
|
||||
{
|
||||
// initialize the first time
|
||||
debug("streamInitRecord(%s): create new Stream object\n",
|
||||
record->name);
|
||||
pstream = new Stream(record, ioLink, readData, writeData);
|
||||
record->dpvt = pstream;
|
||||
} else {
|
||||
// stop any running protocol
|
||||
debug("streamInitRecord(%s): stop running protocol\n",
|
||||
record->name);
|
||||
pstream->finishProtocol(Stream::Abort);
|
||||
}
|
||||
// scan the i/o link
|
||||
debug("streamInitRecord(%s): parse link \"%s\"\n",
|
||||
record->name, ioLink->value.instio.string);
|
||||
status = pstream->parseLink(ioLink, filename, protocol,
|
||||
busname, &addr, busparam);
|
||||
// (re)initialize bus and protocol
|
||||
long status = pstream->initRecord();
|
||||
debug("streamInitRecord(%s): calling initRecord\n",
|
||||
record->name);
|
||||
if (status == 0)
|
||||
status = pstream->initRecord(filename, protocol,
|
||||
busname, addr, busparam);
|
||||
if (status != OK && status != DO_NOT_CONVERT)
|
||||
{
|
||||
error("%s: Record initialization failed\n", record->name);
|
||||
}
|
||||
if (!pstream->ioscanpvt)
|
||||
else if (!pstream->ioscanpvt)
|
||||
{
|
||||
scanIoInit(&pstream->ioscanpvt);
|
||||
}
|
||||
debug("streamInitRecord(%s) done status=%#lx\n", record->name, status);
|
||||
return status;
|
||||
}
|
||||
|
||||
@ -436,7 +478,8 @@ long streamGetIointInfo(int cmd, dbCommon *record, IOSCANPVT *ppvt)
|
||||
{
|
||||
Stream* pstream = (Stream*)record->dpvt;
|
||||
debug("streamGetIointInfo(%s,cmd=%d): pstream=%p, ioscanpvt=%p\n",
|
||||
record->name, cmd, (void*)pstream, pstream ? pstream->ioscanpvt : NULL);
|
||||
record->name, cmd,
|
||||
(void*)pstream, pstream ? pstream->ioscanpvt : NULL);
|
||||
if (!pstream)
|
||||
{
|
||||
error("streamGetIointInfo called without stream instance\n");
|
||||
@ -495,20 +538,20 @@ long streamScanfN(dbCommon* record, format_t *format,
|
||||
// Stream methods ////////////////////////////////////////////////////////
|
||||
|
||||
Stream::
|
||||
Stream(dbCommon* _record, struct link *ioLink,
|
||||
Stream(dbCommon* _record, const struct link *ioLink,
|
||||
streamIoFunction readData, streamIoFunction writeData)
|
||||
:record(_record), ioLink(ioLink), readData(readData), writeData(writeData)
|
||||
{
|
||||
streamname = record->name;
|
||||
#ifdef EPICS_3_14
|
||||
timerQueue = &epicsTimerQueueActive::allocate(true);
|
||||
timer = &timerQueue->createTimer();
|
||||
#else
|
||||
#ifdef EPICS_3_13
|
||||
timer = wdCreate();
|
||||
mutex = semMCreate(SEM_INVERSION_SAFE | SEM_Q_PRIORITY);
|
||||
initDone = semBCreate(SEM_Q_FIFO, SEM_EMPTY);
|
||||
callbackSetCallback(expire, &timeoutCallback);
|
||||
callbackSetUser(this, &timeoutCallback);
|
||||
#else
|
||||
timerQueue = &epicsTimerQueueActive::allocate(true);
|
||||
timer = &timerQueue->createTimer();
|
||||
#endif
|
||||
callbackSetCallback(streamExecuteCommand, &commandCallback);
|
||||
callbackSetUser(this, &commandCallback);
|
||||
@ -532,59 +575,61 @@ Stream::
|
||||
record->dpvt = NULL;
|
||||
debug("~Stream(%s): dpvt cleared\n", name());
|
||||
}
|
||||
#ifdef EPICS_3_14
|
||||
#ifdef EPICS_3_13
|
||||
wdDelete(timer);
|
||||
debug("~Stream(%s): watchdog destroyed\n", name());
|
||||
#else
|
||||
timer->destroy();
|
||||
debug("~Stream(%s): timer destroyed\n", name());
|
||||
timerQueue->release();
|
||||
debug("~Stream(%s): timer queue released\n", name());
|
||||
#else
|
||||
wdDelete(timer);
|
||||
debug("~Stream(%s): watchdog destroyed\n", name());
|
||||
#endif
|
||||
releaseMutex();
|
||||
}
|
||||
|
||||
long Stream::
|
||||
initRecord()
|
||||
parseLink(const struct link *ioLink, char* filename,
|
||||
char* protocol, char* busname, int* addr, char* busparam)
|
||||
{
|
||||
// scan link parameters: filename protocol busname addr busparam
|
||||
// It is safe to call this function again with different
|
||||
// link text or different protocol file.
|
||||
|
||||
char filename[80];
|
||||
char protocol[80];
|
||||
char busname[80];
|
||||
int addr = -1;
|
||||
char busparam[80];
|
||||
// parse link parameters: filename protocol busname addr busparam
|
||||
int n;
|
||||
|
||||
if (ioLink->type != INST_IO)
|
||||
{
|
||||
error("%s: Wrong link type %s\n", name(),
|
||||
error("%s: Wrong I/O link type %s\n", name(),
|
||||
pamaplinkType[ioLink->type].strvalue);
|
||||
return S_dev_badInitRet;
|
||||
}
|
||||
int items = sscanf(ioLink->value.instio.string, "%79s%79s%79s%n%i%n",
|
||||
filename, protocol, busname, &n, &addr, &n);
|
||||
int items = sscanf(ioLink->value.instio.string, "%s%s%s%n%i%n",
|
||||
filename, protocol, busname, &n, addr, &n);
|
||||
if (items <= 0)
|
||||
{
|
||||
error("%s: Empty link. Forgot the leading '@' or confused INP with OUT ?\n",
|
||||
error("%s: Empty I/O link. "
|
||||
"Forgot the leading '@' or confused INP with OUT or link is too long ?\n",
|
||||
name());
|
||||
return S_dev_badInitRet;
|
||||
}
|
||||
if (items < 3)
|
||||
{
|
||||
error("%s: Wrong link format\n"
|
||||
error("%s: Wrong I/O link format\n"
|
||||
" expect \"@file protocol bus addr params\"\n"
|
||||
" in \"@%s\"\n", name(),
|
||||
ioLink->value.instio.string);
|
||||
return S_dev_badInitRet;
|
||||
}
|
||||
memset(busparam, 0 ,80);
|
||||
for (n = 0; isspace((unsigned char)ioLink->value.instio.string[n]); n++);
|
||||
strncpy (busparam, ioLink->value.constantStr+n, 79);
|
||||
while (isspace((unsigned char)ioLink->value.instio.string[n])) n++;
|
||||
strcpy (busparam, ioLink->value.constantStr+n);
|
||||
return OK;
|
||||
}
|
||||
|
||||
long Stream::
|
||||
initRecord(const char* filename, const char* protocol,
|
||||
const char* busname, int addr, const char* busparam)
|
||||
{
|
||||
// It is safe to call this function again with different arguments
|
||||
|
||||
// attach to bus interface
|
||||
debug("Stream::initRecord %s: attachBus(%s, %d, \"%s\")\n",
|
||||
name(), busname, addr, busparam);
|
||||
if (!attachBus(busname, addr, busparam))
|
||||
{
|
||||
error("%s: Can't attach to bus %s %d\n",
|
||||
@ -593,6 +638,8 @@ initRecord()
|
||||
}
|
||||
|
||||
// parse protocol file
|
||||
debug("Stream::initRecord %s: parse(%s, %s)\n",
|
||||
name(), filename, protocol);
|
||||
if (!parse(filename, protocol))
|
||||
{
|
||||
error("%s: Protocol parse error\n",
|
||||
@ -610,7 +657,8 @@ initRecord()
|
||||
name());
|
||||
if (record->scan == SCAN_IO_EVENT)
|
||||
{
|
||||
debug("Stream::initRecord %s: restarting \"I/O Intr\" after reload\n",
|
||||
debug("Stream::initRecord %s: "
|
||||
"restarting \"I/O Intr\" after reload\n",
|
||||
name());
|
||||
if (!startProtocol(StartAsync))
|
||||
{
|
||||
@ -635,10 +683,10 @@ initRecord()
|
||||
}
|
||||
debug("Stream::initRecord %s: waiting for initDone\n",
|
||||
name());
|
||||
#ifdef EPICS_3_14
|
||||
initDone.wait();
|
||||
#else
|
||||
#ifdef EPICS_3_13
|
||||
semTake(initDone, WAIT_FOREVER);
|
||||
#else
|
||||
initDone.wait();
|
||||
#endif
|
||||
debug("Stream::initRecord %s: initDone\n",
|
||||
name());
|
||||
@ -664,8 +712,11 @@ process()
|
||||
{
|
||||
if (status != NO_ALARM)
|
||||
{
|
||||
debug("Stream::process(%s) error status=%d\n",
|
||||
name(), status);
|
||||
debug("Stream::process(%s) error status=%s (%d)\n",
|
||||
name(),
|
||||
status >= 0 && status < ALARM_NSTATUS ?
|
||||
epicsAlarmConditionStrings[status] : "ERROR",
|
||||
status);
|
||||
(void) recGblSetSevr(record, status, INVALID_ALARM);
|
||||
return false;
|
||||
}
|
||||
@ -700,21 +751,16 @@ process()
|
||||
bool Stream::
|
||||
print(format_t *format, va_list ap)
|
||||
{
|
||||
long lval;
|
||||
double dval;
|
||||
char* sval;
|
||||
switch (format->type)
|
||||
{
|
||||
case DBF_ENUM:
|
||||
case DBF_ULONG:
|
||||
case DBF_LONG:
|
||||
lval = va_arg(ap, long);
|
||||
return printValue(*format->priv, lval);
|
||||
case DBF_ENUM:
|
||||
return printValue(*format->priv, va_arg(ap, long));
|
||||
case DBF_DOUBLE:
|
||||
dval = va_arg(ap, double);
|
||||
return printValue(*format->priv, dval);
|
||||
return printValue(*format->priv, va_arg(ap, double));
|
||||
case DBF_STRING:
|
||||
sval = va_arg(ap, char*);
|
||||
return printValue(*format->priv, sval);
|
||||
return printValue(*format->priv, va_arg(ap, char*));
|
||||
}
|
||||
error("INTERNAL ERROR (%s): Illegal format type\n", name());
|
||||
return false;
|
||||
@ -724,27 +770,23 @@ bool Stream::
|
||||
scan(format_t *format, void* value, size_t maxStringSize)
|
||||
{
|
||||
// called by streamScanfN
|
||||
long* lptr;
|
||||
double* dptr;
|
||||
char* sptr;
|
||||
|
||||
// first remove old value from inputLine (if we are scanning arrays)
|
||||
consumedInput += currentValueLength;
|
||||
currentValueLength = 0;
|
||||
switch (format->type)
|
||||
{
|
||||
case DBF_ULONG:
|
||||
case DBF_LONG:
|
||||
case DBF_ENUM:
|
||||
lptr = (long*)value;
|
||||
currentValueLength = scanValue(*format->priv, *lptr);
|
||||
currentValueLength = scanValue(*format->priv, *(long*)value);
|
||||
break;
|
||||
case DBF_DOUBLE:
|
||||
dptr = (double*)value;
|
||||
currentValueLength = scanValue(*format->priv, *dptr);
|
||||
currentValueLength = scanValue(*format->priv, *(double*)value);
|
||||
break;
|
||||
case DBF_STRING:
|
||||
sptr = (char*)value;
|
||||
currentValueLength = scanValue(*format->priv, sptr, maxStringSize);
|
||||
currentValueLength = scanValue(*format->priv, (char*)value,
|
||||
maxStringSize);
|
||||
break;
|
||||
default:
|
||||
error("INTERNAL ERROR (%s): Illegal format type\n", name());
|
||||
@ -762,20 +804,20 @@ scan(format_t *format, void* value, size_t maxStringSize)
|
||||
|
||||
// epicsTimerNotify virtual method ///////////////////////////////////////
|
||||
|
||||
#ifdef EPICS_3_14
|
||||
epicsTimerNotify::expireStatus Stream::
|
||||
expire(const epicsTime&)
|
||||
{
|
||||
timerCallback();
|
||||
return noRestart;
|
||||
}
|
||||
#else
|
||||
#ifdef EPICS_3_13
|
||||
void Stream::
|
||||
expire(CALLBACK *pcallback)
|
||||
{
|
||||
Stream* pstream = static_cast<Stream*>(pcallback->user);
|
||||
pstream->timerCallback();
|
||||
}
|
||||
#else
|
||||
epicsTimerNotify::expireStatus Stream::
|
||||
expire(const epicsTime&)
|
||||
{
|
||||
timerCallback();
|
||||
return noRestart;
|
||||
}
|
||||
#endif
|
||||
|
||||
// StreamCore virtual methods ////////////////////////////////////////////
|
||||
@ -835,10 +877,10 @@ protocolFinishHook(ProtocolResult result)
|
||||
}
|
||||
if (flags & InitRun)
|
||||
{
|
||||
#ifdef EPICS_3_14
|
||||
initDone.signal();
|
||||
#else
|
||||
#ifdef EPICS_3_13
|
||||
semGive(initDone);
|
||||
#else
|
||||
initDone.signal();
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@ -891,13 +933,13 @@ startTimer(unsigned long timeout)
|
||||
{
|
||||
debug("Stream::startTimer(stream=%s, timeout=%lu) = %f seconds\n",
|
||||
name(), timeout, timeout * 0.001);
|
||||
#ifdef EPICS_3_14
|
||||
timer->start(*this, timeout * 0.001);
|
||||
#else
|
||||
#ifdef EPICS_3_13
|
||||
callbackSetPriority(priority(), &timeoutCallback);
|
||||
wdStart(timer, (timeout+1)*sysClkRateGet()/1000-1,
|
||||
reinterpret_cast<FUNCPTR>(callbackRequest),
|
||||
reinterpret_cast<int>(&timeoutCallback));
|
||||
#else
|
||||
timer->start(*this, timeout * 0.001);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -913,13 +955,13 @@ getFieldAddress(const char* fieldname, StreamBuffer& address)
|
||||
else
|
||||
{
|
||||
// FIELD in this record or VAL in other record
|
||||
char fullname[PVNAME_SZ + 1];
|
||||
sprintf(fullname, "%s.%s", name(), fieldname);
|
||||
if (dbNameToAddr(fullname, &dbaddr) != OK)
|
||||
StreamBuffer fullname;
|
||||
fullname.print("%s.%s", name(), fieldname);
|
||||
if (dbNameToAddr(fullname(), &dbaddr) != OK)
|
||||
{
|
||||
// VAL in other record
|
||||
sprintf(fullname, "%s.VAL", fieldname);
|
||||
if (dbNameToAddr(fullname, &dbaddr) != OK) return false;
|
||||
fullname.clear().print("%s.VAL", fieldname);
|
||||
if (dbNameToAddr(fullname(), &dbaddr) != OK) return false;
|
||||
}
|
||||
}
|
||||
address.append(&dbaddr, sizeof(dbaddr));
|
||||
@ -927,9 +969,9 @@ getFieldAddress(const char* fieldname, StreamBuffer& address)
|
||||
}
|
||||
|
||||
static const unsigned char dbfMapping[] =
|
||||
{0, DBF_LONG, DBF_ENUM, DBF_DOUBLE, DBF_STRING};
|
||||
{0, DBF_ULONG, DBF_LONG, DBF_ENUM, DBF_DOUBLE, DBF_STRING};
|
||||
static const short typeSize[] =
|
||||
{0, sizeof(epicsInt32), sizeof(epicsUInt16),
|
||||
{0, sizeof(epicsUInt32), sizeof(epicsInt32), sizeof(epicsUInt16),
|
||||
sizeof(epicsFloat64), MAX_STRING_SIZE};
|
||||
|
||||
bool Stream::
|
||||
@ -941,23 +983,25 @@ formatValue(const StreamFormat& format, const void* fieldaddress)
|
||||
// -- TO DO: If SCAN is "I/O Intr" and record has not been processed, --
|
||||
// -- do it now to get the latest value (only for output records?) --
|
||||
|
||||
format_s fmt;
|
||||
fmt.type = dbfMapping[format.type];
|
||||
fmt.priv = &format;
|
||||
if (fieldaddress)
|
||||
{
|
||||
// Format like "%([record.]field)..." has requested to get value
|
||||
// from field of this or other record.
|
||||
StreamBuffer fieldBuffer;
|
||||
DBADDR* pdbaddr = (DBADDR*)fieldaddress;
|
||||
long i;
|
||||
long nelem = pdbaddr->no_elements;
|
||||
size_t size = nelem * typeSize[format.type];
|
||||
char* buffer = fieldBuffer.clear().reserve(size);
|
||||
|
||||
/* Handle time stamps special. %T converter takes double. */
|
||||
if (strcmp(((dbFldDes*)pdbaddr->pfldDes)->name, "TIME") == 0)
|
||||
{
|
||||
double time;
|
||||
|
||||
if (format.type != double_format)
|
||||
{
|
||||
error ("%s: can only read double values from TIME field\n", name());
|
||||
error ("%s: can only read double values from TIME field\n",
|
||||
name());
|
||||
return false;
|
||||
}
|
||||
if (pdbaddr->precord == record)
|
||||
@ -965,12 +1009,37 @@ formatValue(const StreamFormat& format, const void* fieldaddress)
|
||||
/* if getting time from own record, update timestamp first */
|
||||
recGblGetTimeStamp(record);
|
||||
}
|
||||
time = pdbaddr->precord->time.secPastEpoch + 631152000u + pdbaddr->precord->time.nsec * 1e-9;
|
||||
debug("Stream::formatValue(%s): read %f from TIME field\n", name(), time);
|
||||
/* convert EPICS epoch (1990) to unix epoch (1970) */
|
||||
/* we are losing about 3 digits precision here */
|
||||
time = pdbaddr->precord->time.secPastEpoch +
|
||||
631152000u + pdbaddr->precord->time.nsec * 1e-9;
|
||||
debug("Stream::formatValue(%s): read %f from TIME field\n",
|
||||
name(), time);
|
||||
return printValue(format, time);
|
||||
}
|
||||
|
||||
if (dbGet(pdbaddr, dbfMapping[format.type], buffer,
|
||||
/* convert type to LONG, ENUM, DOUBLE, or STRING */
|
||||
long nelem = pdbaddr->no_elements;
|
||||
size_t size = nelem * typeSize[format.type];
|
||||
|
||||
/* print (U)CHAR arrays as string */
|
||||
if (format.type == string_format &&
|
||||
(pdbaddr->field_type == DBF_CHAR || pdbaddr->field_type == DBF_UCHAR))
|
||||
{
|
||||
debug("Stream::formatValue(%s): format %s.%s array[%ld] size %d of %s as string\n",
|
||||
name(),
|
||||
pdbaddr->precord->name,
|
||||
((dbFldDes*)pdbaddr->pfldDes)->name,
|
||||
nelem,
|
||||
pdbaddr->field_size,
|
||||
pamapdbfType[pdbaddr->field_type].strvalue);
|
||||
fmt.type = DBF_CHAR;
|
||||
size = nelem;
|
||||
}
|
||||
|
||||
char* buffer = fieldBuffer.clear().reserve(size);
|
||||
|
||||
if (dbGet(pdbaddr, fmt.type, buffer,
|
||||
NULL, &nelem, NULL) != 0)
|
||||
{
|
||||
error("%s: dbGet(%s.%s, %s) failed\n",
|
||||
@ -980,6 +1049,18 @@ formatValue(const StreamFormat& format, const void* fieldaddress)
|
||||
pamapdbfType[dbfMapping[format.type]].strvalue);
|
||||
return false;
|
||||
}
|
||||
debug("Stream::formatValue(%s): got %ld elements\n",
|
||||
name(),nelem);
|
||||
|
||||
/* terminate CHAR array as string */
|
||||
if (fmt.type == DBF_CHAR)
|
||||
{
|
||||
if (nelem >= pdbaddr->no_elements) nelem = pdbaddr->no_elements-1;
|
||||
buffer[nelem] = 0;
|
||||
nelem = 1; /* array is only 1 string */
|
||||
}
|
||||
|
||||
long i;
|
||||
for (i = 0; i < nelem; i++)
|
||||
{
|
||||
switch (format.type)
|
||||
@ -989,7 +1070,12 @@ formatValue(const StreamFormat& format, const void* fieldaddress)
|
||||
(long)((epicsUInt16*)buffer)[i]))
|
||||
return false;
|
||||
break;
|
||||
case long_format:
|
||||
case unsigned_format:
|
||||
if (!printValue(format,
|
||||
(long)((epicsUInt32*)buffer)[i]))
|
||||
return false;
|
||||
break;
|
||||
case signed_format:
|
||||
if (!printValue(format,
|
||||
(long)((epicsInt32*)buffer)[i]))
|
||||
return false;
|
||||
@ -1004,8 +1090,10 @@ formatValue(const StreamFormat& format, const void* fieldaddress)
|
||||
return false;
|
||||
break;
|
||||
case pseudo_format:
|
||||
error("%s: %%(FIELD) syntax not allowed with pseudo formats\n",
|
||||
error("%s: %%(FIELD) syntax not allowed "
|
||||
"with pseudo formats\n",
|
||||
name());
|
||||
return false;
|
||||
default:
|
||||
error("INTERNAL ERROR %s: Illegal format.type=%d\n",
|
||||
name(), format.type);
|
||||
@ -1014,9 +1102,6 @@ formatValue(const StreamFormat& format, const void* fieldaddress)
|
||||
}
|
||||
return true;
|
||||
}
|
||||
format_s fmt;
|
||||
fmt.type = dbfMapping[format.type];
|
||||
fmt.priv = &format;
|
||||
debug("Stream::formatValue(%s) format=%%%c type=%s\n",
|
||||
name(), format.conv, pamapdbfType[fmt.type].strvalue);
|
||||
if (!writeData)
|
||||
@ -1036,17 +1121,21 @@ bool Stream::
|
||||
matchValue(const StreamFormat& format, const void* fieldaddress)
|
||||
{
|
||||
// this function must increase consumedInput
|
||||
long consumed;
|
||||
long consumed = 0;
|
||||
long lval;
|
||||
double dval;
|
||||
char* buffer;
|
||||
int status;
|
||||
const char* putfunc;
|
||||
format_s fmt;
|
||||
|
||||
fmt.type = dbfMapping[format.type];
|
||||
fmt.priv = &format;
|
||||
if (fieldaddress)
|
||||
{
|
||||
// Format like "%([record.]field)..." has requested to put value
|
||||
// to field of this or other record.
|
||||
StreamBuffer fieldBuffer;
|
||||
DBADDR* pdbaddr = (DBADDR*)fieldaddress;
|
||||
long nord;
|
||||
long nelem = pdbaddr->no_elements;
|
||||
@ -1054,43 +1143,79 @@ matchValue(const StreamFormat& format, const void* fieldaddress)
|
||||
buffer = fieldBuffer.clear().reserve(size);
|
||||
for (nord = 0; nord < nelem; nord++)
|
||||
{
|
||||
debug("Stream::matchValue(%s): buffer before: %s\n", name(), fieldBuffer.expand()());
|
||||
debug("Stream::matchValue(%s): buffer before: %s\n",
|
||||
name(), fieldBuffer.expand()());
|
||||
switch (format.type)
|
||||
{
|
||||
case long_format:
|
||||
case unsigned_format:
|
||||
{
|
||||
consumed = scanValue(format, lval);
|
||||
if (consumed >= 0) ((epicsUInt32*)buffer)[nord] = lval;
|
||||
debug("Stream::matchValue(%s): %s.%s[%li] = %lu\n",
|
||||
name(), pdbaddr->precord->name,
|
||||
((dbFldDes*)pdbaddr->pfldDes)->name,
|
||||
nord, lval);
|
||||
break;
|
||||
}
|
||||
case signed_format:
|
||||
{
|
||||
consumed = scanValue(format, lval);
|
||||
if (consumed >= 0) ((epicsInt32*)buffer)[nord] = lval;
|
||||
debug("Stream::matchValue(%s): %s[%li] = %li\n",
|
||||
name(), pdbaddr->precord->name, nord, lval);
|
||||
debug("Stream::matchValue(%s): %s.%s[%li] = %li\n",
|
||||
name(), pdbaddr->precord->name,
|
||||
((dbFldDes*)pdbaddr->pfldDes)->name,
|
||||
nord, lval);
|
||||
break;
|
||||
}
|
||||
case enum_format:
|
||||
{
|
||||
consumed = scanValue(format, lval);
|
||||
if (consumed >= 0) ((epicsUInt16*)buffer)[nord] = (epicsUInt16)lval;
|
||||
debug("Stream::matchValue(%s): %s[%li] = %li\n",
|
||||
name(), pdbaddr->precord->name, nord, lval);
|
||||
if (consumed >= 0)
|
||||
((epicsUInt16*)buffer)[nord] = (epicsUInt16)lval;
|
||||
debug("Stream::matchValue(%s): %s.%s[%li] = %li\n",
|
||||
name(), pdbaddr->precord->name,
|
||||
((dbFldDes*)pdbaddr->pfldDes)->name,
|
||||
nord, lval);
|
||||
break;
|
||||
}
|
||||
case double_format:
|
||||
{
|
||||
consumed = scanValue(format, dval);
|
||||
// Direct assignment to buffer fails fith gcc 3.4.3 for xscale_be
|
||||
// Direct assignment to buffer fails with
|
||||
// gcc 3.4.3 for xscale_be
|
||||
// Optimization bug?
|
||||
epicsFloat64 f64=dval;
|
||||
if (consumed >= 0) memcpy(((epicsFloat64*)buffer)+nord, &f64, sizeof(f64));
|
||||
debug("Stream::matchValue(%s): %s[%li] = %#g %#g\n",
|
||||
name(), pdbaddr->precord->name, nord, dval,
|
||||
if (consumed >= 0)
|
||||
memcpy(((epicsFloat64*)buffer)+nord,
|
||||
&f64, sizeof(f64));
|
||||
debug("Stream::matchValue(%s): %s.%s[%li] = %#g %#g\n",
|
||||
name(), pdbaddr->precord->name,
|
||||
((dbFldDes*)pdbaddr->pfldDes)->name,
|
||||
nord, dval,
|
||||
((epicsFloat64*)buffer)[nord]);
|
||||
break;
|
||||
}
|
||||
case string_format:
|
||||
{
|
||||
consumed = scanValue(format,
|
||||
buffer+MAX_STRING_SIZE*nord, MAX_STRING_SIZE);
|
||||
debug("Stream::matchValue(%s): %s[%li] = \"%.*s\"\n",
|
||||
name(), pdbaddr->precord->name, nord, MAX_STRING_SIZE, buffer+MAX_STRING_SIZE*nord);
|
||||
if (pdbaddr->field_type == DBF_CHAR)
|
||||
{
|
||||
// string to char array
|
||||
consumed = scanValue(format, buffer, nelem);
|
||||
debug("Stream::matchValue(%s): %s.%s = \"%.*s\"\n",
|
||||
name(), pdbaddr->precord->name,
|
||||
((dbFldDes*)pdbaddr->pfldDes)->name,
|
||||
(int)consumed, buffer);
|
||||
nord = nelem;
|
||||
}
|
||||
else
|
||||
{
|
||||
consumed = scanValue(format,
|
||||
buffer+MAX_STRING_SIZE*nord, MAX_STRING_SIZE);
|
||||
debug("Stream::matchValue(%s): %s.%s[%li] = \"%.*s\"\n",
|
||||
name(), pdbaddr->precord->name,
|
||||
((dbFldDes*)pdbaddr->pfldDes)->name,
|
||||
nord, MAX_STRING_SIZE, buffer+MAX_STRING_SIZE*nord);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -1098,7 +1223,8 @@ matchValue(const StreamFormat& format, const void* fieldaddress)
|
||||
"Illegal format type\n", name());
|
||||
return false;
|
||||
}
|
||||
debug("Stream::matchValue(%s): buffer after: %s\n", name(), fieldBuffer.expand()());
|
||||
debug("Stream::matchValue(%s): buffer after: %s\n",
|
||||
name(), fieldBuffer.expand()());
|
||||
if (consumed < 0) break;
|
||||
consumedInput += consumed;
|
||||
}
|
||||
@ -1107,7 +1233,8 @@ matchValue(const StreamFormat& format, const void* fieldaddress)
|
||||
// scan error: set other record to alarm status
|
||||
if (pdbaddr->precord != record)
|
||||
{
|
||||
(void) recGblSetSevr(pdbaddr->precord, CALC_ALARM, INVALID_ALARM);
|
||||
(void) recGblSetSevr(pdbaddr->precord,
|
||||
CALC_ALARM, INVALID_ALARM);
|
||||
if (!INIT_RUN)
|
||||
{
|
||||
// process other record to send alarm monitor
|
||||
@ -1121,34 +1248,42 @@ matchValue(const StreamFormat& format, const void* fieldaddress)
|
||||
#ifdef epicsTimeEventDeviceTime
|
||||
if (format.type != double_format)
|
||||
{
|
||||
error ("%s: can only write double values to TIME field\n", name());
|
||||
error ("%s: can only write double values to TIME field\n",
|
||||
name());
|
||||
return false;
|
||||
}
|
||||
/* convert from Unix epoch (1 Jan 1970) to EPICS epoch (1 Jan 1990) */
|
||||
dval = dval-631152000u;
|
||||
pdbaddr->precord->time.secPastEpoch = (long)dval;
|
||||
/* rouding: we don't have 9 digits precision in a double of today's number of seconds */
|
||||
// rouding: we don't have 9 digits precision
|
||||
// in a double of today's number of seconds
|
||||
pdbaddr->precord->time.nsec = (long)((dval-(long)dval)*1e6)*1000;
|
||||
debug("Stream::matchValue(%s): writing %i.%i to TIME field\n", name(),
|
||||
pdbaddr->precord->time.secPastEpoch, pdbaddr->precord->time.nsec);
|
||||
debug("Stream::matchValue(%s): writing %i.%i to %s.TIME field\n",
|
||||
name(),
|
||||
pdbaddr->precord->time.secPastEpoch,
|
||||
pdbaddr->precord->time.nsec,
|
||||
pdbaddr->precord->name);
|
||||
pdbaddr->precord->tse = epicsTimeEventDeviceTime;
|
||||
return true;
|
||||
#else
|
||||
error ("%s: writing TIME field is not supported in this EPICS version\n", name());
|
||||
error ("%s: writing TIME field is not supported "
|
||||
"in this EPICS version\n", name());
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (format.type == string_format &&
|
||||
(pdbaddr->field_type == DBF_CHAR || pdbaddr->field_type == DBF_UCHAR))
|
||||
{
|
||||
/* write strings to [U]CHAR arrays */
|
||||
nord = consumed;
|
||||
fmt.type = DBF_CHAR;
|
||||
}
|
||||
if (pdbaddr->precord == record || INIT_RUN)
|
||||
{
|
||||
// write into own record, thus don't process it
|
||||
// in @init we must not process other record
|
||||
debug("Stream::matchValue(%s): dbPut(%s.%s,%s)\n",
|
||||
name(),
|
||||
pdbaddr->precord->name,
|
||||
((dbFldDes*)pdbaddr->pfldDes)->name,
|
||||
fieldBuffer.expand()());
|
||||
putfunc = "dbPut";
|
||||
status = dbPut(pdbaddr, dbfMapping[format.type], buffer, nord);
|
||||
status = dbPut(pdbaddr, fmt.type, buffer, nord);
|
||||
if (INIT_RUN && pdbaddr->precord != record)
|
||||
{
|
||||
// clean error status of other record in @init
|
||||
@ -1160,40 +1295,44 @@ matchValue(const StreamFormat& format, const void* fieldaddress)
|
||||
else
|
||||
{
|
||||
// write into other record, thus process it
|
||||
debug("Stream::matchValue(%s): dbPutField(%s.%s,%s)\n",
|
||||
name(),
|
||||
pdbaddr->precord->name,
|
||||
((dbFldDes*)pdbaddr->pfldDes)->name,
|
||||
fieldBuffer.expand()());
|
||||
putfunc = "dbPutField";
|
||||
status = dbPutField(pdbaddr, dbfMapping[format.type], buffer, nord);
|
||||
status = dbPutField(pdbaddr, fmt.type,
|
||||
buffer, nord);
|
||||
}
|
||||
debug("Stream::matchValue(%s): %s(%s.%s, %s, %s) status=0x%x\n",
|
||||
name(), putfunc,
|
||||
pdbaddr->precord->name,
|
||||
((dbFldDes*)pdbaddr->pfldDes)->name,
|
||||
pamapdbfType[fmt.type].strvalue,
|
||||
fieldBuffer.expand()(),
|
||||
status);
|
||||
if (status != 0)
|
||||
{
|
||||
flags &= ~ScanTried;
|
||||
switch (format.type)
|
||||
switch (fmt.type)
|
||||
{
|
||||
case long_format:
|
||||
case enum_format:
|
||||
case DBF_ULONG:
|
||||
case DBF_LONG:
|
||||
case DBF_ENUM:
|
||||
error("%s: %s(%s.%s, %s, %li) failed\n",
|
||||
putfunc, name(), pdbaddr->precord->name,
|
||||
name(), putfunc, pdbaddr->precord->name,
|
||||
((dbFldDes*)pdbaddr->pfldDes)->name,
|
||||
pamapdbfType[dbfMapping[format.type]].strvalue,
|
||||
pamapdbfType[fmt.type].strvalue,
|
||||
lval);
|
||||
return false;
|
||||
case double_format:
|
||||
case DBF_DOUBLE:
|
||||
error("%s: %s(%s.%s, %s, %#g) failed\n",
|
||||
putfunc, name(), pdbaddr->precord->name,
|
||||
name(), putfunc, pdbaddr->precord->name,
|
||||
((dbFldDes*)pdbaddr->pfldDes)->name,
|
||||
pamapdbfType[dbfMapping[format.type]].strvalue,
|
||||
pamapdbfType[fmt.type].strvalue,
|
||||
dval);
|
||||
return false;
|
||||
case string_format:
|
||||
error("%s: %s(%s.%s, %s, \"%s\") failed\n",
|
||||
putfunc, name(), pdbaddr->precord->name,
|
||||
case DBF_STRING:
|
||||
error("%s: %s(%s.%s, %s, \"%.*s\") failed\n",
|
||||
name(), putfunc, pdbaddr->precord->name,
|
||||
((dbFldDes*)pdbaddr->pfldDes)->name,
|
||||
pamapdbfType[dbfMapping[format.type]].strvalue,
|
||||
buffer);
|
||||
pamapdbfType[fmt.type].strvalue,
|
||||
(int)consumed, buffer);
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
@ -1202,9 +1341,6 @@ matchValue(const StreamFormat& format, const void* fieldaddress)
|
||||
return true;
|
||||
}
|
||||
// no fieldaddress (the "normal" case)
|
||||
format_s fmt;
|
||||
fmt.type = dbfMapping[format.type];
|
||||
fmt.priv = &format;
|
||||
if (!readData)
|
||||
{
|
||||
error("%s: No readData() function provided\n", name());
|
||||
@ -1229,13 +1365,15 @@ matchValue(const StreamFormat& format, const void* fieldaddress)
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef EPICS_3_14
|
||||
// Pass command to iocsh
|
||||
#ifdef EPICS_3_13
|
||||
// Pass command to vxWorks shell
|
||||
extern "C" int execute(const char *cmd);
|
||||
|
||||
void streamExecuteCommand(CALLBACK *pcallback)
|
||||
{
|
||||
Stream* pstream = static_cast<Stream*>(pcallback->user);
|
||||
|
||||
if (iocshCmd(pstream->outputLine()) != OK)
|
||||
if (execute(pstream->outputLine()) != OK)
|
||||
{
|
||||
pstream->execCallback(StreamIoFault);
|
||||
}
|
||||
@ -1245,14 +1383,12 @@ void streamExecuteCommand(CALLBACK *pcallback)
|
||||
}
|
||||
}
|
||||
#else
|
||||
// Pass command to vxWorks shell
|
||||
extern "C" int execute(const char *cmd);
|
||||
|
||||
// Pass command to iocsh
|
||||
void streamExecuteCommand(CALLBACK *pcallback)
|
||||
{
|
||||
Stream* pstream = static_cast<Stream*>(pcallback->user);
|
||||
|
||||
if (execute(pstream->outputLine()) != OK)
|
||||
if (iocshCmd(pstream->outputLine()) != OK)
|
||||
{
|
||||
pstream->execCallback(StreamIoFault);
|
||||
}
|
||||
@ -1274,19 +1410,19 @@ execute()
|
||||
void Stream::
|
||||
lockMutex()
|
||||
{
|
||||
#ifdef EPICS_3_14
|
||||
mutex.lock();
|
||||
#else
|
||||
#ifdef EPICS_3_13
|
||||
semTake(mutex, WAIT_FOREVER);
|
||||
#else
|
||||
mutex.lock();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Stream::
|
||||
releaseMutex()
|
||||
{
|
||||
#ifdef EPICS_3_14
|
||||
mutex.unlock();
|
||||
#else
|
||||
#ifdef EPICS_3_13
|
||||
semGive(mutex);
|
||||
#else
|
||||
mutex.unlock();
|
||||
#endif
|
||||
}
|
||||
|
@ -20,8 +20,10 @@
|
||||
#include "StreamError.h"
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int streamDebug = 0;
|
||||
int streamError = 0;
|
||||
extern "C" {
|
||||
#ifdef _WIN32
|
||||
__declspec(dllexport)
|
||||
@ -73,6 +75,7 @@ void StreamError(int line, const char* file, const char* fmt, ...)
|
||||
void StreamVError(int line, const char* file, const char* fmt, va_list args)
|
||||
{
|
||||
char timestamp[40];
|
||||
if (!streamError) return; // Error logging disabled
|
||||
StreamPrintTimestampFunction(timestamp, 40);
|
||||
#ifdef va_copy
|
||||
if (StreamDebugFile)
|
||||
|
@ -20,14 +20,15 @@
|
||||
#ifndef StreamError_h
|
||||
#define StreamError_h
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#ifndef __GNUC__
|
||||
#define __attribute__(x)
|
||||
#endif
|
||||
|
||||
extern int streamDebug;
|
||||
extern int streamError;
|
||||
extern void (*StreamPrintTimestampFunction)(char* buffer, int size);
|
||||
|
||||
void StreamError(int line, const char* file, const char* fmt, ...)
|
||||
|
@ -30,15 +30,17 @@ typedef enum {
|
||||
zero_flag = 0x10,
|
||||
skip_flag = 0x20,
|
||||
default_flag = 0x40,
|
||||
compare_flag = 0x80
|
||||
compare_flag = 0x80,
|
||||
fix_width_flag = 0x100
|
||||
} StreamFormatFlag;
|
||||
|
||||
typedef enum {
|
||||
long_format = 1,
|
||||
enum_format = 2,
|
||||
double_format = 3,
|
||||
string_format = 4,
|
||||
pseudo_format = 5
|
||||
unsigned_format = 1,
|
||||
signed_format,
|
||||
enum_format,
|
||||
double_format,
|
||||
string_format,
|
||||
pseudo_format
|
||||
} StreamFormatType;
|
||||
|
||||
extern const char* StreamFormatTypeStr[];
|
||||
@ -47,7 +49,7 @@ typedef struct StreamFormat
|
||||
{
|
||||
char conv;
|
||||
StreamFormatType type;
|
||||
unsigned char flags;
|
||||
unsigned short flags;
|
||||
short prec;
|
||||
unsigned short width;
|
||||
unsigned short infolen;
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
#include "StreamFormatConverter.h"
|
||||
#include "StreamError.h"
|
||||
|
||||
@ -37,7 +38,7 @@ parseFormat(const char*& source, FormatType formatType, StreamFormat& streamForm
|
||||
{
|
||||
/*
|
||||
source := [flags] [width] ['.' prec] conv [extra]
|
||||
flags := '-' | '+' | ' ' | '#' | '0' | '*' | '?' | '='
|
||||
flags := '-' | '+' | ' ' | '#' | '0' | '*' | '?' | '=' | '!'
|
||||
width := integer
|
||||
prec := integer
|
||||
conv := character
|
||||
@ -84,6 +85,15 @@ parseFormat(const char*& source, FormatType formatType, StreamFormat& streamForm
|
||||
}
|
||||
streamFormat.flags |= default_flag;
|
||||
break;
|
||||
case '!':
|
||||
if (formatType != ScanFormat)
|
||||
{
|
||||
error("Use of fixed width modifier '!' "
|
||||
"only allowed in input formats\n");
|
||||
return false;
|
||||
}
|
||||
streamFormat.flags |= fix_width_flag;
|
||||
break;
|
||||
case '=':
|
||||
if (formatType != ScanFormat)
|
||||
{
|
||||
@ -310,13 +320,17 @@ parse(const StreamFormat& fmt, StreamBuffer& info,
|
||||
info.append('l');
|
||||
info.append(fmt.conv);
|
||||
}
|
||||
return long_format;
|
||||
if (fmt.conv == 'd' || fmt.conv == 'i') return signed_format;
|
||||
return unsigned_format;
|
||||
}
|
||||
|
||||
bool StdLongConverter::
|
||||
printLong(const StreamFormat& fmt, StreamBuffer& output, long value)
|
||||
{
|
||||
output.printf(fmt.info, value);
|
||||
// limits %x/%X formats to number of half bytes in width.
|
||||
if (fmt.width && (fmt.conv == 'x' || fmt.conv == 'X') && fmt.width < 2*sizeof(long))
|
||||
value &= ~(-1L << (fmt.width*4));
|
||||
output.print(fmt.info, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -327,6 +341,7 @@ scanLong(const StreamFormat& fmt, const char* input, long& value)
|
||||
int length;
|
||||
bool neg;
|
||||
int base;
|
||||
long v;
|
||||
|
||||
length = prepareval(fmt, input, neg);
|
||||
if (length < 0) return -1;
|
||||
@ -336,14 +351,11 @@ scanLong(const StreamFormat& fmt, const char* input, long& value)
|
||||
base = 10;
|
||||
break;
|
||||
case 'o':
|
||||
base = 8;
|
||||
goto signcheck;
|
||||
case 'x':
|
||||
case 'X':
|
||||
base = 16;
|
||||
signcheck:
|
||||
// allow negative hex and oct numbers with - flag
|
||||
// allow negative hex and oct numbers with - flag
|
||||
if (neg && !(fmt.flags & left_flag)) return -1;
|
||||
base = (fmt.conv == 'o') ? 8 : 16;
|
||||
break;
|
||||
case 'u':
|
||||
if (neg) return -1;
|
||||
@ -352,10 +364,10 @@ signcheck:
|
||||
default:
|
||||
base = 0;
|
||||
}
|
||||
value = strtoul(input, &end, base);
|
||||
if (neg) value = -value;
|
||||
v = strtoul(input, &end, base);
|
||||
if (end == input) return -1;
|
||||
length += end-input;
|
||||
value = neg ? -v : v;
|
||||
return length;
|
||||
}
|
||||
|
||||
@ -395,7 +407,7 @@ parse(const StreamFormat& fmt, StreamBuffer& info,
|
||||
bool StdDoubleConverter::
|
||||
printDouble(const StreamFormat& fmt, StreamBuffer& output, double value)
|
||||
{
|
||||
output.printf(fmt.info, value);
|
||||
output.print(fmt.info, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -430,10 +442,11 @@ int StdStringConverter::
|
||||
parse(const StreamFormat& fmt, StreamBuffer& info,
|
||||
const char*& source, bool scanFormat)
|
||||
{
|
||||
if (fmt.flags & (sign_flag|zero_flag))
|
||||
if (fmt.flags & sign_flag)
|
||||
{
|
||||
error("Use of modifiers '+', '0'"
|
||||
"not allowed with %%s conversion\n");
|
||||
error("Use of modifier '+'"
|
||||
"not allowed with %%%c conversion\n",
|
||||
fmt.conv);
|
||||
return false;
|
||||
}
|
||||
if (scanFormat && fmt.prec >= 0)
|
||||
@ -451,7 +464,22 @@ parse(const StreamFormat& fmt, StreamBuffer& info,
|
||||
bool StdStringConverter::
|
||||
printString(const StreamFormat& fmt, StreamBuffer& output, const char* value)
|
||||
{
|
||||
output.printf(fmt.info, value);
|
||||
if (fmt.flags & zero_flag && fmt.width)
|
||||
{
|
||||
size_t l;
|
||||
if (fmt.prec > -1)
|
||||
{
|
||||
char* p = (char*)memchr(value, 0, fmt.prec);
|
||||
if (p) l = p - value;
|
||||
else l = fmt.prec;
|
||||
}
|
||||
else l = strlen(value);
|
||||
if (!(fmt.flags & left_flag)) output.append('\0', fmt.width-l);
|
||||
output.append(value, l);
|
||||
if (fmt.flags & left_flag) output.append('\0', fmt.width-l);
|
||||
}
|
||||
else
|
||||
output.print(fmt.info, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -543,13 +571,13 @@ parse(const StreamFormat& fmt, StreamBuffer& info,
|
||||
info.append("%n");
|
||||
return string_format;
|
||||
}
|
||||
return long_format;
|
||||
return unsigned_format;
|
||||
}
|
||||
|
||||
bool StdCharsConverter::
|
||||
printLong(const StreamFormat& fmt, StreamBuffer& output, long value)
|
||||
{
|
||||
output.printf(fmt.info, value);
|
||||
output.print(fmt.info, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,8 @@
|
||||
#include "StreamError.h"
|
||||
|
||||
const char* StreamFormatTypeStr[] = {
|
||||
"none", "long", "enum", "double", "string", "pseudo"
|
||||
// must match the order in StreamFormat.h
|
||||
"none", "unsigned", "signed", "enum", "double", "string", "pseudo"
|
||||
};
|
||||
|
||||
class StreamProtocolParser::Protocol::Variable
|
||||
@ -634,7 +635,7 @@ printString(StreamBuffer& buffer, const char* s)
|
||||
switch (*s)
|
||||
{
|
||||
case esc:
|
||||
buffer.printf("\\x%02x", (*++s) & 0xff);
|
||||
buffer.print("\\x%02x", (*++s) & 0xff);
|
||||
break;
|
||||
case '\r':
|
||||
buffer.append("\\r");
|
||||
@ -655,7 +656,7 @@ printString(StreamBuffer& buffer, const char* s)
|
||||
buffer.append("\\\\");
|
||||
break;
|
||||
case format_field:
|
||||
buffer.printf("%%(%s)", ++s);
|
||||
buffer.print("%%(%s)", ++s);
|
||||
while (*s++);
|
||||
s += extract<unsigned short>(s); // skip fieldaddress
|
||||
goto format;
|
||||
@ -670,7 +671,7 @@ format: {
|
||||
continue;
|
||||
default:
|
||||
if ((*s & 0x7f) < 0x20 || (*s & 0x7f) == 0x7f)
|
||||
buffer.printf("\\x%02x", *s & 0xff);
|
||||
buffer.print("\\x%02x", *s & 0xff);
|
||||
else
|
||||
buffer.append(*s);
|
||||
}
|
||||
@ -1037,7 +1038,7 @@ compileNumber(unsigned long& number, const char*& source, unsigned long max)
|
||||
"Garbage after numeric value: %s\n", buffer());
|
||||
return false;
|
||||
}
|
||||
if (n < 0 || n > max)
|
||||
if (n > max)
|
||||
{
|
||||
debug("StreamProtocolParser::Protocol::compileNumber: %s\n",
|
||||
buffer.expand()());
|
||||
@ -1059,7 +1060,6 @@ compileString(StreamBuffer& buffer, const char*& source,
|
||||
FormatType formatType, Client* client, int quoted)
|
||||
{
|
||||
bool escaped = false;
|
||||
int n;
|
||||
int newline = 0;
|
||||
StreamBuffer formatbuffer;
|
||||
int formatpos = buffer.length();
|
||||
@ -1136,7 +1136,8 @@ compileString(StreamBuffer& buffer, const char*& source,
|
||||
if (escaped) // char after \ in quoted text
|
||||
{
|
||||
escaped = false;
|
||||
unsigned int temp;
|
||||
unsigned int c;
|
||||
int n=1;
|
||||
switch (*source)
|
||||
{
|
||||
case '$': // can't be: readToken would have made a token from this
|
||||
@ -1145,61 +1146,50 @@ compileString(StreamBuffer& buffer, const char*& source,
|
||||
return false;
|
||||
case '?':
|
||||
buffer.append(skip);
|
||||
break;
|
||||
source++;
|
||||
continue;
|
||||
case '_':
|
||||
buffer.append(whitespace);
|
||||
break;
|
||||
source++;
|
||||
continue;
|
||||
case 'a':
|
||||
buffer.append(7);
|
||||
c=7;
|
||||
break;
|
||||
case 'b':
|
||||
buffer.append(8);
|
||||
c=8;
|
||||
break;
|
||||
case 't':
|
||||
buffer.append(9);
|
||||
c=9;
|
||||
break;
|
||||
case 'n':
|
||||
buffer.append('\n');
|
||||
c='\n';
|
||||
break;
|
||||
case 'r':
|
||||
buffer.append('\r');
|
||||
c='\r';
|
||||
break;
|
||||
case 'e':
|
||||
buffer.append(esc).append(esc);
|
||||
c=esc;
|
||||
break;
|
||||
case '0': // octal numbers (max 3 digits after 0)
|
||||
sscanf (source, "%3o%n", &temp, &n);
|
||||
if (temp > 0xFF)
|
||||
case '0': // octal numbers (max 4 digits)
|
||||
sscanf (source, "%4o%n", &c, &n); //cannot fail
|
||||
if (c > 0xFF)
|
||||
{
|
||||
error(line, filename(),
|
||||
"Octal source %#o does not fit in byte: %s\n",
|
||||
temp, source-1);
|
||||
"Octal number %#o does not fit in byte: \"%s\"\n",
|
||||
c, source-1);
|
||||
return false;
|
||||
}
|
||||
if (formatType != NoFormat &&
|
||||
(temp < last_function_code || temp == esc))
|
||||
{
|
||||
buffer.append(esc);
|
||||
}
|
||||
buffer.append(temp);
|
||||
source += n;
|
||||
continue;
|
||||
case 'x': // hex numbers (max 2 digits after 0)
|
||||
if (sscanf (source+1, "%2x%n", &temp, &n) < 1)
|
||||
break;
|
||||
case 'x': // hex numbers (max 2 digits after x)
|
||||
if (sscanf (source+1, "%2x%n", &c, &n) < 1)
|
||||
{
|
||||
error(line, filename(),
|
||||
"Hex digit expected after \\x: %s\n",
|
||||
"Hex digit expected after \\x: \"%s\"\n",
|
||||
source-1);
|
||||
return false;
|
||||
}
|
||||
if (formatType != NoFormat &&
|
||||
(temp < last_function_code || temp == esc))
|
||||
{
|
||||
buffer.append(esc);
|
||||
}
|
||||
buffer.append(temp);
|
||||
source += n+1;
|
||||
continue;
|
||||
n++;
|
||||
break;
|
||||
case '1': // decimal numbers (max 3 digits)
|
||||
case '2':
|
||||
case '3':
|
||||
@ -1209,26 +1199,24 @@ compileString(StreamBuffer& buffer, const char*& source,
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
sscanf (source, "%3u%n", &temp, &n);
|
||||
if (temp > 0xFF)
|
||||
sscanf (source, "%3u%n", &c, &n); //cannot fail
|
||||
if (c > 0xFF)
|
||||
{
|
||||
error(line, filename(),
|
||||
"Decimal source %d does not fit in byte: %s\n",
|
||||
temp, source-1);
|
||||
"Decimal number %d does not fit in byte: \"%s\"\n",
|
||||
c, source-1);
|
||||
return false;
|
||||
}
|
||||
if (formatType != NoFormat &&
|
||||
(temp < last_function_code || temp == esc))
|
||||
{
|
||||
buffer.append(esc);
|
||||
}
|
||||
buffer.append(temp);
|
||||
source += n;
|
||||
continue;
|
||||
break;
|
||||
default: // escaped literals
|
||||
buffer.append(esc).append(*source);
|
||||
c=*source;
|
||||
}
|
||||
source++;
|
||||
source+=n;
|
||||
if (formatType != NoFormat)
|
||||
{
|
||||
buffer.append(esc);
|
||||
}
|
||||
buffer.append(c);
|
||||
continue;
|
||||
}
|
||||
if (quoted) // look for ending quotes and escapes
|
||||
@ -1281,7 +1269,7 @@ compileString(StreamBuffer& buffer, const char*& source,
|
||||
}
|
||||
// try numeric byte value
|
||||
char* p;
|
||||
int temp = strtol(source, &p, 0);
|
||||
int c = strtol(source, &p, 0);
|
||||
if (p != source)
|
||||
{
|
||||
if (*p != 0)
|
||||
@ -1290,18 +1278,17 @@ compileString(StreamBuffer& buffer, const char*& source,
|
||||
"Garbage after numeric source: %s", source);
|
||||
return false;
|
||||
}
|
||||
if (temp > 0xFF || temp < -0x80)
|
||||
if (c > 0xFF || c < -0x80)
|
||||
{
|
||||
error(line, filename(),
|
||||
"Value %s does not fit in byte\n", source);
|
||||
return false;
|
||||
}
|
||||
if (formatType != NoFormat &&
|
||||
(temp < last_function_code || temp == esc))
|
||||
if (formatType != NoFormat)
|
||||
{
|
||||
buffer.append(esc);
|
||||
}
|
||||
buffer.append(temp);
|
||||
buffer.append(c);
|
||||
source = p+1+sizeof(int);
|
||||
continue;
|
||||
}
|
||||
@ -1348,7 +1335,7 @@ compileString(StreamBuffer& buffer, const char*& source,
|
||||
{"del", 0x7f}
|
||||
};
|
||||
size_t i;
|
||||
char c = 0;
|
||||
c=-1;
|
||||
for (i = 0; i < sizeof(codes)/sizeof(*codes); i++)
|
||||
{
|
||||
if (strcmp(source, codes[i].name) == 0)
|
||||
@ -1361,8 +1348,7 @@ compileString(StreamBuffer& buffer, const char*& source,
|
||||
source);
|
||||
return false;
|
||||
}
|
||||
if (formatType != NoFormat &&
|
||||
(temp < last_function_code || temp == esc))
|
||||
if (formatType != NoFormat)
|
||||
{
|
||||
buffer.append(esc);
|
||||
}
|
||||
@ -1371,10 +1357,10 @@ compileString(StreamBuffer& buffer, const char*& source,
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (c) continue;
|
||||
if (c >= 0) continue;
|
||||
// source may contain a function name
|
||||
error(line, filename(),
|
||||
"Unexpected word: %s\n", source);
|
||||
"Unexpected word: \"%s\"\n", source);
|
||||
return false;
|
||||
}
|
||||
debug("StreamProtocolParser::Protocol::compileString buffer=%s\n", buffer.expand()());
|
||||
@ -1453,7 +1439,7 @@ compileFormat(StreamBuffer& buffer, const char*& formatstr,
|
||||
// parsing failed
|
||||
return false;
|
||||
}
|
||||
if (type < long_format && type > pseudo_format)
|
||||
if (type < 1 && type > pseudo_format)
|
||||
{
|
||||
error(line, filename(),
|
||||
"Illegal format type %d returned from '%%%c' converter\n",
|
||||
@ -1493,8 +1479,10 @@ compileFormat(StreamBuffer& buffer, const char*& formatstr,
|
||||
buffer.append(&streamFormat, sizeof(streamFormat));
|
||||
buffer.append(infoString);
|
||||
|
||||
debug("StreamProtocolParser::Protocol::compileFormat: format.type=%s, infolen=%d\n",
|
||||
StreamFormatTypeStr[streamFormat.type], streamFormat.infolen);
|
||||
debug("StreamProtocolParser::Protocol::compileFormat: format.type=%s, "
|
||||
"infolen=%d infostring=\"%s\"\n",
|
||||
StreamFormatTypeStr[streamFormat.type],
|
||||
streamFormat.infolen, infoString.expand()());
|
||||
formatstr = source; // move pointer after parsed format
|
||||
return true;
|
||||
}
|
||||
|
@ -23,6 +23,7 @@
|
||||
#define STR2(x) #x
|
||||
#define STR(x) STR2(x)
|
||||
const char StreamVersion [] =
|
||||
"StreamDevice " STR(STREAM_MAJOR) "." STR(STREAM_MINOR)
|
||||
"StreamDevice " STR(STREAM_MAJOR)
|
||||
"." STR(STREAM_MINOR)
|
||||
"." STR(STREAM_PATCHLEVEL)
|
||||
" built " __DATE__ " " __TIME__;
|
||||
|
||||
|
@ -26,6 +26,24 @@
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
||||
/* timezone in UNIX contains the seconds between UTC and local time,
|
||||
but not in Free-BSD! Here timezone() is a function delivering
|
||||
the time zone abbreviation (e.g. CET). Alternatively, the timezone
|
||||
value can also be gained from tm_gmtoff of the tm-structure.
|
||||
HJK, 4.4.14 */
|
||||
/* The same seems to be true for other BSDs. DZ. */
|
||||
|
||||
#if defined(__FreeBSD__) || \
|
||||
defined(__NetBSD__) || \
|
||||
defined(__OpenBSD__) || \
|
||||
defined(__bsdi__ ) || \
|
||||
defined(__DragonFly__)
|
||||
static int timezone_bsd=0;
|
||||
#define timezone timezone_bsd
|
||||
#define tzset() { struct tm tm; time_t timet; tzset(); time(&timet); \
|
||||
localtime_r(&timet, &tm); timezone=tm.tm_gmtoff; }
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#define tzset() _tzset()
|
||||
#define timezone _timezone
|
||||
@ -46,6 +64,13 @@ int timezone = 0;
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#if defined(__MINGW32__)
|
||||
/* MinGW has no re-entrant localtime. How about other environments? */
|
||||
/* Just let's hope for the best */
|
||||
#undef localtime_r
|
||||
#define localtime_r(timet,tm) (*(tm)=*localtime(timet))
|
||||
#endif
|
||||
|
||||
class TimestampConverter : public StreamFormatConverter
|
||||
{
|
||||
int parse(const StreamFormat&, StreamBuffer&, const char*&, bool);
|
||||
@ -82,14 +107,14 @@ parse(const StreamFormat&, StreamBuffer& info,
|
||||
if (*c == 'f')
|
||||
{
|
||||
source = c;
|
||||
info.printf("%%0%uf", n);
|
||||
info.print("%%0%uf", n);
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* look for nanoseconds %N of %f */
|
||||
if (*source == 'N' || *source == 'f')
|
||||
{
|
||||
info.printf("%%09f");
|
||||
info.print("%%09f");
|
||||
break;
|
||||
}
|
||||
/* look for seconds with fractions like %.3S */
|
||||
@ -100,7 +125,7 @@ parse(const StreamFormat&, StreamBuffer& info,
|
||||
if (toupper(*c) == 'S')
|
||||
{
|
||||
source = c;
|
||||
info.printf("%%%c.%%0%uf", *c, n);
|
||||
info.print("%%%c.%%0%uf", *c, n);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -366,7 +391,7 @@ startover:
|
||||
debug ("TimestampConverter::scantime: %s hour = %d\n", pm?"PM":"AM", tm->tm_hour);
|
||||
break;
|
||||
case 'M': /* minute */
|
||||
i = nummatch(input, 1, 59);
|
||||
i = nummatch(input, 0, 59);
|
||||
if (i < 0)
|
||||
{
|
||||
error ("error parsing minute: '%.20s'\n", input);
|
||||
@ -376,7 +401,7 @@ startover:
|
||||
debug ("TimestampConverter::scantime: min = %d\n", tm->tm_min);
|
||||
break;
|
||||
case 'S': /* second */
|
||||
i = nummatch(input, 1, 60);
|
||||
i = nummatch(input, 0, 60);
|
||||
if (i < 0)
|
||||
{
|
||||
error ("error parsing week second: '%.20s'\n", input);
|
||||
|
@ -22,7 +22,8 @@
|
||||
#define devStream_h
|
||||
|
||||
#define STREAM_MAJOR 2
|
||||
#define STREAM_MINOR 4
|
||||
#define STREAM_MINOR 8
|
||||
#define STREAM_PATCHLEVEL 0
|
||||
|
||||
#if defined(__vxworks) || defined(vxWorks)
|
||||
#include <vxWorks.h>
|
||||
@ -40,22 +41,31 @@
|
||||
#define INIT_RUN (!interruptAccept)
|
||||
|
||||
#include <epicsVersion.h>
|
||||
#if (EPICS_VERSION == 3 && EPICS_REVISION == 14)
|
||||
#define EPICS_3_14
|
||||
#ifdef BASE_VERSION
|
||||
#define EPICS_3_13
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus) && !defined(EPICS_3_14)
|
||||
#if defined(__cplusplus) && defined(EPICS_3_13)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef epicsExportSharedSymbols
|
||||
# define devStream_epicsExportSharedSymbols
|
||||
# undef epicsExportSharedSymbols
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <dbCommon.h>
|
||||
#include <dbScan.h>
|
||||
#include <devSup.h>
|
||||
/* #include <dbFldTypes.h> */
|
||||
#include <dbAccess.h>
|
||||
|
||||
#if defined(__cplusplus) && !defined(EPICS_3_14)
|
||||
#ifdef devStream_epicsExportSharedSymbols
|
||||
# define epicsExportSharedSymbols
|
||||
# include "shareLib.h"
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus) && defined(EPICS_3_13)
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -69,23 +79,22 @@ typedef const struct format_s {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
__declspec(dllimport)
|
||||
#endif
|
||||
extern FILE* StreamDebugFile;
|
||||
epicsShareExtern FILE* StreamDebugFile;
|
||||
|
||||
extern const char StreamVersion [];
|
||||
|
||||
typedef long (*streamIoFunction) (dbCommon*, format_t*);
|
||||
|
||||
long streamInit(int after);
|
||||
long streamInitRecord(dbCommon *record, struct link *ioLink,
|
||||
epicsShareFunc long streamInit(int after);
|
||||
epicsShareFunc long streamInitRecord(dbCommon *record,
|
||||
const struct link *ioLink,
|
||||
streamIoFunction readData, streamIoFunction writeData);
|
||||
long streamReport(int interest);
|
||||
long streamReadWrite(dbCommon *record);
|
||||
long streamGetIointInfo(int cmd, dbCommon *record, IOSCANPVT *ppvt);
|
||||
long streamPrintf(dbCommon *record, format_t *format, ...);
|
||||
long streamScanfN(dbCommon *record, format_t *format,
|
||||
epicsShareFunc long streamReport(int interest);
|
||||
epicsShareFunc long streamReadWrite(dbCommon *record);
|
||||
epicsShareFunc long streamGetIointInfo(int cmd,
|
||||
dbCommon *record, IOSCANPVT *ppvt);
|
||||
epicsShareFunc long streamPrintf(dbCommon *record, format_t *format, ...);
|
||||
epicsShareFunc long streamScanfN(dbCommon *record, format_t *format,
|
||||
void*, size_t maxStringSize);
|
||||
|
||||
/* backward compatibility stuff */
|
||||
|
@ -20,9 +20,9 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "devStream.h"
|
||||
#include <aaiRecord.h>
|
||||
#include <errlog.h>
|
||||
#include <aaiRecord.h>
|
||||
#include "devStream.h"
|
||||
#include <epicsExport.h>
|
||||
|
||||
static long readData (dbCommon *record, format_t *format)
|
||||
@ -57,6 +57,7 @@ static long readData (dbCommon *record, format_t *format)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DBF_ULONG:
|
||||
case DBF_LONG:
|
||||
case DBF_ENUM:
|
||||
{
|
||||
@ -191,6 +192,7 @@ static long writeData (dbCommon *record, format_t *format)
|
||||
return ERROR;
|
||||
break;
|
||||
}
|
||||
case DBF_ULONG:
|
||||
case DBF_LONG:
|
||||
case DBF_ENUM:
|
||||
{
|
||||
|
@ -20,9 +20,9 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "devStream.h"
|
||||
#include <aaoRecord.h>
|
||||
#include <errlog.h>
|
||||
#include <aaoRecord.h>
|
||||
#include "devStream.h"
|
||||
#include <epicsExport.h>
|
||||
|
||||
static long readData (dbCommon *record, format_t *format)
|
||||
@ -57,6 +57,7 @@ static long readData (dbCommon *record, format_t *format)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DBF_ULONG:
|
||||
case DBF_LONG:
|
||||
case DBF_ENUM:
|
||||
{
|
||||
@ -191,6 +192,7 @@ static long writeData (dbCommon *record, format_t *format)
|
||||
return ERROR;
|
||||
break;
|
||||
}
|
||||
case DBF_ULONG:
|
||||
case DBF_LONG:
|
||||
case DBF_ENUM:
|
||||
{
|
||||
|
@ -18,41 +18,18 @@
|
||||
* *
|
||||
***************************************************************/
|
||||
|
||||
#include "devStream.h"
|
||||
#include <aiRecord.h>
|
||||
#include "devStream.h"
|
||||
#ifdef EPICS_3_13
|
||||
#include <private/mathP.h>
|
||||
#define isinf(x) isInf(x)
|
||||
#define isnan(x) isNan(x)
|
||||
#else
|
||||
#include <epicsMath.h>
|
||||
#endif
|
||||
#include <epicsExport.h>
|
||||
|
||||
static long readData (dbCommon *record, format_t *format)
|
||||
{
|
||||
aiRecord *ai = (aiRecord *) record;
|
||||
|
||||
switch (format->type)
|
||||
{
|
||||
case DBF_DOUBLE:
|
||||
{
|
||||
double val;
|
||||
if (streamScanf (record, format, &val)) return ERROR;
|
||||
if (ai->aslo != 0.0) val *= ai->aslo;
|
||||
val += ai->aoff;
|
||||
if (!INIT_RUN && ai->smoo != 0.0)
|
||||
{
|
||||
val = ai->val * ai->smoo + val * (1.0 - ai->smoo);
|
||||
}
|
||||
ai->val = val;
|
||||
return DO_NOT_CONVERT;
|
||||
}
|
||||
case DBF_LONG:
|
||||
{
|
||||
long rval;
|
||||
if (streamScanf (record, format, &rval)) return ERROR;
|
||||
ai->rval = rval;
|
||||
return OK;
|
||||
}
|
||||
}
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
static long writeData (dbCommon *record, format_t *format)
|
||||
{
|
||||
aiRecord *ai = (aiRecord *) record;
|
||||
double val;
|
||||
@ -61,13 +38,67 @@ static long writeData (dbCommon *record, format_t *format)
|
||||
{
|
||||
case DBF_DOUBLE:
|
||||
{
|
||||
val = ai->val - ai->aoff;
|
||||
if (ai->aslo != 0) val /= ai->aslo;
|
||||
if (streamScanf (record, format, &val)) return ERROR;
|
||||
break;
|
||||
}
|
||||
case DBF_ULONG:
|
||||
case DBF_LONG:
|
||||
{
|
||||
long rval;
|
||||
if (streamScanf (record, format, &rval)) return ERROR;
|
||||
ai->rval = rval;
|
||||
if (ai->linr == 0)
|
||||
{
|
||||
/* allow integers with more than 32 bits */
|
||||
if (format->type == DBF_ULONG)
|
||||
val = (unsigned long)rval;
|
||||
else
|
||||
val = rval;
|
||||
break;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
default:
|
||||
return ERROR;
|
||||
}
|
||||
if (ai->aslo != 0.0 && ai->aslo != 1.0) val *= ai->aslo;
|
||||
val += ai->aoff;
|
||||
if (!(ai->smoo == 0.0 || ai->init || ai->udf || isinf(ai->val) || isnan(ai->val)))
|
||||
val = ai->val * ai->smoo + val * (1.0 - ai->smoo);
|
||||
ai->val = val;
|
||||
return DO_NOT_CONVERT;
|
||||
}
|
||||
|
||||
static long writeData (dbCommon *record, format_t *format)
|
||||
{
|
||||
aiRecord *ai = (aiRecord *) record;
|
||||
|
||||
double val = ai->val - ai->aoff;
|
||||
if (ai->aslo != 0.0 && ai->aslo != 1.0) val /= ai->aslo;
|
||||
|
||||
switch (format->type)
|
||||
{
|
||||
case DBF_DOUBLE:
|
||||
{
|
||||
return streamPrintf (record, format, val);
|
||||
}
|
||||
case DBF_ULONG:
|
||||
{
|
||||
if (ai->linr == 0)
|
||||
{
|
||||
/* allow more bits than 32 */
|
||||
return streamPrintf (record, format, (unsigned long)val);
|
||||
}
|
||||
return streamPrintf (record, format, (unsigned long)ai->rval);
|
||||
}
|
||||
case DBF_LONG:
|
||||
{
|
||||
return streamPrintf (record, format, (long) ai->rval);
|
||||
if (ai->linr == 0)
|
||||
{
|
||||
/* allow more bits than 32 */
|
||||
return streamPrintf (record, format, (long)val);
|
||||
}
|
||||
return streamPrintf (record, format, (long)ai->rval);
|
||||
}
|
||||
}
|
||||
return ERROR;
|
||||
|
@ -18,54 +18,78 @@
|
||||
* *
|
||||
***************************************************************/
|
||||
|
||||
#include "devStream.h"
|
||||
#include <aoRecord.h>
|
||||
#include "devStream.h"
|
||||
#include <epicsExport.h>
|
||||
|
||||
static long readData (dbCommon *record, format_t *format)
|
||||
{
|
||||
aoRecord *ao = (aoRecord *) record;
|
||||
double val;
|
||||
|
||||
switch (format->type)
|
||||
{
|
||||
case DBF_DOUBLE:
|
||||
{
|
||||
double val;
|
||||
if (streamScanf (record, format, &val)) return ERROR;
|
||||
if (ao->aslo != 0) val *= ao->aslo;
|
||||
ao->val = val + ao->aoff;
|
||||
return DO_NOT_CONVERT;
|
||||
break;
|
||||
}
|
||||
case DBF_ULONG:
|
||||
case DBF_LONG:
|
||||
{
|
||||
long rval;
|
||||
if (streamScanf (record, format, &rval)) return ERROR;
|
||||
ao->rbv = rval;
|
||||
if (INIT_RUN) ao->rval = rval;
|
||||
ao->rval = rval;
|
||||
if (ao->linr == 0)
|
||||
{
|
||||
/* allow integers with more than 32 bits */
|
||||
if (format->type == DBF_ULONG)
|
||||
val = (unsigned long)rval;
|
||||
else
|
||||
val = rval;
|
||||
break;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
default:
|
||||
return ERROR;
|
||||
}
|
||||
return ERROR;
|
||||
if (ao->aslo != 0.0 && ao->aslo != 1.0) val *= ao->aslo;
|
||||
ao->val = val + ao->aoff;
|
||||
return DO_NOT_CONVERT;
|
||||
}
|
||||
|
||||
static long writeData (dbCommon *record, format_t *format)
|
||||
{
|
||||
aoRecord *ao = (aoRecord *) record;
|
||||
|
||||
double val = (INIT_RUN ? ao->val : ao->oval) - ao->aoff;
|
||||
if (ao->aslo != 0.0 && ao->aslo != 1.0) val /= ao->aslo;
|
||||
|
||||
switch (format->type)
|
||||
{
|
||||
case DBF_DOUBLE:
|
||||
{
|
||||
double val;
|
||||
if (INIT_RUN) val = ao->val;
|
||||
else val = ao->oval;
|
||||
val -= ao->aoff;
|
||||
if (ao->aslo != 0) val /= ao->aslo;
|
||||
return streamPrintf (record, format, val);
|
||||
}
|
||||
case DBF_ULONG:
|
||||
{
|
||||
if (ao->linr == 0)
|
||||
{
|
||||
/* allow integers with more than 32 bits */
|
||||
return streamPrintf (record, format, (unsigned long)val);
|
||||
}
|
||||
return streamPrintf (record, format, (unsigned long)ao->rval);
|
||||
}
|
||||
case DBF_LONG:
|
||||
{
|
||||
return streamPrintf (record, format, (long) ao->rval);
|
||||
if (ao->linr == 0)
|
||||
{
|
||||
/* allow integers with more than 32 bits */
|
||||
return streamPrintf (record, format, (long)val);
|
||||
}
|
||||
return streamPrintf (record, format, (long)ao->rval);
|
||||
}
|
||||
}
|
||||
return ERROR;
|
||||
|
@ -18,9 +18,9 @@
|
||||
* *
|
||||
***************************************************************/
|
||||
|
||||
#include "devStream.h"
|
||||
#include <biRecord.h>
|
||||
#include <string.h>
|
||||
#include <biRecord.h>
|
||||
#include "devStream.h"
|
||||
#include <epicsExport.h>
|
||||
|
||||
static long readData (dbCommon *record, format_t *format)
|
||||
@ -30,6 +30,7 @@ static long readData (dbCommon *record, format_t *format)
|
||||
|
||||
switch (format->type)
|
||||
{
|
||||
case DBF_ULONG:
|
||||
case DBF_LONG:
|
||||
{
|
||||
if (streamScanf (record, format, &val)) return ERROR;
|
||||
@ -69,13 +70,14 @@ static long writeData (dbCommon *record, format_t *format)
|
||||
|
||||
switch (format->type)
|
||||
{
|
||||
case DBF_ULONG:
|
||||
case DBF_LONG:
|
||||
{
|
||||
return streamPrintf (record, format, bi->rval);
|
||||
}
|
||||
case DBF_ENUM:
|
||||
{
|
||||
return streamPrintf (record, format, (long) bi->val);
|
||||
return streamPrintf (record, format, (long)bi->val);
|
||||
}
|
||||
case DBF_STRING:
|
||||
{
|
||||
|
@ -18,9 +18,9 @@
|
||||
* *
|
||||
***************************************************************/
|
||||
|
||||
#include "devStream.h"
|
||||
#include <boRecord.h>
|
||||
#include <string.h>
|
||||
#include <boRecord.h>
|
||||
#include "devStream.h"
|
||||
#include <epicsExport.h>
|
||||
|
||||
static long readData (dbCommon *record, format_t *format)
|
||||
@ -30,6 +30,7 @@ static long readData (dbCommon *record, format_t *format)
|
||||
|
||||
switch (format->type)
|
||||
{
|
||||
case DBF_ULONG:
|
||||
case DBF_LONG:
|
||||
{
|
||||
if (streamScanf (record, format, &val)) return ERROR;
|
||||
@ -70,13 +71,14 @@ static long writeData (dbCommon *record, format_t *format)
|
||||
|
||||
switch (format->type)
|
||||
{
|
||||
case DBF_ULONG:
|
||||
case DBF_LONG:
|
||||
{
|
||||
return streamPrintf (record, format, bo->rval);
|
||||
}
|
||||
case DBF_ENUM:
|
||||
{
|
||||
return streamPrintf (record, format, (long) bo->val);
|
||||
return streamPrintf (record, format, (long)bo->val);
|
||||
}
|
||||
case DBF_STRING:
|
||||
{
|
||||
|