CAN Communication Problem OPENMV CAM M7


I am using ‘openmv cam m7’ at motion detection project. I have to send data with CANBUS to other nodes. But I have getting some error. CAn you help me with this?

# Hello World Example
# Welcome to the OpenMV IDE! Click on the green run arrow button below to run the script!

import sensor, image, os, time, pyb
from pyb import  UART, CAN

p_x = 320
p_y = 240

sensor.reset()                      # Reset and initialize the sensor.
sensor.set_pixformat(sensor.GRAYSCALE) # Set pixel format to RGB565 (or GRAYSCALE)
sensor.set_framesize(sensor.QVGA)   # Set frame size to QVGA (320x240)
sensor.set_windowing((p_x, p_y))
sensor.skip_frames(time = 2000)     # Wait for settings take effect.
clock = time.clock()                # Create a clock object to track the FPS.

#canbus communication config
can = pyb.CAN(2, CAN.NORMAL)
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)
#uart communication config
uart = UART(1)
uart.init(1152000, bits=8, parity=None, stop=1, timeout=1000, flow=0, timeout_char=0, read_buf_len=64)

#bacground image take and save to sdcard
if not "temp" in os.listdir(): os.mkdir("temp")
sensor.skip_frames(time = 2000)
bgImage = sensor.snapshot()"temp/bg.bmp")"temp/bg.bmp")

    clock.tick()                    # Update the FPS clock.
    img = sensor.snapshot()         # Take a picture and return the image.


    hist = img.get_histogram()
    diff = hist.get_percentile(0.99).l_value() - hist.get_percentile(0.90).l_value()
    triggered = diff > TRIGGER_THRESOLD

    print(clock.fps(), triggered)              # Note: OpenMV Cam runs about half as fast when connected
                                               # to the IDE. The FPS should increase once disconnected.

Hi, I bought the hardware to validate CAN bus communication but I have yet to actually check operation. The hardware on the MCU is definitely there and MicroPython supplies a driver for it but I can’t tell you if anything works or not just yet. If you need CAN right now I’d recommend you to connect an Arduino or something to the OpenMV CAM via a UART and use the Arduino as a CAN bridge device.

Ok than. Thank you for information.

@zener, which error do you get? Is the error coming from the import line

from pyb import  UART, CAN

Which firmware are you using?

I can vouch for CAN working on the M7, I’ve been using it without any issues.
Your code seems fine, apart from the fact that you never use the CAN bus to send or receive messages.
Echoing the questions from @bauer-san, what firmware are you using and what errors are you seeing?

Hi everyone, please see this issue:

The CAN module was disabled by mistake in the last release, and it has been fixed and will be available in the next release. For now you can either use FW 3.0.0 or wait for 3.2.0