Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

following the newly API of CIA402,do some change. #132

Merged
merged 1 commit into from
Jan 3, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions examples/simple_ds402_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
network.check()

# Add some nodes with corresponding Object Dictionaries
node = canopen.Node402(35, '/home/andre/Code/test/jupiter.eds')
node = canopen.BaseNode402(35, '/home/andre/Code/test/jupiter.eds')
network.add_node(node)
# network.add_node(34, '/home/andre/Code/test/jupiter.eds')
# node = network[34]
Expand Down Expand Up @@ -61,7 +61,7 @@
print device_name
print vendor_id

node.powerstate_402.state = 'SWITCH ON DISABLED'
node.state = 'SWITCH ON DISABLED'

print 'node state 4) = {0}'.format(node.nmt.state)

Expand All @@ -85,8 +85,8 @@
node.rpdo[1]['Controlword'].raw = 0x81
node.rpdo[1].transmit()

node.powerstate_402.state = 'READY TO SWITCH ON'
node.powerstate_402.state = 'SWITCHED ON'
node.state = 'READY TO SWITCH ON'
node.state = 'SWITCHED ON'

node.rpdo.export('database.dbc')

Expand All @@ -95,22 +95,22 @@
print 'Node booted up'

timeout = time.time() + 15
node.powerstate_402.state = 'READY TO SWITCH ON'
while node.powerstate_402.state != 'READY TO SWITCH ON':
node.state = 'READY TO SWITCH ON'
while node.state != 'READY TO SWITCH ON':
if time.time() > timeout:
raise Exception('Timeout when trying to change state')
time.sleep(0.001)

timeout = time.time() + 15
node.powerstate_402.state = 'SWITCHED ON'
while node.powerstate_402.state != 'SWITCHED ON':
node.state = 'SWITCHED ON'
while node.state != 'SWITCHED ON':
if time.time() > timeout:
raise Exception('Timeout when trying to change state')
time.sleep(0.001)

timeout = time.time() + 15
node.powerstate_402.state = 'OPERATION ENABLED'
while node.powerstate_402.state != 'OPERATION ENABLED':
node.state = 'OPERATION ENABLED'
while node.state != 'OPERATION ENABLED':
if time.time() > timeout:
raise Exception('Timeout when trying to change state')
time.sleep(0.001)
Expand Down