canbus | canbus provides high-level facilities | Socket library
kandi X-RAY | canbus Summary
kandi X-RAY | canbus Summary
canbus provides high-level facilities to interact with CAN sockets.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- This is the main entry point for example .
- parseFrame converts a string to a byte slice
- Bind to socket
- New returns a Socket .
canbus Key Features
canbus Examples and Code Snippets
Community Discussions
Trending Discussions on canbus
QUESTION
I want to filter with canbus. I found certain things for the filter, but what I want is not working. I created a filter like the one below. Some messages cannot pass through this filter.
What kind of change should I make in the filter to be included in the following messages? Thank you for your answers.
Passing messages
Messages that do not pass
My Filtre Code
...ANSWER
Answered 2021-Mar-23 at 16:31CAN messages are e.g. filtered to reduce CPU interrupt load (only if a filter accepts a message an interrupt is triggered). With filters is i.e. checked if a message that is on the bus is addressed to this node, this is in detail on page 42-48 in https://www.mi.fu-berlin.de/inf/groups/ag-tech/projects/ScatterWeb/moduleComponents/CanBus_canover.pdf
CAN filters and masks are organized a bit similar to IP addressing (IP address and netmask), this is in detail in http://www.cse.dmu.ac.uk/~eg/tele/CanbusIDandMask.html or in the IP analogy in http://jodies.de/ipcalc
So in CAN filtering if you want to filter a range of addresses you use a mask :
Example 2. we wish to accept only frames with IDs of 00001560 thru to 0000156F
set filter to 00001560
set mask to 1FFFFFF0
In your code only the 0x18 is fixed the rest of the address has to be masked
QUESTION
It is Veysel My board is STM32 Nucleo F429ZI and I use Mbed-os 6.6.0. I can read from my car CANBus data but I am not able to write on the bus. I tried it with two STM32 (same boards) and my trancivers are SN65HVD230 So I know that I can read on the CANBus , but I cannot write.
I have tried , https://os.mbed.com/users/WiredHome/notebook/can---getting-started/ with one STM32 and I have tried
...ANSWER
Answered 2021-Jan-31 at 06:10for me it sounds like you forgot to drive the "RS"-pin of the CAN Transciever. This is a bit misleading in the datasheet, but it is not only "slope" control, but it also sets the Transciever to sleep. I'd recommend to use a 10k slope control resistor unlesss needed otherwise as shown here: Schematics
QUESTION
I have an interface which gives me a QVariant
of an arbitrary type. I need to convert the data content in this variant to a raw binary QByteArray
:
ANSWER
Answered 2021-Jan-25 at 08:36It turns out, that QVariant
has an undocumented method constData()
which gives exactly the result I want to have: A pointer to the internally stored data of the QVariant
. Together with QMetaType::sizeOf()
, this is exactly what is needed to write all the data into a QByteArray
.
I found that method documented in the documentation of Qt 6.0
and found it as well working with my Qt 5.12.7
, despite not being described in the corresponding documentation.
QUESTION
I am writing a program that should display some data that's going over a CanBus (data is being refreshed every 200ms), however when I make an objects from my class like this:
...ANSWER
Answered 2020-Oct-27 at 14:40Since you have more than one instance of PlaceInfo
, therefore there is more than one after task reading the CanBus which may cause race condition. Also after task A may read the message for task B and vice versa.
You need to centralize the reading of the CanBus and perform the reading in a thread because recv()
is a blocking task.
So you can create a CanReader
class which extends from threading.Thread
and call recv()
in its run()
function:
QUESTION
For a project I need to make communicate in a CANBus network, ethernet network and with RS-232. I want to use one single MCU that will act as the main unit of CANBus start topology, Ethernet start topology and that MCU also will be transfering the RS232 data that comes to it to another device. Now I want to use high speed CAN which can be up to 1 Mbits per second. However,RS-232 is max 20 k baud. I wonder if it is doable with 1 MCU to handle 3 different communications ( CANBus, ethernet and RS-232). I am afraid of to get overrun with data at some point. I can buffer data short term if data comes in bursts that can be averaged out. For continuous data where I'll never be able to keep up, I'll need to discard messages, perhaps in a managed way. But I do not want to discard any data. So my question is: Would using 1 MCU for this case work? And are there any software tricks that would help me with this case? (Like giving CANBus a higher priority etc.)
...ANSWER
Answered 2020-Sep-26 at 10:28Yes, this can be done with a single MCU. Even a simple MCU should easily be able to handle data rates of 1 Mbps. Most likely you want to use DMA enabled transfer so the CPU core will only need to act when the transmission of a chunk of data has completed.
The problem of being overrun by data due to the mismatch in data rate is a separate topic:
- If the mismatch persists, no system can handle it, no matter how capable.
- If the mismatch is temporary, it's just a function of the available buffer size.
So if the worst case you want to handle is 10s of incoming data at 1 Mbps (with an outgoing rate of 20kbps), then you will need 10s x (1Mbps - 20kps) = 9.8 Mbit = 1.225 MByte of buffer memory.
QUESTION
I realized there is no encryption in CANBus communication. So my question is: Does it worth to add an encryption method to CANBus communication in a vehicle. Since the communication takes place between the ECU's in the same vehicle, I believe CANBus is safe against the remote attacks/attackers. So I think encryption is not necesssary. However, putting an encryption in CANBus might make it harder to make your vehicle get reverse engineered. Am I correct? To sum up, I have 3 questions:
- Does CANBus needs an encryption method and does adding it worth to effort?
- If yes what kind of encryption method would be the best for the CANBus communication in a vehicle?
- Does adding an encryption to CANBus in your vehicled, would make it harder to get reverse engineered?
ANSWER
Answered 2020-Sep-25 at 07:03Not really. Depends what you want to protect against. To prevent a car thief from hacking into your CAN bus, use the usual protection measures against thieves: locks and alarms.
A couple of horrible car designs connect a MCU on the bus to the Internet for firmware updates. If you do that, you risk getting it hacked remotely, if an attacker can figure out how to download their own firmware into that MCU. Jeep had some design flaw like that iirc. But the design flaw is not of the CAN bus itself, it is the provided internet access to a MCU which also has access to the bus.
I suppose whatever is currently regarded as safe. But if it involves a lot of heavy math, it might be unsuitable for that purpose, since these are hard real-time systems, often with low end, decentralized CPUs. They won't be able to do heavy floating point math fast enough.
Of course.
QUESTION
We are developing a typical CANbus networked system with what you could call a controller organizing a number of devices.
The devices needs configuration, which the controller writes (and might also read back) using regular object dictionary items (currently in the manufacturer specific range).
The devices also perform actions (commands) with more than 8 bytes of data and this we solve by having write only items in the device object dictionary and relying on the regular segmentation/de-segmentation of SDO's. (I don't know if this is the CANopen way of doing things, but it seems reasonable).
However, the device also produces events (say some sensor data passes a certain threshold) resulting in more than 8 bytes of asynchronous data coming up from the device. PDO's are meant to be used for sending async event data, but it can only contain 8 bytes. The devices could write the data into an object dictionary item on the controller, but this doesn't seem like the CANopen way. Am I right?
The best we've come up with is to send a PDO to the controller, informing the controller that more data are available in the object dictionary on the device.
Anyone with CANopen background that can way in on the best (CANopen) way of solving this?
Since I'm repeating 8 bytes a lot, we can safely assume that this network is not running CAN-FD.
...ANSWER
Answered 2020-Sep-08 at 07:58The key of any sensible CAN network design is to consider real-time, data priorities, bus load and data amounts early on. If you find yourself with a chunk of data larger than 8 bytes, then that strongly suggests that something is wrong in this design - it should likely be split in several packages.
Generally, you shouldn't be using SDO for data at all, since they come with overhead. That includes writes to the object dictionary, which also means SDO access. Block transfers etc with SDO are meant for things like bootloaders or one-time configuration, not for live data traffic in operational mode. It can be done, but it is fishy.
You can in theory map data across several PDOs with PDO mapping, but all of this really sounds like an "XY problem" - you are convinced that you need to transmit larger chunks of data and look for a way to do it. But step 1 is to look at the fundamental network data/design and see if you actually need those large chunks or if it makes sense to split them in several. The ideal CANopen design is to have one PDO per type of data, when possible.
QUESTION
I'm writing a Python program to interact with a device based on a CAN Bus. I'm using the python-can module successfully for this purpose. I'm also using asyncio to react to asynchronous events. I have written a "CanBusManager" class that is used by the "CanBusSequencer" class. The "CanBusManager" class takes care of generating/sending/receiving messages, and the CanBusSequencer drives the sequence of messages to be sent.
At some point in the sequence I want to wait until a specific message is received to "unlock" the remaining messages to be sent in the sequence. Overview in code:
main.py
...ANSWER
Answered 2020-Jul-09 at 12:18Your question doesn't explain how you arrange for receivedMsgCallback
to be invoked.
If it is invoked by a classic "async" API which uses threads behind the scenes, then it will be invoked from outside the thread that runs the event loop. According to the documentation, asyncio primitives are not thread-safe, so invoking event.set()
from another thread doesn't properly synchronize with the running event loop, which is why your program doesn't wake up when it should.
If you want to do anything asyncio-related, such as invoke Event.set
, from outside the event loop thread, you need to use call_soon_threadsafe
or equivalent. For example:
QUESTION
I am writing a python program to produce canbus data in the following format.
<0x18eeff01> [8] 05 a0 be 1c 00 a0 a0 c0
I am using python-can library for this and trying to read message format as above. I couldn't figure out what is the first format <0x18eeff01> indicates? I don't know how I will produce that in the output.
...ANSWER
Answered 2020-Jun-13 at 17:380x18eeff01 is the arbitration id in hex form. You can get it with msg.arbitration_id. See here
QUESTION
I'm trying to load all the xml data into an QList. I'm not sure if I did the right thing of coding of getting all the data from xml.
When I tried to run it, there's some parts of the information from the xml that went missing in the output.
the following is the xml elements:
...ANSWER
Answered 2020-Mar-19 at 04:51Based on the on the next example: QXmlStreamReader to parse XML in Qt I have implemented the following solution:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install canbus
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page