Skip to content

network disconnect - leads to unresolvable exception loop #90

@QuadCorei8085

Description

@QuadCorei8085

network.py Network.disconnect() functions calls the bus.shutdown() then dumps the bus instance (assigns None).

The problem is that in case a PCAN error happens (e.g. you disconnect the bus - but you would like to be robust against disconnected bus) then notifier thread will throw a PcanError exception, in case you would like your code to recover from this situation this could be done like:

while True:
  try:
      print node.sdo['item']['subitem'].raw
  except:
      network.bus.reset()
      network.disconnect()
      network.connect(....)

The problem with this is that if your bus interruption takes longer than the bus reset, reconnect then the connect will fail without exception and in the next cycle the bus.reset() will report "None" type object has no member reset.

Currently my only workaround is:

while True:
  try:
      print node.sdo['item']['subitem'].raw
  except:
      try:
        network.bus.reset()
      except:
       pass

      try:
        network.disconnect()
      except:
       pass

      try:
        network.connect(....)
      except:
       pass

I also tried to just reset the bus using network.bus.reset() but I was not able to (although with PCAN-View it is possible to bring out the device from the

Bus error: an error counter reached the 'heavy'/'warning' limit

I personally would remove either the python self.bus = None or make it part of the connect() function that in case the item exists we could either throw an exception or just simply replace it with the new instace.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions