Hi Gorka,
I probably did not understand completely what you wanted. You want to be
able to use *different* each time the record processed?
If that is the case you have to store the values in some record. For
example in an "ao" record. (There you can even scale it from "user
units" in VAL to integers in RVAL. See "ao" documentation.)
So let's now assume the two values are in stored in $(P):$(R):C4:LO.RVAL
and $(P):$(R):C4:HI.RVAL. Then you can use redirection to access these
values. You have to give the record names (or the common prefix) to the
protocol as a parameter like this:
field(INP, "@devwbc6600.proto c4($(P):$(R):C4) $(PORT) $(A)")
and use the name in $1 for two redirections to fetch LO and HI:
out 0xc0 0x04 0xfb "%(\$1:LO.RVAL)r%(\$1:LO.RVAL)r" 0x00 0x00 0x00 0x00
"%<xor>";
The %r converter just outputs the least significant byte to the
mentioned record field.
It would really help to know what the "C4" command actually does. Can
you give me a link to the device documentation?
Dirk
Gorka Ronda wrote:
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
- Replies:
- Re: Stream Device With Parameters Dirk Zimoch
- References:
- [no subject] Gorka Ronda
- Re: Stream Device With Parameters Dirk Zimoch
- RE: Stream Device With Parameters Gorka Ronda
- Navigate by Date:
- Prev:
RE: Stream Device With Parameters Gorka Ronda
- Next:
Re: Strange gateway error message Dirk Zimoch
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
<2010>
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
RE: Stream Device With Parameters Gorka Ronda
- Next:
Re: Stream Device With Parameters Dirk Zimoch
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
<2010>
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
|