Skip to content

OPC-N2 remains stuck in a infinite wait - advices #73

Description

@teokino

Hello to all,

thanks to your suggestions I have carried out continuous monitoring using OPC-N2. For two months the data were collected without any kind of problem.

Recently I realized that for 10 days, the code execution was blocked pending data. The connection had been established but the execution is stuck at values_PM = alpha.pm (). Once the process was killed and restarted again, everything came back to work.

I would like to ask for advice on how to proceed. In your opinion, is it the case of working with threads? Having available the timing related to the last data collected, I can compare it with the current timing. In case the difference is higher than a certain threshold I could re-launch the command in a new thread.

In your opinion, is the right way to operate?
Below is an extract of the code used

def get_data_points(alpha):
    
    #alpha = opc.OPCN2(spi)
    
    print('->'+str(alpha))
    
    
    while alpha is None:
        time.sleep(10)
        try:
            # connect
            alpha = opc.OPCN2(spi)
        except:
            print('--> errore connesione OPC-N2')
            pass
    
    print('->'+str(alpha))
    values_PM = alpha.pm()
    
    value_PM1 = values_PM['PM1']
    value_PM2_5 = values_PM['PM2.5']
    value_PM10 = values_PM['PM10']
    
    if value_PM1==0 and value_PM2_5==0 and value_PM10==0:
        values_PM = alpha.pm()
        value_PM1 = values_PM['PM1']
        value_PM2_5 = values_PM['PM2.5']
        value_PM10 = values_PM['PM10']

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions