Giter Site home page Giter Site logo

can-doc's People

Contributors

hartkopp avatar marckleinebudde avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

can-doc's Issues

Issue with bus.send_periodic

Hi, I'm trying to send CAN messages with the function send_periodic. however i got the error

can.exceptions.CanOperationError: Couldn't send CAN BCM frame due to OS Error: Invalid argument You are probably referring to a non-existing frame. [Error Code 22]

The code i used is :

import can
import time

try:
    bus = can.interface.Bus(channel = 'can0',
                            bustype = 'socketcan',
                            bitrate = 500000)
except OSError as e:
    print(e)

message = can.Message(arbitration_id=0x37A, data=[0x0A, 0x00, 0x3B, 0x00, 0xFF, 0x0B, 0x00, 0x00], is_extended_id= False)
message1 = can.Message(arbitration_id=0x379, data=[0x0C, 0x00, 0x0A, 0x00, 0xFF, 0x00, 0x0A, 0x00], is_extended_id= False)
message2 = can.Message(arbitration_id=0x372, data=[0x00, 0xD0, 0x50, 0x80, 0xCC, 0x00, 0xAA, 0xB0], is_extended_id= False)

period = 0.1

while True:
    bus.send_periodic(msgs = message, period = 0.1)
    bus.send_periodic(msgs = message1, period = 0.1)
    bus.send_periodic(msgs = message2, period = 0.1)

When i tried to send it via bus.send it seems to be able to work

import can
import time

bus = can.interface.Bus(channel='can0', bustype='socketcan')
    
message = can.Message(arbitration_id=0x37A, data=[0x0A, 0x00, 0x3B, 0x00, 0xFF, 0x0B, 0x00, 0x00], is_extended_id= False)
message1 = can.Message(arbitration_id=0x379, data=[0x0C, 0x00, 0x0A, 0x00, 0xFF, 0x00, 0x0A, 0x00], is_extended_id= False)
message2 = can.Message(arbitration_id=0x372, data=[0x00, 0xD0, 0x50, 0x80, 0xCC, 0x00, 0xAA, 0xB0], is_extended_id= False)


period = 0.1

while True:
    bus.send(message)
    time.sleep(period)
    bus.send(message1)
    time.sleep(period)
    bus.send(message2)
    time.sleep(period)

Here are some of the configurations that my CAN device is working on
RPI-4B 8GB Ram,
kernel version : 6.1.19-v8+
CAN transceiver device, MCP2515 (modified, changed VP230 for TJA1050)

ip -d -s link show can0
4: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UP mode DEFAULT group default qlen 10
    link/can  promiscuity 0 minmtu 0 maxmtu 0 
    can state ERROR-ACTIVE restart-ms 100 
    
lsmod | grep spi
spidev                 20480  2
spi_bcm2835            20480  0

 ifconfig can0
can0: flags=193<UP,RUNNING,NOARP>  mtu 16
        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 10  (UNSPEC)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

/boot/config.txt
dtparam=spi=on
dtoverlay=mcp2515, spi0-0, interrupt=25,oscillator=8000000
dtoverlay=spi-dma
dtoverlay=spi-bcm2835

Upon boot up, RPI did say that it is unable to load spi-dma & bcm2835

failed to load dtoverlay=spi-dma
failed to load dtoverlay=spi-bcm2835

I'm pretty new to RPI and CAN devices as well as posting issues on github, so any advice would definitely help! Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.