Code: Select all
import pyb
from pyb import CAN
can = CAN(1)
can.init(CAN.NORMAL,False,2,sjw=1,bs1=15,bs2=5)# 1Mbps
can.setfilter(0, CAN.MASK32, 0, (0, 0)) # set a filter to receive messages
def run():
"""
Start the loop.
"""
can_id = 0
print('Loop started.\nPress Ctrl+C to break out of the loop.')
while 1:
try:
can.send('message',can_id)
can.recv(0,timeout=1000)
can_id += 1
except OSError: # VCPInterrupt # Ctrl+C in interpreter mode.
break
if __name__ == '__main__':
run()
but have a OSError and break the loop
how i need to do?