def import_from_node(node_id, network):
# Create temporary SDO client
sdo_client = SdoClient(0x600 + node_id, 0x580 + node_id, None)
sdo_client.network = network
# Subscribe to SDO responses
network.subscribe(0x580 + node_id, sdo_client.on_response)
# Create file like object for Store EDS variable
try:
eds_fp = ReadableStream(sdo_client, 0x1021)
eds_fp = io.BufferedReader(eds_fp)
eds_fp = io.TextIOWrapper(eds_fp, "ascii")
od = import_eds(eds_fp, node_id)
except Exception as e:
logger.error("No object dictionary could be loaded for node %d: %s",
node_id, e)
od = None
finally:
network.unsubscribe(0x580 + node_id)
return od
评论列表
文章目录