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  <20202021  2022  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  <20202021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: How to write a soft record with a constant long string value
From: "Johnson, Andrew N. via Tech-talk" <tech-talk at aps.anl.gov>
To: "Cobb, Tom (DLSLtd,RAL,LSCI)" <tom.cobb at diamond.ac.uk>
Cc: EPICS tech-talk <tech-talk at aps.anl.gov>
Date: Wed, 19 Aug 2020 18:03:19 +0000
Hi Tom,

On Aug 19, 2020, at 7:18 AM, Cobb, Tom (DLSLtd,RAL,LSCI) <tom.cobb at diamond.ac.uk> wrote:

Thanks for the suggestion, I made waveform device support:


It seems to work, apart from one issue: escaped quotes appear in the info as unescaped quotes:
$ cat info.db 
record(waveform, TEST) {
  info(json, {"this": "has \"quotes\" in"})
}
$ softIoc -d info.db
...
epics> dbli TEST info(json, "{"this":"has "quotes" in"}")
When I use dbGetInfo to get the string, it appears the same as dbli shows. 

Is this a bug, or is there a different way of escaping quotes?

Ahh yes, we have a known issue with the parser escaping JSON when it shouldn’t that will be fixed when my JSON-5 PR gets merged, hopefully in the next release. I can send you a short patch for Base, or you should be able to do either of these instead (your JSON parser should understand \u0022 as a double-quote:

woz$ cat ~/db/test.db 
record(lsi, "json") {
  info(json, {"this": "has \\\"quotes\\u0022 in"})
}

woz$ bin/darwin-x86/softIoc -d ~/db/test.db 
...
epics> dbli
json info(json, "{"this":"has \"quotes\u0022 in"}")

- Andrew



From: Johnson, Andrew N. <anj at anl.gov>
Sent: 18 August 2020 16:45
To: Cobb, Tom (DLSLtd,RAL,LSCI) <tom.cobb at diamond.ac.uk>
Cc: EPICS tech-talk <tech-talk at aps.anl.gov>
Subject: Re: How to write a soft record with a constant long string value
 
Hi Tom,

On Aug 18, 2020, at 4:04 AM, Cobb, Tom (DLSLtd,RAL,LSCI) via Tech-talk <tech-talk at aps.anl.gov> wrote:

I would like to write a database file with a single record that holds a constant chunk of JSON (generated by a script at IOC build time). I would prefer to do this by writing the JSON into the database file itself, rather than having to use a separate file, or dbpf.

Does anyone know if this is possible?

You can load arbitrary JSON into a record info tag, but not directly into any other field type at the moment. It should be relatively easy to write device support or an aSub subroutine to copy the contents of an info tag into a long string field though:

woz$ cat ~/db/test.db 
record(lsi, "json") {
  info(json, {"this": ["is", "json"], # Comments,
    # spaces and newlines are stripped.
    "does": ["this", "help?"]})
}
woz$ bin/darwin-x86/softIoc -d ~/db/test.db 
dbLoadDatabase("/Users/anj/Software/epics/base-7.0/bin/darwin-x86/../../dbd/softIoc.dbd")
softIoc_registerRecordDeviceDriver(pdbbase)
dbLoadRecords("/Users/anj/db/test.db")
iocInit()
Starting iocInit
############################################################################
## EPICS R7.0.4.1-rc1-DEV
## Rev. R7.0.4.1-rc1-14-ga808e3c7900b79f22eb5-dirty
############################################################################
iocRun: All initialization complete
epics> dbli
json info(json, "{"this":["is","json"],"does":["this","help?"]}")

HTH,

- Andrew


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

 

-- 
This e-mail and any attachments may contain confidential, copyright and or privileged material, and are for the use of the intended addressee only. If you are not the intended addressee or an authorised recipient of the addressee please notify us of receipt by returning the e-mail and do not use, copy, retain, distribute or disclose the information in or attached to the e-mail.
Any opinions expressed within this e-mail are those of the individual and not necessarily of 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

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


References:
How to write a soft record with a constant long string value Cobb, Tom (DLSLtd,RAL,LSCI) via Tech-talk
Re: How to write a soft record with a constant long string value Johnson, Andrew N. via Tech-talk
Re: How to write a soft record with a constant long string value Cobb, Tom (DLSLtd,RAL,LSCI) via Tech-talk

Navigate by Date:
Prev: Re: ADViewers: EPICS_NTNDA_VIEWER' does not connect - ADViewers Gofron, Kazimierz via Tech-talk
Next: Re: ADViewers: EPICS_NTNDA_VIEWER' does not connect - ADViewers Mark Rivers 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  <20202021  2022  2023  2024 
Navigate by Thread:
Prev: Re: How to write a soft record with a constant long string value Cobb, Tom (DLSLtd,RAL,LSCI) via Tech-talk
Next: EPICS7 and Python Juan F. Esteban Müller 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  <20202021  2022  2023  2024 
ANJ, 19 Aug 2020 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·