Experimental Physics and Industrial Control System
I am trying to use macLib to do macro substitution in base 3.15.5. It is generally working. However sometimes when there is an undefined macro the return value from macExpandString is not negative when it should be.
This is the code I am using to call macExpandString, with some debugging printf calls. It prints the value returned by macValueExpand, as well as the input and output strings.
// Create a temporary buffer 10 times larger than input buffer
int bufferSize = buffer.length() * 10;
char *tmpBuffer = (char *)malloc(bufferSize);
printf("Calling macExpandString, input length=%d, output buffer size=%d\n", (int)buffer.length(), bufferSize);
status = macExpandString(macHandle, buffer.c_str(), tmpBuffer, bufferSize);
printf("macExpandString returned %d\n", status);
printf("input:\n########\n%s\n########\n\n", buffer.c_str());
printf("output:\n########\n%s\n########\n\n", tmpBuffer);
Here is an example. In this case the CAMERA macro is not defined.
#####################################################################################################################
Calling macExpandString, input length=1013, output buffer size=10130
macLib: macro CAMERA is undefined (expanding string <?xml version="1.0" standalone="no" ?>
<!-- Attributes -->
<Attributes
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../ADCore/XML_schema/NDAttributes.xsd"
>
<Attribute name="AcquireTime" type="EPICS_PV" source="$(CAMERA)AcquireTime" dbrtype="DBR_NATIVE" description="Camera acquire time"/>
<Attribute name="RingCurrent" type="EPICS_PV" source="S:SRcurrentAI" dbrtype="DBR_NATIVE" description="Storage ring current"/>
<Attribute name="RingCurrent_EGU" type="EPICS_PV" source="S:SRcurrentAI.EGU" dbrtype="DBR_NATIVE" description="Storage ring current units"/>
<Attribute name="ID_Energy" type="EPICS_PV" source="$(ID)Energy" dbrtype="DBR_NATIVE" description="Undulator energy"/>
<Attribute name="ID_Energy_EGU" type="EPICS_PV" source="$(ID)Energy.EGU" dbrtype="DBR_NATIVE" description="Undulator energy units"/>
</Attributes>
)
macExpandString returned 1027
input:
########
<?xml version="1.0" standalone="no" ?>
<!-- Attributes -->
<Attributes
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../ADCore/XML_schema/NDAttributes.xsd"
>
<Attribute name="AcquireTime" type="EPICS_PV" source="$(CAMERA)AcquireTime" dbrtype="DBR_NATIVE" description="Camera acquire time"/>
<Attribute name="RingCurrent" type="EPICS_PV" source="S:SRcurrentAI" dbrtype="DBR_NATIVE" description="Storage ring current"/>
<Attribute name="RingCurrent_EGU" type="EPICS_PV" source="S:SRcurrentAI.EGU" dbrtype="DBR_NATIVE" description="Storage ring current units"/>
<Attribute name="ID_Energy" type="EPICS_PV" source="$(ID)Energy" dbrtype="DBR_NATIVE" description="Undulator energy"/>
<Attribute name="ID_Energy_EGU" type="EPICS_PV" source="$(ID)Energy.EGU" dbrtype="DBR_NATIVE" description="Undulator energy units"/>
</Attributes>
########
output:
########
<?xml version="1.0" standalone="no" ?>
<!-- Attributes -->
<Attributes
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../ADCore/XML_schema/NDAttributes.xsd"
>
<Attribute name="AcquireTime" type="EPICS_PV" source="$(CAMERA,undefined)AcquireTime" dbrtype="DBR_NATIVE" description="Camera acquire time"/>
<Attribute name="RingCurrent" type="EPICS_PV" source="S:SRcurrentAI" dbrtype="DBR_NATIVE" description="Storage ring current"/>
<Attribute name="RingCurrent_EGU" type="EPICS_PV" source="S:SRcurrentAI.EGU" dbrtype="DBR_NATIVE" description="Storage ring current units"/>
<Attribute name="ID_Energy" type="EPICS_PV" source="ID13us:Energy" dbrtype="DBR_NATIVE" description="Undulator energy"/>
<Attribute name="ID_Energy_EGU" type="EPICS_PV" source="ID13us:Energy.EGU" dbrtype="DBR_NATIVE" description="Undulator energy units"/>
</Attributes>
########
#####################################################################################################################
Note above that macExpand string is printing an error message as it should. However, it is returning a positive integer 1037, while it should be returning a negative value because there was an undefined macro.
If instead of CAMERA being undefined I don't define ID instead I get this output:
#####################################################################################################################
Calling macExpandString, input length=1013, output buffer size=10130
macLib: macro ID is undefined (expanding string <?xml version="1.0" standalone="no" ?>
<!-- Attributes -->
<Attributes
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../ADCore/XML_schema/NDAttributes.xsd"
>
<Attribute name="AcquireTime" type="EPICS_PV" source="$(CAMERA)AcquireTime" dbrtype="DBR_NATIVE" description="Camera acquire time"/>
<Attribute name="RingCurrent" type="EPICS_PV" source="S:SRcurrentAI" dbrtype="DBR_NATIVE" description="Storage ring current"/>
<Attribute name="RingCurrent_EGU" type="EPICS_PV" source="S:SRcurrentAI.EGU" dbrtype="DBR_NATIVE" description="Storage ring current units"/>
<Attribute name="ID_Energy" type="EPICS_PV" source="$(ID)Energy" dbrtype="DBR_NATIVE" description="Undulator energy"/>
<Attribute name="ID_Energy_EGU" type="EPICS_PV" source="$(ID)Energy.EGU" dbrtype="DBR_NATIVE" description="Undulator energy units"/>
</Attributes>
)
macLib: macro ID is undefined (expanding string <?xml version="1.0" standalone="no" ?>
<!-- Attributes -->
<Attributes
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../ADCore/XML_schema/NDAttributes.xsd"
>
<Attribute name="AcquireTime" type="EPICS_PV" source="$(CAMERA)AcquireTime" dbrtype="DBR_NATIVE" description="Camera acquire time"/>
<Attribute name="RingCurrent" type="EPICS_PV" source="S:SRcurrentAI" dbrtype="DBR_NATIVE" description="Storage ring current"/>
<Attribute name="RingCurrent_EGU" type="EPICS_PV" source="S:SRcurrentAI.EGU" dbrtype="DBR_NATIVE" description="Storage ring current units"/>
<Attribute name="ID_Energy" type="EPICS_PV" source="$(ID)Energy" dbrtype="DBR_NATIVE" description="Undulator energy"/>
<Attribute name="ID_Energy_EGU" type="EPICS_PV" source="$(ID)Energy.EGU" dbrtype="DBR_NATIVE" description="Undulator energy units"/>
</Attributes>
)
macExpandString returned -1036
input:
########
<?xml version="1.0" standalone="no" ?>
<!-- Attributes -->
<Attributes
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../ADCore/XML_schema/NDAttributes.xsd"
>
<Attribute name="AcquireTime" type="EPICS_PV" source="$(CAMERA)AcquireTime" dbrtype="DBR_NATIVE" description="Camera acquire time"/>
<Attribute name="RingCurrent" type="EPICS_PV" source="S:SRcurrentAI" dbrtype="DBR_NATIVE" description="Storage ring current"/>
<Attribute name="RingCurrent_EGU" type="EPICS_PV" source="S:SRcurrentAI.EGU" dbrtype="DBR_NATIVE" description="Storage ring current units"/>
<Attribute name="ID_Energy" type="EPICS_PV" source="$(ID)Energy" dbrtype="DBR_NATIVE" description="Undulator energy"/>
<Attribute name="ID_Energy_EGU" type="EPICS_PV" source="$(ID)Energy.EGU" dbrtype="DBR_NATIVE" description="Undulator energy units"/>
</Attributes>
########
output:
########
<?xml version="1.0" standalone="no" ?>
<!-- Attributes -->
<Attributes
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../ADCore/XML_schema/NDAttributes.xsd"
>
<Attribute name="AcquireTime" type="EPICS_PV" source="13SIM1:cam1:AcquireTime" dbrtype="DBR_NATIVE" description="Camera acquire time"/>
<Attribute name="RingCurrent" type="EPICS_PV" source="S:SRcurrentAI" dbrtype="DBR_NATIVE" description="Storage ring current"/>
<Attribute name="RingCurrent_EGU" type="EPICS_PV" source="S:SRcurrentAI.EGU" dbrtype="DBR_NATIVE" description="Storage ring current units"/>
<Attribute name="ID_Energy" type="EPICS_PV" source="$(ID,undefined)Energy" dbrtype="DBR_NATIVE" description="Undulator energy"/>
<Attribute name="ID_Energy_EGU" type="EPICS_PV" source="$(ID,undefined)Energy.EGU" dbrtype="DBR_NATIVE" description="Undulator energy units"/>
</Attributes>
########
#####################################################################################################################
This is behaving correctly, macExpandString is returning a negative number, -1036 as it should.
Am I doing something wrong or is this a bug?
Thanks,
Mark
- Replies:
- RE: Problem in macLib macExpandString? Mark Rivers
- Navigate by Date:
- Prev:
Re: CAS: partial (damaged?) UDP msg Shen, Guobao
- Next:
RE: Problem in macLib macExpandString? Mark Rivers
- 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
- Navigate by Thread:
- Prev:
Re: CAS: partial (damaged?) UDP msg Shen, Guobao
- Next:
RE: Problem in macLib macExpandString? Mark Rivers
- 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