What is the minimum hardware requirements for a CAN bus simulation? - simulation

I am making a research about CAN bus, and I need to see how it works. Is there a way to simulate simple CAN bus instructions? What hardware I must have for this purpose?
P.S: I am very new to topic.

To simulate can instructions you don't need any hardware. You can use socketcan under Linux and setup a virtual can-interface.
After you have setup the virtual can-interface vcan0, to try first things install can-utils:
sudo apt install can-utils
Then listen on the virtual can interface vcan0 by executing
candump vcan0
On another terminal send for example a can frame (with identifier 123) with 3 bytes of data 0x123456 to the interface vcan0 via
cansend vcan0 123#123456
You should also see the sent can-frame on the other terminal, where you executed candump vcan0.
In case you really want to "talk" to a real CAN-network you need hardware. One good and cost-effective way, would be to use a Raspberry Pi with a CAN-extension shield. Also there you can use socketcan + can-utils.

Related

How to send IPMI commands over I2C?

I am looking into trying to run ipmitool over I2C and was wondering if this is supported. I have a raspberry Pi connected via I2C to another device that has a BMC. I have the character device /dev/i2c-1 which I can use to write I2C commands to but I am hoping to be able to send IPMI commands instead, such as with ipmitool.
If I connect the Pi and other system both to the same network, I can still send commands over ipmitool's lanplus interface but that is not what I want to do. I would like to see if sending them over I2C is possible.
Most commands I run with ipmitool seem to attempt to open the file /dev/ipmi-N which doesn't exist on my raspberry pi. I checked the driver support in the kernel for getting that (https://www.kernel.org/doc/html/latest/driver-api/ipmi.html) and made sure that my kernel has ipmi_msghandler, ipmi_devintf, and ipmi_ssif compiled into it. But still no luck. I suspect the issue is that I haven't correctly configured the ipmi_ssif driver on the kernel command line. Am I on the right path with this? I determined the i2c address with i2cdetect -y 1 and it shows up as 0x10. Dumping the file cat /sys/class/i2c-adapter/i2c-1/name shows me that my adapter is bcm2835. This led me to try to add ipmb_ssif.addr=0x10 ipmi_ssif.adapter=bcm2835 ipmi_ssif.dbg=1,2,4,8 ipmi_ssif.dbg_probe=1 to the kernel command line. However, I didn't specify anything for ipmi_ssif.slave_addrs, ipmi_ssif.tryacpi, or ipmi_ssif.trydmi which admittedly could be my problem. I don't know if it could also be just something with the raspberry Pi maybe not having some support for this or something. Any ideas?
I also tried the driver ipmi_si, although the Pi doesn't seem to have the hardware support for this. I suspect that's trying to access a BMC locally instead of trying to go over I2C. Since the ipmi_ssif talks about going over an SMBus that seemed like the one that I wanted.
I did also looked through some of the other interfaces that ipmitool supports and went down a bit of a rabbit hole with the ipmb-dev-int driver (https://www.kernel.org/doc/html/latest/driver-api/ipmb.html) since that also looked promising and originally mistook it for imb interface. But it doesn't look like ipmitool has that as an interface. But perhaps there is another one there that might be a better option for what I am trying to do. Maybe the free interface for working with freeipmi?
Any ideas would be greatly appreciated!
I posted a similar question to the folks who maintain ipmitool https://github.com/ipmitool/ipmitool/discussions/296 and one of the maintainers there helped me out by pointing me to another ipmb driver https://github.com/Mellanox/ipmb-host that looks like I might be able to use in combination with the OpenIPMI interface.

Adress external Hardware directly without driver?

Is it possible to access external hardware without using a driver, i.e. not having the driver abstraction layer in between program and external device?
Can you use a device by implementing your own driver-like controlling/handling directly in your program code?
I'm trying to understand a program that implements a Modbus protocol and some very specific Modbus configurations. Now I don't know how exactly it communicates with the Modbus devices.
It looks to me that this is very similar to what a driver does.
But can it even communicate DIRECTLY with the device without having a driver installed?
Yes, there are several micro-kernel OS's that always configure this way -- drivers are entirely implemented outside of the kernel.
The first thing you likely need is to get access to the device's registers; typically performed with mmap(), you may need to dig around a bit to find the right settings for cacheability, etc...
Second problem is interrupts. Unless you are running something like QNX, you won't have a way to have interrupts signal your program directly. You will probably have to turn them off and poll the device periodically.
If you are using linux and need io ports (inb, outb, etc...) man ioperm for more information.

Reading KNX using Raspberry Pi 3 GPIO

My dad wants me to make kind of a smart home.
I would like to interface with KNX (a home automation protocol) using the GPIO on a Raspberry Pi 3. Ideally, I would like to build a web interface for it, but I don't have a clue how to interface with KNX in the first place.
Any suggestions?
It wont make sense for you to interpret and understand the KNX bus communication protocol directly. There is a massive specification behind the KNX bus which deals with so many problems from device addresses to collision detection. It would take years to master it and unless you develop KNX devices you really should not spend your time on it. You will be better off by doing the following:
Buy a KNX/IP gateway/interface such as https://www.mdt.de/en/products/product-detail/system-devices/system-devices/ip-interface.html
Understand that KNX bus traffic can be routed/tunneled to your home LAN/WIFI
Play around with one of the KNX libraries on GitHub. For example for C#: https://github.com/search?l=C%23&q=knx&type=Repositories&utf8=%E2%9C%93
If you want, have a look at my experimental .NET Core project which starts a radio streaming process when someone touches a button (in the bathroom in my case). It runs on any operation system (so Raspberry and Linux are fine) and you can find it here: https://github.com/ThomasZeman/KnxNetCore
check this website : http://michlstechblog.info/blog/raspberry-pi-eibknx-ip-gateway-and-router-with-knxd/ that might help. also there are special knx 2 ip devices sold by electronic stores
You can't connect the KNX bus to anything on the pi. The KNX bus has its own electrical specs, and you need specialized hardware to connect to it.
Such hardware is available, but probably a KNXnet/IP device (such as the Siemens N148) is a better option.
I see two options for you:
A) use an IP interface (e.g. the ones from MDT) and access the IP interface from your raspberryPi (e.g. with http://calimero-project.github.io/)
B) use a TPUART controller, which makes KNX TP telegrams accessible (r/w) to UART - see http://www.konnekting.de/konnekting-lernen/l1-knx-mit-arduino/

dose Arduino Uno capable of running an application taking input from sensors and sending them to remote database?

as I mentioned above,
does Arduino Uno capable of running application that is taking input from sensors around 6 sensors and sending that input to a remote database through out internet by using either (Wi-Fi shield, ethernet shield)?
I am asking such a question because I am going to use it in the next semester of academic year as a part of my final year project, but I am worried that it's RAM size is not enough since it is 2KB and I need to decide either using Arduino Uno or switch to Raspberry Pi.
It should be possible, altough you may have a hard time searching for a suitable driver for your database. If using MySQL, there is already a project to do exactly what you want.
Another (more flexible) approach is to write a small PC software to receive sensor data in a simple protocol you define, and write them to the database. Run it on the database machine (or any other machine, really), and then make the Arduino communicate with your proxy software instead.

Interface between a DSP/Microcontroller and a PC application

I'm using a DSP to control a sensorless brushless DC motor, The DSP is on a board which has a parallel port and a jtag connection (it's an eZdspTMS320F2812). What would be the best way to communicate between a PC application and the DSP as it was running? Ideally I'd like to have a GUI program with buttons like start, stop, accelerate, decelerate... but I've never done anything like that before. Which ports and method would be easiest to use?
Thanks
You can also use simple RS232 communications. I use always because it`s cheap and easy to implement.
The RS232 transceivers are very cheap (like MAX232 from Maxim-IC), and easy to use. Also they come in many packages like DIP or SOIC for example and can be found almost every electronic shop.
You can use any USART from your microcontroller to link with MAX232. Then, using a PC serial-usb converter (or if your PC does have a serial port it`s easier), you can use serial port programming from any programming language to develop your desktop application.
After that, all you have to do is create a protocol to exchange data between your PC programm and your DSP (some simple commands to start, stop and change motor direction for example).
Good luck in your project.
The parallel port is probably the easiest route. Depending on what OS and programming language you are using you should be able to find example code or libraries to support bi-directional communication via the parallel port. Since you have a small set of commands that you might want to send to the DSP board then you can probably just send a single character to the board for each command, e.g. 'R' = start, 'S' = stop, etc.