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  2018  2019  2020  2021  2022  2023  2024  <2025 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  <2025
<== Date ==> <== Thread ==>

Subject: Re: Question about getting hexadecimal data with StreamDevice
From: Mark Rivers via Tech-talk <tech-talk at aps.anl.gov>
To: "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov>, cxy <ycx810212 at 163.com>
Date: Thu, 19 Jun 2025 14:33:14 +0000
Hi Kevin,

I think this format is your problem:

    in "\x5A\xA5\x03\x06%(A)2x%(B)2x"

The device is sending you binary data, not ASCII encoded data.  %2x is the format you would use if the device were sending the data as ASCII characters for a hex number.

I think you need to change the format to:

    in "\x5A\xA5\x03\x06%(A)01r%(B)01r"

The "r" format is for "raw" data.


Mark




From: Tech-talk <tech-talk-bounces at aps.anl.gov> on behalf of cxy via Tech-talk <tech-talk at aps.anl.gov>
Sent: Thursday, June 19, 2025 6:44 AM
To: tech-talk at aps.anl.gov <tech-talk at aps.anl.gov>
Subject: Question about getting hexadecimal data with StreamDevice
 

Hello, everyone:

I have a current-readout  device,  communicate with RS232, baud rate 115200, 8 bits data, 1 bit stop, no parity.


When send "\x5A\xA5\x55\x00", it should return data as "5A A5 XX YY ZZ ZZ",  such as"\x5a\xa5\x03\x06\x7f\xe8", and we can get current data from "ZZ ZZ".


The Device provids these simple information above. With a serial port assistent on Windows, we can get all the data correctly.

For example, send "5A A5 55 00" as hexadecimal data, get "5a a5 03 06 7f 07", also as hexadecimal data.

Now I use EPICS StreamDevice to connect the device, communication is correct, I want to save return dada to a record A and another record B. But I can not get right return data.
Here attached the details. Does anyone know why? What's the problem here? How can I get all the returned data "ZZ ZZ" to two PVs such as A and B?  
Hope for your advice, thank you very much.


1. Use the ai record (A,B,C,D) to receive returned data, with record and proto file  like this:

record(ai, "data")

{

     field(DTYP, "stream")

     field(INP, "@wcm.proto  readdata  wcm")

     field(SCAN, "1 second")

}


wcm.proto:

OutTerminator=CR LF;

InTerminator=CR LF;

readdata{

    out "\x5A\xA5\x55\x00";      #it shows wrong if ther is a space " " between 5A and A5.

    in "\x5A\xA5\x03\x06%(A)2x%(B)2x"

}

I think I should get A=7f, B=07.

But, the executing result:

Then I try to use string type to get all the turned back data, it seems I can not do that.

2. Use string record (A, B,C,D)to receive returned data:


record(stringin, "data")

{

     field(DTYP, "stream")

     field(INP, "@wcm.proto  readdata  wcm")

     field(SCAN, "1 second")

}


wcm.proto:

OutTerminator=CR LF;

InTerminator=CR LF;

readdata{

    out "\x5A\xA5\x55\x00";

    in "\x5A\xA5%(A)28c"

}


 Executing result:

   3. Use string record (A, B,C,D)to receive returned data:


record(stringin, "data")

{

     field(DTYP, "stream")

     field(INP, "@wcm.proto  readdata  wcm")

     field(SCAN, "1 second")

}

wcm.proto:

OutTerminator=CR LF;

InTerminator=CR LF;

readdata{

    out "\x5A\xA5\x55\x00";

    in "%s"

}

 Executing result (The same as last one):


Look forward to your advice. Thank you again.

Best wishes,

Kevin

6/19/2025



References:
Question about getting hexadecimal data with StreamDevice cxy via Tech-talk

Navigate by Date:
Prev: RE: Failed to integrate Archiver Appliance with Phoebus Sky Brewer via Tech-talk
Next: Channel Finder Recsync Server issue hanr shayi via Tech-talk
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  <2025
Navigate by Thread:
Prev: Question about getting hexadecimal data with StreamDevice cxy via Tech-talk
Next: Channel Finder Recsync Server issue hanr shayi via Tech-talk
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  <2025
ANJ, 19 Jun 2025 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions ·
· Download · Search · IRMIS · Talk · Documents · Links · Licensing ·