bnjmnp / pysoem

Cython wrapper for the Simple Open EtherCAT Master Library
MIT License
97 stars 38 forks source link

Troubles by decoding sdo_read #103

Closed jonnYyYyYy closed 1 year ago

jonnYyYyYy commented 1 year ago

Hi, I like to read data from an Index of an SEW etherCAT slave, but I have some troubles by decoding.

import pysoem master = pysoem.Master() master.open(r'\Device\XXXXXXXXXXXXXX') if master.config_init() > 0: for device in master.slaves: print(f'Found Device {device.name}') else: print('no device found') print(master.config_map)

print(test)

device_name = device.sdo_read(0x1008, 0) print(device_name) master.close()

But then I get the following output:

b'0\xb8\xe6je\x02\x00\x00\xa7vyJ\xf9\x7f\x00\x00*\x92Y)\xff\x0f\x00\x000\xb8\xe6je\x02\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\xba7\x8fje\x02\x00\x00@$\xe5je\x02\x00\x00$\xe5je\x02\x00\x00\xba7\x8fje\x02\x00\x00\xc8|\xb5J\xf9\x7f\x00\x00\xf8\x93\xccJ\xf9\x7f\x00\x00\xf8\x93\xccJ\xf9\x7f\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x9cHxJ\xf9\x7f\x00\x00y\xceJ\xf9\x7f\x00\x000\xb8\xe6je\x02\x00\x000\xb8\xe6je\x02\x00\x00\xf2\xa5{J\xf9\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf8\xd5\xccJ\xf9\x7f\x00\x00`y\xceJ\xf9\x7f\x00\x00\xf8\x93\xccJ\xf9\x7f\x00\x00(\xf3\xcbJ\xf9\x7f\x00\x00j\xa2{J\xf9\x7f\x00\x000\xb8\xe6je\x02\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\xf8\x93\xccJ\xf9\x7f\x00\x00\x00\xfe\xb7je\x02\x00\x00\x96\x9a{J\xf9\x7f\x00\x00\xf8\x93\xccJ\xf9\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

If I try to decode it, using utf-8, the following error occurs: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb8 in position 1: invalid start byte

Can someone show me where my mistake is?