Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_time_producer(self):
network = canopen.Network()
network.connect(bustype="virtual", receive_own_messages=True)
producer = canopen.timestamp.TimeProducer(network)
producer.transmit(1486236238)
msg = network.bus.recv(1)
network.disconnect()
self.assertEqual(msg.arbitration_id, 0x100)
self.assertEqual(msg.dlc, 6)
self.assertEqual(msg.data, b"\xb0\xa4\x29\x04\x31\x43")
def setUp(self):
network = canopen.Network()
network.add_node(2, EDS_PATH)
network.add_node(3, network[2].object_dictionary)
self.network = network
def setUp(self):
network = canopen.Network()
network.send_message = self._send_message
node = network.add_node(2, EDS_PATH)
node.sdo.RESPONSE_TIMEOUT = 0.01
self.network = network
def setUpClass(cls):
cls.network1 = canopen.Network()
cls.network1.connect("test", bustype="virtual")
cls.remote_node = cls.network1.add_node(2, EDS_PATH)
cls.network2 = canopen.Network()
cls.network2.connect("test", bustype="virtual")
cls.local_node = cls.network2.create_node(2, EDS_PATH)
def setUpClass(cls):
cls.network1 = canopen.Network()
cls.network1.connect("test", bustype="virtual")
cls.remote_node = cls.network1.add_node(2, EDS_PATH)
cls.network2 = canopen.Network()
cls.network2.connect("test", bustype="virtual")
cls.local_node = cls.network2.create_node(2, EDS_PATH)
cls.remote_node2 = cls.network1.add_node(3, EDS_PATH)
cls.local_node2 = cls.network2.create_node(3, EDS_PATH)
import canopen
import sys
import os
import traceback
import time
try:
# Start with creating a network representing one CAN bus
network = canopen.Network()
# Connect to the CAN bus
network.connect(bustype='kvaser', channel=0, bitrate=1000000)
network.check()
# Add some nodes with corresponding Object Dictionaries
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]
# Reset network
node.nmt.state = 'RESET COMMUNICATION'
#node.nmt.state = 'RESET'
node.nmt.wait_for_bootup(15)