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

Subject: Re: combining long strings
From: "Johnson, Andrew N. via Tech-talk" <tech-talk at aps.anl.gov>
To: "Sintschuk, Michael" <michael.sintschuk at bam.de>
Cc: EPICS tech-talk <tech-talk at aps.anl.gov>
Date: Thu, 11 Feb 2021 18:09:23 +0000
Hi Michael,

I have just thought of another solution for combining longs strings that works with the built-in record types. I should have suggested this when you first asked, sorry!

I added a new record type in Base-3.15 called the printf record which can handle long strings. This should do what you want:

record(printf, "$(exp):FilePath") {
    field(SIZV, 256)
    field(FMT, "%ls%ls%ls%ls%ls")
    field(INP0, "$(exp):PathMenu.VAL$ CP")
    field(INP1, "$(exp):DateMenu.VAL$ CP")
    field(INP2, "$(exp):SampleMenu.VAL$ CP")
    field(INP3, "$(exp):OrientationMenu.VAL$ CP")
    field(INP4, "$(exp):EnergyMenu.VAL$ CP")
    field(OUT, "$(cam):$(format)1:FilePath")
}

Note that those input links use the $ field modifier to transport long strings over CA, which you are doing by using the CP flag. If those aren’t long strings you can change the associated format string part from %ls to %s and don’t use the $ field modifier. You can add literals or pull other value types by changing the format string.

- Andrew


On Feb 11, 2021, at 11:10 AM, Sintschuk, Michael <michael.sintschuk at bam.de> wrote:

Hello Keenan,
 
>Is the error every time you attempt to set a value or does it just pop up at IOC start?
It is on IOC start. When I change the string values in the mbbo-records, nothing happens. No new error messages appear, the luascript record stays the same. I cant even trigger it in the console:
 
epics> dbtr Topo:FilePath
record active
 
From “dbpr Topo:FilePath 10” I see, that
 
TIME: <undefined>
NSTA: LINK
ERR: 1: attempt to concatenate a nil value (global 'AA')
 
Basically the same status like I posted on Wed, 3 Feb 2021 14:05:49 +0000.
 
 
 
Von: Lang, Keenan C. <klang at anl.gov> 
Gesendet: Donnerstag, 4. Februar 2021 21:26
An: Sintschuk, Michael <michael.sintschuk at bam.de>; Johnson, Andrew N. <anj at anl.gov>
Cc: tech-talk at aps.anl.gov
Betreff: Re: combining long strings
 
Michael,
 
Is the error every time you attempt to set a value or does it just pop up at IOC start?
 
It looks like having multiple CP links can process the record while at least one of the links isn't fully connected. Since the link isn't connected, the field for that value reports a nil value which causes the error when it attempts to concatenate. I need to look into the behavior and coding of the calc-style records and see how they behave and what I'm doing wrong, but once all the CP links are connected, the record does correctly grab the string value rather than the index value. If that weren't the case you wouldn't be getting an error, you'd just be getting a string with a number in the middle instead of the text you wanted.
 
 
Keenan

From: Sintschuk, Michael <michael.sintschuk at bam.de>
Sent: Thursday, February 4, 2021 4:14 AM
To: Lang, Keenan C. <klang at anl.gov>; Johnson, Andrew N. <anj at anl.gov>
Cc: tech-talk at aps.anl.gov <tech-talk at aps.anl.gov>
Subject: AW: combining long strings
 
Hello Andrew, Keenan,
 
I pulled now the recent luascript-master and rebuild the module/IOC. Now I get the following error:
 
Calling return table.pack(string.byte(AA..CC, 1, -1)) resulted in error: 1: attempt to concatenate a nil value (global 'AA')
 
I think, it tries to concatenate the index-value of the mbbo-record and not the string-value. If I write my template like this:
 
record(luascript,"$(exp):FilePath") {
  field(INAA,"$(exp):PathMenu.ZRST CP")
  field(INCC,"$(exp):SampleMenu.ZRST CP")
  field(CODE,"return table.pack(string.byte(AA..CC, 1, -1))")
  field(OUT,"$(cam):$(format)1:FilePath PP")}
 
It concatenates and puts the string correctly, without errors. But this way I always look at the same string…
 
Von: Lang, Keenan C. <klang at anl.gov> 
Gesendet: Donnerstag, 4. Februar 2021 01:31
An: Johnson, Andrew N. <anj at anl.gov>
Cc: Sintschuk, Michael <michael.sintschuk at bam.de>; tech-talk at aps.anl.gov
Betreff: Re: combining long strings
 
