pylogix: Batch reading NoneType AttributeError: 'NoneType' object has no attribute 'group'

Preflight checks

  • Have you tried the examples?
  • Have you tried pylogix-tester?
  • Have you read previous issues?

Type of issue

  • Bug
  • Feature Request
  • Question
  • Other

Delete items that do not apply below.

Description of issue

When reading a batch of variables the batch read fails when a BOOL is included. The first 4 variables in the list are REALS the 5th one is a BOOL. If I read the BOOL alone it works, if I read the bool along with any of the others it fails.

Expected behavior

Expected response with tags and values

Actual behavior

Reading generates Attribute Error NoneType AttributeError: ‘NoneType’ object has no attribute ‘group’

Code

from pylogix import PLC
import time

with PLC() as comm:
    comm.IPAddress = '192.168.1.221'
    tags = comm.GetTagList()
    print(tags.Status)
    if tags.Status == 'Success':
        iris_tags = [ t.TagName for t in tags.Value if 'IRIS' in t.TagName]
        #comm.SetPLCTime()
        plctime = comm.GetPLCTime()
        print(plctime.Value)
        print(iris_tags[4])
        read = True
        while read:
            try:
                ret = comm.Read(iris_tags[:5])
                #print(ret.Value)
                for r in ret:
                    print(r)
                    print()
                time.sleep(1)
            except KeyboardInterrupt:
                print('exiting')
                read = False

Screenshots

image

Stacktrace

Versions

Include versions to

  • pylogix: 7.5
  • python: 3.8.5
  • OS: Ubuntu 20.04

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (5 by maintainers)

Most upvoted comments

@TheFern2 The LgxTag class is only used for GetTagList().

BOOL arrays are the worst. As you discovered @tdesroches, they are not stored in the PLC as BOOL, but 32 bit words. That is the reason why when you create BOOL arrays, you have to create them blocks of 32. You can’t create a BOOL array of 16 for example. When I request BOOL[4] for example, I have to send the request with an index of 0, because bool 4 is in the first DWORD. Think of BOOL arrays as an array of DINT’s and you are using the individual bits.

A few days ago, I realized that I was not handling the index properly for some time. I believe this to be fix in the latest code here on GH, but it has not been put up on pypi. Try the latest code here, the problem should be resolved.

The first 4 tags were a REAL, then a BOOL. I think this is the same issue I fixed the other day.

Can you try the latest code from the repo?