How can I use CAN?

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
damy2005
Posts: 1
Joined: Thu Feb 12, 2015 9:03 am

How can I use CAN?

Post by damy2005 » Thu Feb 12, 2015 9:16 am

I write the codes below in main.py. But there is no data out,when i mesure PB9.How can I do?

from pyb import CAN
can = CAN(1,CAN.NORMAL)
can.setfilter(0, CAN.LIST16, 0, (123, 124, 125, 126)) # set a filter to receive messages with id=123, 124, 125 and 126
while True:
can.send('message!', 123) # send a message with id 123
pyb.delay(1000)

Nambabwe
Posts: 6
Joined: Wed Apr 29, 2015 9:04 pm

Re: How can I use CAN?

Post by Nambabwe » Fri May 01, 2015 9:04 pm

Damy2005, do you have the CAN wires connected to another CAN device? Something on the bus must reply with an 'ACK', so you need to connect something CAN to it.

Post Reply