Sorry for not using the subject line, I have forgotten it.
If using macros, where I have to define it? And/or where can I specify its value? If I define the record like the following I get it right, but always with that values initialized with:
field(INP, "@devwbc6600.proto c4($(HI=0x04),$(LO=0x57)) $(PORT) $(A)")
I want to specify the values of the macros each time I process the record. I get an error in IOC initialization if I put it without values:
field(INP, "@devwbc6600.proto c4($(HI),$(LO)) $(PORT) $(A)")
When loading record instances, it says that HI and LO macros are undefined. These are the messages of IOC initialization:
$ ../../bin/cygwin-x86/wbc6600test st.cmd
#!../../bin/cygwin-x86/wbc6600test
###############################################################################
# Set up environment
< envPaths
epicsEnvSet("ARCH","cygwin-x86")
epicsEnvSet("IOC","iocwbc6600test")
epicsEnvSet("TOP","c:/epics/wbc6600")
epicsEnvSet("ASYN","/cygdrive/c/epics/synApps_5_5/support/asyn-4-13")
epicsEnvSet("STREAM","/cygdrive/c/epics/synApps_5_5/support/stream-2-4-1")
epicsEnvSet("EPICS_BASE","/cygdrive/c/epics/base-3-14-11")
epicsEnvSet "STREAM_PROTOCOL_PATH" "/cygdrive/c/epics/wbc6600/db"
###############################################################################
# Allow PV name prefixes and serial port name to be set from the environment
epicsEnvSet "P" "wbc6600"
epicsEnvSet "R" "Test"
epicsEnvSet "TTY" "/dev/ttyS0"
###############################################################################
cd c:/epics/wbc6600
## Register all support components
dbLoadDatabase "dbd/wbc6600test.dbd"
wbc6600test_registerRecordDeviceDriver pdbbase
###############################################################################
# Set up ASYN ports
# drvAsynSerialPortConfigure port ipInfo priority noAutoconnect noProcessEos
drvAsynSerialPortConfigure("L0","/dev/ttyS0",0,0,0)
asynSetOption("L0", -1, "baud", "115200")
asynSetOption("L0", -1, "bits", "8")
asynSetOption("L0", -1, "parity", "none")
asynSetOption("L0", -1, "stop", "1")
asynSetOption("L0", -1, "clocal", "Y")
asynSetOption("L0", -1, "crtscts", "N")
asynOctetSetInputEos("L0", -1, "\n")
asynOctetSetOutputEos("L0", -1, "\n")
asynSetTraceIOMask("L0",-1,0x4)
asynSetTraceMask("L0",-1,0x9)
###############################################################################
## Load record instances
dbLoadRecords("db/devwbc6600.db","P=wbc6600,R=Test,PORT=L0,A=0")
macLib: macro HI is undefined (expanding string field(INP, "@devwbc6600.pro
to c4($(HI),$(LO)) $(PORT) $(A)")
)
macLib: macro LO is undefined (expanding string field(INP, "@devwbc6600.pro
to c4($(HI),$(LO)) $(PORT) $(A)")
)
wbc6600:Test:C4.INP Has unexpanded macro
Can't set "wbc6600:Test:C4.INP" to "@devwbc6600.proto c4($(HI,undefined),$(LO,un
defined)) L0 0"
Error at or before ")" in file "db/devwbc6600.db" line 72
dbLoadRecords("db/asynRecord.db","P=wbc6600Test,R=asyn,PORT=L0,ADDR=-1,OMAX=0,IM
AX=0")
###############################################################################
## Start EPICS
cd c:/epics/wbc6600/iocBoot/iocwbc6600test
iocInit
Starting iocInit
############################################################################
## EPICS R3.14.11 $R3-14-11$ $2009/08/28 18:47:36$
## EPICS Base built Jul 30 2010
############################################################################
2010/09/15 11:02:29.743 _main_ wbc6600:Test:C4: Empty link. Forgot the leading '
@' or confused INP with OUT ?
2010/09/15 11:02:29.745 _main_ wbc6600:Test:C4: Record initialization failed
iocRun: All initialization complete
-----Mensaje original-----
De: Dirk Zimoch [mailto:[email protected]]
Enviado el: martes, 14 de septiembre de 2010 15:36
Para: Gorka Ronda
CC: [email protected]
Asunto: Re: Stream Device With Parameters
Hi Gorka,
Please use the subject line. Otherwise your request may be ignored.
You can use protocol(param1,param2...) with up to 9 parameters (which
must neither contain space nor comma at the moment, sorry). No space
allowed before ( or inside ( and ).
The parameters appear as $1 ... $9 in the protocol. (Within quotes the $
must be escaped: "\$1" ... "\$9".)
I would write your example as follows:
field(INP, "@devwbc6600.proto c4(0x04,0x57) $(PORT) $(A)")
c4 {
out 0xc0 0x04 0xfb $2 $1 0x00 0x00 0x00 0x00 "%<xor>";
...
}
You probably want to use macros for LO and HI:
field(INP, "@devwbc6600.proto c4($(LO),$(HI)) $(PORT) $(A)")
LO and HI may as well be specified in decimal here if you like.
By the way, instead of "c4" I would also give the protocol a name that
someone who is not an expert in the wbc6600 (?) can understand.
Gorka Ronda wrote:
Hello everyone,
Using streamDevice, How can I run the command dbtr like a function with
parameters? Something like:
Function (parameter 1, parameter 2)
How do I have to write the protocol and record? There are currently as
follows:
HI = \x04;
LO = \x57;
cmd4 = \xC0\x04\xFB${HI}${LO}\x00\x00\x00\x00%<xor>;
c4 {
out "\$cmd4";
in "%*4r";
}
record(bi, "$(P):$(R):C4")
{
field(DESC, "Command 4")
field(DTYP, "stream")
field(INP, "@devwbc6600.proto c4 $(PORT) $(A)")
}
What I want is not to specify the values of the variables HI and LO in
the archive .proto. I want to give them values when I call the command
dbtr (another command to process the records?), to give these variables
the hexadecimal value I want, each time I run the command.
Thanks in advance,
Gorka