pysoem icon indicating copy to clipboard operation
pysoem copied to clipboard

Retrieval of Assigned Name SDO returns different bytes every try

Open njoye opened this issue 2 years ago • 3 comments

Hi!

I've used the following code to retrieve the "Assigned Name" of a Synapticon Motor Controller. Sadly I always get a different result when I retrieve the data (only once was I able to actually decode the name and get the correct answer). When executed, I usually get a UnicodeDecodeError. The decoding doesn't seem to be the actual issue as the encoding provided by the company (ASCII) did work once and works with lower-level approaches (namely Igh and TwinCAT) of EtherCAT masters. However I am wondering why I get different results every time I try to load the data - is this a bug in the software? Maybe with how I set up my hardware (I communicate with other devices on the same interface - is this an issue)? I thank you for any help you can give me already!

The code that shows my problem:

import pysoem

def find_devices(ifname):
        master = pysoem.Master()
        master.open(ifname)

        if master.config_init() > 0:
                for device in master.slaves:
                        print("Found device " + str(device.name))
                         # The below call ('decode') makes it crash as sdo_read returns different values every time
                        device_name = device.sdo_read(0x20F2, 0).decode('ascii') 
                        print("Device name is " + str(device_name))
        else:
                print("No device found")

        devices = master.slaves
        master.close()
        return devices

if __name__ == "__main__":
        find_devices("enp8s0")

njoye avatar Apr 29 '22 14:04 njoye

Hi, What do you mean with "I communicate with other devices on the same interface"? On the Ethernet port you are using, there should only be EtherCAT device connected.

bnjmnp avatar Apr 30 '22 10:04 bnjmnp

Thanks @bnjmnp - after doing my own research I came to the same conclusion myself. I'll talk to our electrical engineer and make sure that the electrical wiring is correct. Once that is done and if that fix resolves this issue I will close it. Thanks again!

njoye avatar May 02 '22 08:05 njoye

The wiring is correct now, but my issues with reading the data persists. This was also confirmed by a developer at Synapticon who had the same problem with the script that I provided above.

njoye avatar May 11 '22 07:05 njoye