EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  <20182019  2020  2021  2022  2023  2024  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  <20182019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: using stream -calcout
From: Ralph Lange <[email protected]>
To: EPICS Tech Talk <[email protected]>
Date: Fri, 16 Feb 2018 13:30:58 +0100
Hello Li Xing,

Your statements and your protocol file are not consistent.

For the output, your statement seems to say that you send 8 bytes, and your 'out' string in the protocol is indeed sending 8 bytes.
For the returned data, your statement seems to say that you expect 7 bytes, however, the 'in' part of your protocol is trying to receive 14 bytes (characters).

Following your statement (receive 7 bytes), please try using a single record (longin or ai record, depending on desired conversion into a double; no calc needed) and an 'in' part that reads "raw" bytes. Do something like

    out "\xFE\x04\x00\x00\x00\x01\x25\xC5";
    in "%*3r%02r%*2r"

(ignore 3 bytes, read 2 unsigned bytes as big endian, ignore 2 bytes)

If parts of the returned message are fixed, include them in your in format.
E.g., if the return always starts with "FE 04", your in format could be "\xFE\x04%*1r%02r%*2r". This increases robustness, because if the communication gets out of sync, the protocol will not blindly decode bytes at the wrong position.

Cheers,
~Ralph


On Fri, Feb 16, 2018 at 11:27 AM, l123173 <[email protected]> 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.

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";
}

References:
using stream -calcout l123173

Navigate by Date:
Prev: Re: using stream -calcout Mooney, Tim M.
Next: ADSupport compilation problem due to GraphicsMagick Malformed UTF-8 character(s) Gofron, Kazimierz
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  <20182019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: using stream -calcout Mooney, Tim M.
Next: Re: using stream -calcout 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  <20182019  2020  2021  2022  2023  2024 
ANJ, 19 Feb 2018 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·