Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

putScalarArray fails for numbers > 6 digits #58

Closed
jsparger opened this issue Jun 11, 2020 · 5 comments
Closed

putScalarArray fails for numbers > 6 digits #58

jsparger opened this issue Jun 11, 2020 · 5 comments

Comments

@jsparger
Copy link

jsparger commented Jun 11, 2020

Hi. I am unable to put an array where any value contains a string longer than 6 digits using the method Channel::putScalarArray. However, pvput works fine on the command line.

I also tried constructing a PvScalarArray of type ULONG, but a pvaccess.PvScalarArray is not accepted by Channel::putScalarArray.

Below are the database I used and the commands which can be run to reproduce the error. I am using pvapy 2.2

(dgro_asub) jsparger@spectre:dgro_asub$ pip freeze | grep pvapy
pvapy==2.2.0
record(waveform, "Addresses")
{
    field(DESC, "Addresses")
    field(FTVL, "ULONG")
    field(NELM, "3")
}
In [1]: import pvaccess                                                                              

In [2]: c = pvaccess.Channel("Addresses")                                                            

In [3]: print(c.get())                                                                               
epics:nt/NTScalarArray:1.0 
    uint[] value [123456]
    alarm_t alarm
        int severity 0
        int status 0
        string message NO_ALARM
    time_t timeStamp
        long secondsPastEpoch 1591882692
        int nanoseconds 459499857
        int userTag 0
    structure display
        double limitLow 0
        double limitHigh 0
        string description Addresses
        string units 
        int precision 0
        enum_t form
            int index 0
            string[] choices ["Default", "String", "Binary", "Decimal", "Hex", "Exponential", "Engineering"]
    control_t control
        double limitLow 0
        double limitHigh 0
        double minStep 0
    valueAlarm_t valueAlarm
        boolean active false
        double lowAlarmLimit nan
        double lowWarningLimit nan
        double highWarningLimit nan
        double highAlarmLimit nan
        int lowAlarmSeverity 0
        int lowWarningSeverity 0
        int highWarningSeverity 0
        int highAlarmSeverity 0
        byte hysteresis 0


In [4]: c.putScalarArray([123456])                                                                   

In [5]: c.get()["value"]                                                                             
Out[5]: array([123456], dtype=uint32)

In [6]: c.putScalarArray([1234567])                                                                  
---------------------------------------------------------------------------
PvaException                              Traceback (most recent call last)
<ipython-input-6-4152885d1ebd> in <module>
----> 1 c.putScalarArray([1234567])

PvaException: parseToPOD: Extraneous characters

In [7]: quit()         
                                                                              
(dgro_asub) jsparger@spectre:dgro_asub$ pvput Addresses [1234567]
Old : 2020-06-11 15:39:19.060  [123456]
New : 2020-06-11 15:43:26.610  [1234567]
@sveseli
Copy link
Collaborator

sveseli commented Jun 11, 2020

Thanks for sending this, I did reproduce the problem on my end.

@sveseli
Copy link
Collaborator

sveseli commented Jun 11, 2020

As a temporary workaround, this should work:

bluegill2> python -c "from pvaccess import *; c = Channel('Addresses'); c.put([1]); pv = c.get(); print(pv['value']); pv.setScalarArray([1234567890]); c.put(pv); pv2=c.get(); print(pv2['value'])"
[1]
[1234567890]

@jsparger
Copy link
Author

This works. Thanks @sveseli.

@jsparger
Copy link
Author

For anyone who finds this between now and the fix, the first put is not necessary, it was just to show how it works. Just getting a pv object and using it to set the value is enough.

In [1]: import pvaccess                                                                                                                                                               

In [2]: c = pvaccess.Channel("Addresses")                                                                                                                                             

In [3]: pv = c.get()                                                                                                                                                                  

In [4]: pv.setScalarArray([123456789])                                                                                                                                                

In [5]: c.put(pv)                                                                                                                                                                     

In [6]: c.get()['value']                                                                                                                                                              
Out[6]: array([123456789], dtype=uint32)

@sveseli
Copy link
Collaborator

sveseli commented Jun 16, 2020

This issue is resolved in release 2.3.0.

@sveseli sveseli closed this as completed Jun 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants