Hello Li Xing,
I suggest to use a numeric record to receive the numbers, either longin
if you want the integer or ai if you want to convert (scale) the integer
to a double.
For clarifications: Do you send "\xFE\x04\x00\x00\x00\x01\x25\xC5" (8
bytes) or " fe 04 00 00 00 01 25 c5 " (string with 25 chars coding for 8
hex numbers)?
From your protocol I assume that you have 8 raw bytes, not a hex string.
To read 2 raw bytes as an integer use "%2r" (big endian signed) or
"%02r" (big endian unsigned), "%#2r" (little endian signed) or "%#02r"
(little endian unsigned). I assume big endian unsigned for now.
record(longin, "TEM") {
field(DESC, "test for upstairs tcpip")
field(DTYP, "stream")
field(INP, "@devtemp.proto get_high $(PORT) $(A)")
}
get_tem {
MaxInput = 7;
out "\xFE\x04\x00\x00\x00\x01\x25\xC5";
in 0xfe 0x04 0x02 "%02r" 0xae 0x22;
}
This should give you 1032.
I assuming the input always starts with 0xfe 0x04 0x02 and always ends
with 0xae 0x22. If the last two bytes are some sort of checksum consider
the %<...> formats.
I set MaxInput = 7; to avoid delays from readTimeout because you have no
terminator and seem to have fixed input length of 7 bytes.
Dirk
On 16.02.2018 11:27, l123173 wrote:
Hi all,
I have a simple question about stream.
The device was connected with LAN. If sending " fe 04 00 00 00 01
25 c5 " in Hex, getting " fe 04 02 04 08 ae 22 " in Hex.
Among the getting bytes( " fe 04 02 04 08 ae 22 "), 04 08 was I
wanted. Convert 0408(HEX) to decimal was 1032 (4*16**2 +8=1032), and
1032 was the finall result I wanted.
In my programe, I have successfully sent and got the bytes. But I
could not get the 1032, I want to achieve it using scalcout, but failed.
Could you please give me some suggestion.
The environment I use, base3.14.12.7, synapps_5_8, fedora 27(64).
my db file:
--------------------------------------------
record(stringin, "GET_HIGH")
{
field(DESC, "test for upstairs tcpip")
field(DTYP, "stream")
field(INP, "@devtemp.proto get_high $(PORT) $(A)")
}
record(stringin, "GET_LOW")
{
field(DTYP, "stream")
field(INP, "@devtemp.proto get_low $(PORT) $(A)")
field(SCAN, "I/O Intr")
}
record(scalcout, "TEM")
{
field(DESC, "get the temperature")
field(DTYP, "stream")
field(INPA, "GET_HIGH")
field(INPB, "GET_LOW")
field(CALC, "A*16*16 + B")
}
my proto file:
-------------------------------------------------------
get_high {
out "\xFE\x04\x00\x00\x00\x01\x25\xC5";
in "%*c%*c%*c%*c%*c%*c%c%c%*c%*c%*c%*c%*c%*c";
# in "%s";
}
get_low {
in "%*c%*c%*c%*c%*c%*c%*c%*c%c%c%*c%*c%*c%*c";
}
output of st.cmd: (there is an error "Record "TEM" is of unknown type
"scalcout" )
------------------------------------
#!../../bin/linux-x86_64/temp
## You may have to change temp to something else
## everywhere it appears in this file
< envPaths
epicsEnvSet("ARCH","linux-x86_64")
epicsEnvSet("IOC","ioctemp")
epicsEnvSet("TOP","/home/lyx/tem_setup_with_asyn_scpi")
epicsEnvSet("EPICS_BASE","/opt/epics/base")
epicsEnvSet("ASYN","/opt/epics/synApps_5_8/support/asyn-4-26")
epicsEnvSet("STREAM","/opt/epics/synApps_5_8/support/stream-2-6a")
epicsEnvSet "STREAM_PROTOCOL_PATH" "/home/lyx/tem_setup_with_asyn_scpi/db"
epicsEnvSet "P" "P"
epicsEnvSet "R" "T"
cd "/home/lyx/tem_setup_with_asyn_scpi"
## Register all support components
dbLoadDatabase "dbd/temp.dbd"
temp_registerRecordDeviceDriver pdbbase
drvAsynIPPortConfigure("L0","192.168.215.120:10000",0,0,0)
asynSetTraceIOMask("L0",-1,0x2)
asynSetTraceMask("L0",-1,0x9)
## Load record instances
dbLoadRecords("/home/lyx/tem_setup_with_asyn_scpi/db/devtemp.db","P=P,R=T,PORT=L0,A=0,user=lyxHost")
Record "TEM" is of unknown type "scalcout"
Error at or before ")" in file
"/home/lyx/tem_setup_with_asyn_scpi/db/devtemp.db" line 25
cd "/home/lyx/tem_setup_with_asyn_scpi/iocBoot/ioctemp"
iocInit
Starting iocInit
############################################################################
## EPICS R3.14.12.7
## EPICS Base built Feb 7 2018
############################################################################
Regards,
Li xing
- References:
- using stream -calcout l123173
- Navigate by Date:
- Prev:
RE: Excel DDE to EPICS interface freddie.akeroyd
- Next:
Re: ADSupport compilation problem due to GraphicsMagick Malformed UTF-8 character(s) Andrew Johnson
- 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: using stream -calcout Ralph Lange
- Next:
Re: using stream -calcout l123173
- 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
|