CAN CUMMUNICATION OSERROR:16

Discussion related to "under the hood" OpenMV topics.
adrianhergi
Posts: 1
Joined: Mon Jan 08, 2018 7:22 am

CAN CUMMUNICATION OSERROR:16

Postby adrianhergi » Mon Jan 08, 2018 7:38 am

Hello, I am trying to communicate via CAN but I am always gettitn an OsError_16 after trying to send three messages. However in the bus I dont see those messages.

Here is my code:

Code: Select all

# Untitled - By: Juan - lu. ene. 8 2018

import sensor, image, time, utime
import pyb

can = pyb.CAN(2)                        #The bus 2(PB12, PB13) is the only can bus on the Open MVCam

can.init(pyb.CAN.NORMAL, extframe=False, prescaler=18, sjw=1, bs1=8, bs2=3) #250kb/s
# APB1 = 54MHz, Prescaler 18 et 250kB/s --> 12 time quanta par bit (1 + 8 + 3 = 12)
can.setfilter(0, pyb.CAN.LIST16, 0, [0x700, 0x700, 0x701, 0x702], rtr = [0, 1, 0, 0])

sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)

clock = time.clock()
tiempo= utime.ticks_ms() # get millisecond counter
aux=pyb.freq();
print(aux)
while(True):
    clock.tick()
    img = sensor.snapshot()
    data= b'\x01\x50'
    tiempo2=utime.ticks_ms()
    if (tiempo + 1000)< (tiempo2):
        tiempo= utime.ticks_ms() # get millisecond counter
        can.send(data, id = 0x702, timeout=0, rtr=False)
        print("can : message sent") # [Debug]
        
And the Serial Output

Code: Select all

>>> (216000000, 216000000, 54000000, 108000000)
can : message sent
can : message sent
can : message sent

Traceback (most recent call last):
  File "<stdin>", line 28, in <module>
OSError: 16
MicroPython v1.9.2-4416-g17df8ae1 on 2017-11-04; OPENMV3 with STM32F765
Type "help()" for more information.


Any ideas?
User avatar
kwagyeman
Posts: 2037
Joined: Sun May 24, 2015 2:10 pm

Re: CAN CUMMUNICATION OSERROR:16

Postby kwagyeman » Mon Jan 08, 2018 10:39 pm

Hi, I've never done anything with the CAN peripheral. Ibrahim might know how to work it. Pinging him.

Note, if you ask for help on the main MP forums they might know more.
Nyamekye,
User avatar
iabdalkader
Posts: 481
Joined: Sun May 24, 2015 3:53 pm

Re: CAN CUMMUNICATION OSERROR:16

Postby iabdalkader » Tue Jan 09, 2018 2:54 pm

I'm not sure either, I don't have the hardware to test CAN. OSError 16 is "Device or resource busy" I found this on MP forums:
https://forum.micropython.org/viewtopic.php?t=1923

Return to “Technical Discussion”

Who is online

Users browsing this forum: No registered users and 2 guests