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: | Checksum for StreamDevice input with regular expression |
From: | "Baker, Keith \(DLSLtd, RAL, LSCI\) via Tech-talk" <tech-talk at aps.anl.gov> |
To: | "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov> |
Date: | Thu, 8 May 2025 11:08:44 +0000 |
Hello. I am trying to read in a datetime string, format YYMMDDhhmmss, but would prefer it in a more human readable format such as YY-MM-DD hh:mm:ss My protocol file is fine if I just read the string as YYMMDDhhmmss and the checksum passes. Then I can insert the extra characters with a regular _expression_ to give the string I want but the checksum now fails. I am forced to omit the checksum and just ignore extra input. Is this the expect behaviour or might I be doing something wrong? If so, can someone suggest a more elegant solution for the format conversion instead of a regular _expression_, perhaps with an sCalcout record? I’m sure someone will ask for my code so here it is. I’m actually using redirection to put the date and time into two separate records, $1:DATE and $1:TIME. I’ve shown the evolution of my protocol attempts. readTime { out BEL "01ZR \$CS" ETX; # Basic input with no reformatting. # in BEL "01ZR","%(\$1:DATE)6s%(\$1:TIME)6s\$CS" ETX; # Next line works but actually does nothing in the regular _expression_. # in BEL "01ZR","%#/([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/\1\2\3\4\5\6/%(\$1:DATE)6s%(\$1:TIME)6s\$CS" ETX; # Next line gives a checksum error. # in BEL "01ZR","%#/([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/\1:\2:\3\4-\5-\6/%(\$1:DATE)8s%(\$1:TIME)8s\$CS" ETX; # So this is my best solution so far but omitting the checksum. in BEL "01ZR","%#/([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/\1:\2:\3\4-\5-\6/%(\$1:DATE)8s%(\$1:TIME)8s"; ExtraInput = Ignore; #Suspect checksum calculated after regex so will not match input. } If I can get the regular _expression_ to work with a checksum, maybe someone could also suggest a more elegant regular _expression_. Thanks, Keith Baker Diamond Light Source Ltd Diamond Light Source Ltd. cannot guarantee that this e-mail or any attachments are free from viruses and we cannot accept liability for any damage which you may sustain as a result of software viruses which may be transmitted in or with the message. Diamond Light Source Limited (company no. 4375679). Registered in England and Wales with its registered office at Diamond House, Harwell Science and Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United Kingdom. |