Andrew,
 
I wasn't before, but I have now changed the errLog function to also write out using errlogPrintf.
 
 
Keenan

From: Johnson, Andrew N. <anj at anl.gov>
Sent: Wednesday, February 3, 2021 12:33 PM
To: Lang, Keenan C. <
klang at anl.gov>
Cc: Sintschuk, Michael <
michael.sintschuk at bam.de>; tech-talk at aps.anl.gov <tech-talk at aps.anl.gov>
Subject: Re: combining long strings
 
Hi Keenan,
 
On Feb 3, 2021, at 12:05 PM, Lang, Keenan C. <klang at anl.gov> wrote:
 
The ERR field has an error in it, so the record did try to process, it just never successfully completed. I haven't seen that error before, but it appears that it points to some sort of issue with invalid memory access during the code execution. I'm trying to track down what went wrong.
 
Thanks for correcting me, I didn’t notice that PACT was still 1.
 
Does it also log lua errors using errlogPrintf() or an equivalent? I would want the IOC's error log to have a record of this kind of problem, and to not have to monitor the ERR fields of all the lua records.
 
- Andrew
 

 

From: Johnson, Andrew N. <anj at anl.gov>
Sent: Wednesday, February 3, 2021 12:01 PM
To: Sintschuk, Michael <
michael.sintschuk at bam.de>
Cc: Lang, Keenan C. <
klang at anl.gov>; tech-talk at aps.anl.gov <tech-talk at aps.anl.gov>
Subject: Re: combining long strings
 
Hi Michael,
 
On Feb 3, 2021, at 8:05 AM, Sintschuk, Michael via Tech-talk <tech-talk at aps.anl.gov> wrote:
 
I like the luascript script solution. But unfortunately it won’t work for me. The record is always in SEVR: invalid mode and there is no input to the AA, BB … fields:
 
...
PINI: NO            PJ: 0               PJJ: 0x88d770       PPN: (nil)         
PPNR: (nil)         PREC: 0             PRIO: LOW           PROC: 0             
PSVL:               PUTF: 0             PVAL: 0             RDES: 0x80c5f0     
RELO: Every New File                    RPRO: 0             RPVT: 0x88d570     
RSET: 0x7f8e4c1d9e40                    SCAN: Passive       SDIS:CONSTANT      
SEVR: INVALID       SPVT: (nil)         STAT: UDF           STATE: 0x88d7a8    
SVAL:               SYNC: Sync          TIME: <undefined>   TPRO: 0            
TSE: 0              TSEL:CONSTANT       UDF: 1              UDFS: INVALID      
VAL: 0              WAIT: NoWait       
epics>
 
Did I missed something with the record settings?
 
Your record doesn’t appear to have been processed at all yet (STAT is UDF, UDF is 1 and TIME is <undefined>). Does processing it change the result? You can have that happen automatically when the IOC boots by setting PINI to YES, or manually with this iocsh command:
 
dbpf Topo:FilePath.PROC 1
 
- Andrew
 
-- 
Complexity comes for free, simplicity you have to work for.
 
-- 
Complexity comes for free, simplicity you have to work for.

-- 
Complexity comes for free, simplicity you have to work for.


Replies:
AW: combining long strings Sintschuk, Michael via Tech-talk
References:
combining long strings Sintschuk, Michael via Tech-talk
Re: combining long strings Lang, Keenan C. via Tech-talk
AW: combining long strings Sintschuk, Michael via Tech-talk
Re: combining long strings Johnson, Andrew N. via Tech-talk
Re: combining long strings Lang, Keenan C. via Tech-talk
Re: combining long strings Johnson, Andrew N. via Tech-talk
Re: combining long strings Lang, Keenan C. via Tech-talk
AW: combining long strings Sintschuk, Michael via Tech-talk
Re: combining long strings Lang, Keenan C. via Tech-talk
AW: combining long strings Sintschuk, Michael via Tech-talk

Navigate by Date:
Prev: AW: combining long strings Sintschuk, Michael via Tech-talk
Next: AW: combining long strings Sintschuk, Michael 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  <20212022  2023  2024 
Navigate by Thread:
Prev: AW: combining long strings Sintschuk, Michael via Tech-talk
Next: AW: combining long strings Sintschuk, Michael 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  <20212022  2023  2024 
ANJ, 12 Feb 2021 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·