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  <2026 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  <2026
<== Date ==> <== Thread ==>

Subject: Re: Question About Calculating Checksum in a StreamDevice Protocol
From: "Zimoch, Dirk via Tech-talk" <tech-talk at aps.anl.gov>
To: "huishan147 at gmail.com" <huishan147 at gmail.com>, "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov>
Date: Mon, 29 Jun 2026 07:33:27 +0000
Hello Huishan

What exactly do you mean by "hexadecimal format"? It could mean a string like
"3E"  (which is two bytes, 0x33 and 0x45).
But as you wrote the rest of your command as hexadecimal numbers, I assume you
mean something like 2 bytes for example 1E 2F meaning either the number
0x1e2f=7727 (big endian) or 0x2f1e=12062 (little endian).

In case of big endian you need: out 55 AA 05 04 "%.2r%<sum>";
In case you need little endian: out 55 AA 05 04 "%#.2r%<sum>";

See: https://urldefense.us/v3/__https://paulscherrerinstitute.github.io/StreamDevice/formats.html*raw__;Iw!!G_uCfscf7eWS!aqWJFIEKwy7Jzr44rjp81yiD9Alo8KmGHmLA8RqsPyh-zS1Q_BhTbmSRud6CE_brwNhKTvDqOLqHLdMj4LjBH3pAiQ$ 

The "%<sum>" adds all bytes (starting from the 55 and including the value)
https://urldefense.us/v3/__https://paulscherrerinstitute.github.io/StreamDevice/formats.html*chksum__;Iw!!G_uCfscf7eWS!aqWJFIEKwy7Jzr44rjp81yiD9Alo8KmGHmLA8RqsPyh-zS1Q_BhTbmSRud6CE_brwNhKTvDqOLqHLdMj4LhtL5tDyQ$ 

If you use an 'ao' record, the value will be taken from .RVAL, so you can scale
the value from a floating point number if necessary. 
https://urldefense.us/v3/__https://paulscherrerinstitute.github.io/StreamDevice/ao.html__;!!G_uCfscf7eWS!aqWJFIEKwy7Jzr44rjp81yiD9Alo8KmGHmLA8RqsPyh-zS1Q_BhTbmSRud6CE_brwNhKTvDqOLqHLdMj4Lj9jHjoag$ 

If you use a 'longout', it will simply use the .VAL field.

Dirk

On Mon, 2026-06-29 at 12:17 +0800, Huishan via Tech-talk wrote:
> Hello everyone,
>     I have a question about writing a StreamDevice protocol for the following command: 55 AA 05 04 byte1 byte2 byte3.
>     The last three bytes of the command need to change dynamically. The first two bytes represent the current value in hexadecimal format. The third byte is a checksum, which is calculated by adding 0x05, 0x04, byte1, and byte2 using hexadecimal addition.Is there a way to have the checksum calculated automatically in a StreamDevice protocol? If so, what should I use in the protocol file as a placeholder for the calculated value?
>     If StreamDevice doesn't support calculations like this, does that mean I have to calculate the checksum manually every time before sending the command?
>     Any suggestions or examples would be greatly appreciated.Thank you!
>                                                                                                                          Huishan                                                                                                                                      

References:
Question About Calculating Checksum in a StreamDevice Protocol Huishan via Tech-talk

Navigate by Date:
Prev: Re: EPICS support for Fastech motors Torsten Bögershausen via Tech-talk
Next: Bridge PV to REST and WebSocket in Python Wang, Lin 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  <2026
Navigate by Thread:
Prev: Question About Calculating Checksum in a StreamDevice Protocol Huishan via Tech-talk
Next: Bridge PV to REST and WebSocket in Python Wang, Lin 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  <2026
ANJ, 29 Jun 2026 · Home · News · About · Talk · Base · Modules · Extensions ·
· Distributions · Download · Documents · Links · Licensing ·