Troubleshooting Data Reception Issues in a CANopen Service Tool

17 views Asked by At

I'm currently facing challenges in receiving PDO data from a device within a CANopen network. Although the device seems to transmit TPDOs correctly and the mappings in the EDS file appear accurate, my Python script's read function consistently returns zero values for both irrigation and aspiration parameters.

My primary objective is to develop a service tool capable of interfacing with remote nodes in the network to receive data. In this case, my service tool acts as a local node attempting to communicate with a remote device.

Could you please review the relevant portion of my Python script to identify any potential errors or suggest improvements? Thank you!

In the following you can see my actual code:

def readLoop(self):
        """
        Reads PDO Data in a loop
        """
        localNode = self.__connectionController.network[100]
        remoteNode = self.__connectionController.network[self.__nodeId]

        localNode.nmt.state = 'OPERATIONAL'
        remoteNode.nmt.state = 'OPERATIONAL'

        localNode.rpdo.read()
        localNode.tpdo.read()
        localNode.rpdo[1].enabled = True

        cobId = self.__dataModel.getCobId()
        localNode.rpdo[1].cob_id = int(cobId, 16)
        
        interval = 1000 
        localNode.rpdo[1].start(interval)
        
        try:
            while not self.stopRequested:
                irrigationLevel = localNode.rpdo['EH_RefRelativePedalDeflection.Irrigation'].raw
                aspirationRate = localNode.rpdo['EH_RefRelativePedalDeflection.Aspiration'].raw
                print(f"Irrigation Level: {irrigationLevel}, Aspiration Rate: {aspirationRate}")
                time.sleep(interval / 1000)
        except Exception as e:
            print(f"Exception in read loop: {e}")
        finally:
            localNode.rpdo[1].stop()
            print("Read loop stopped.")

I tried everything from Christian Sandberg (Developer of canopen for Python) from GitHub: https://github.com/christiansandberg/canopen But until today the output is still:

Irrigation Level: 0, Aspiration Rate: 0

0

There are 0 answers