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: | Question about getting hexadecimal data with StreamDevice |
From: | cxy via Tech-talk <tech-talk at aps.anl.gov> |
To: | tech-talk at aps.anl.gov |
Date: | Thu, 19 Jun 2025 19:44:26 +0800 (CST) |
Hello, everyone:
I have a current-readout device, communicate with RS232, baud rate 115200, 8 bits data, 1 bit stop, no parity.
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.record(ai, "data")
{
field(DTYP, "stream")
field(INP, "@wcm.proto readdata wcm")
field(SCAN, "1 second")
}
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:
{
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:
{
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