OpenMV H7 CAN-bus receive extended frame

Hello,

I am trying to receive something on OpenMV H7 via CAN-bus. I am using the example for CAN on the IDE, and if configured as transmitter, I can successfully transmit messages and see them on the bus using a CAN-Analyzer tool. However, when I send messages from the tool, or any other device, I can’t seem to make it receive anything if they are extended messages. If I initialize CAN with extframe=False, and I transmit standard ID messages, I can receive them. But if I use extframe=True, and I transmit extended ID messages, I can’t receive anything. Does anyone know if there is something else missing to make it work with receiving extended ID CAN messages?

This is the code I’m using currently:

# CAN Shield Example
#
# This example demonstrates CAN communications between two cameras.
# NOTE: you need two CAN transceiver shields and DB9 cable to run this example.

import time, omv
from pyb import CAN
from pyb import LED

RED_LED_PIN = 1

# NOTE: Set to False on receiving node.
TRANSMITTER = False
#TRANSMITTER = True

can = CAN(2)#, CAN.NORMAL)
# Set a different baudrate (default is 250Kbps)
# NOTE: The following parameters are for the H7 only.
#
# can.init(CAN.NORMAL, prescaler=32, sjw=1, bs1=8, bs2=3) # 125Kbps
#can.init(CAN.NORMAL,extframe=True, prescaler=16, sjw=1, bs1=8, bs2=3,auto_restart=True) # 250Kbps
can.init(CAN.NORMAL,extframe=True, prescaler=16, sjw=1, bs1=8, bs2=3,auto_restart=True) # 250Kbps
# can.init(CAN.NORMAL, prescaler=8,  sjw=1, bs1=8, bs2=3) # 500Kbps
# can.init(CAN.NORMAL, prescaler=4,  sjw=1, bs1=8, bs2=3) # 1000Kbps

#can.restart()

LED(RED_LED_PIN).off()

if (TRANSMITTER):
    while (True):
        # Send message with id 1
        can.send('Hello', 2)
        time.sleep(1000)

else:
    # Runs on the receiving node.
    if (omv.board_type() == 'H7'): # FDCAN
        # Set a filter to receive messages with id=1 -> 4
        # Filter index, mode (RANGE, DUAL or MASK), FIFO (0 or 1), params
        can.setfilter(0,CAN.MASK,0,(0,0))
        #can.setfilter(1,CAN.MASK,1,(0,0))
        LED(RED_LED_PIN).on()

        #can.setfilter(0, CAN.RANGE, 0, (1, 4))
    else:
        # Set a filter to receive messages with id=1, 2, 3 and 4
        # Filter index, mode (LIST16, etc..), FIFO (0 or 1), params
        can.setfilter(0, CAN.LIST16, 0, (1, 2, 3, 4))

    while (True):
        # Receive messages on FIFO 0
        if (can.any(0)):
            print(can.recv(0,timeout=20))
        #else:
        #    print(can.info())
        #    time.sleep(100)
#            print(can.recv(0, timeout=100))
#        except:
#            print("no receive\n")

The H7 CAN driver doesn’t support extended frames, it supports the basic CAN features. You’re welcome to send patches to implement that (or feature requests) to MicroPython: GitHub - micropython/micropython: MicroPython - a lean and efficient Python implementation for microcontrollers and constrained systems

Hi, thanks for the information.

No problems, I just wanted to be sure I wasn’t doing something wrong.

I have recently been using FDCAN with extended message IDs on the STM32H7 for an unrelated project at work, and could potentially implement this functionality in the near future if there is a need. For now, I have been able to adjust my sensor so that it works in standard CAN frames.

-Justin

If you do please let me know here and I’ll merged it back in OpenMV’s MicroPython fork.

I’m coming back to this question to see if any progress had been made?

I am a mentor for First Robotics Challenge and my team is using (and promoting) the OpenMV camera for FRC. I’ve had great success with high-school kids learning computer vision with OpenMV and it is much smaller, easier to use and faster to learn than RaspberryPi or other schemes (the IDE is awesome!). It is also much more robust for integration into competition robots because of the CANShield. This will be our 3rd season using OpenMV cameras as sensors on our robots and we want to make extensive use of the H7 and H7 Plus, but being unable to receive extended CAN frames is a big limitation for the H7’s.

I wanted to chime in and add a +1 for a potentially large audience of young people who could benefit from more complete CAN frame support on the H7. This would allow FRC teams to integrate with the FRC CANBus system /software stack which is essentially required by the rules and is based entirely on an extended CAN addressing scheme.

Please make a github feature request for this on the OpenMV GitHub.

Sure: On GitHub here: https://github.com/openmv/openmv/issues/1071

Thanks. We’ll get to working on this in the future. I can’t promise a when however.

Sure. I definitely understand. I’m just glad we have a issue for it to track. I’m looking forward to having the feature whenever we get it.

2021 challenge season kickoff is this Saturday so fingers crossed!

Thanks so much for all the cool features of OpenMV.