13
votes
Accepted
Controlling Raspberry Pi GPIO with c and Python
The BCM2711 SOC in the Pi4 has a new Peripheral implementation (all previous SOC had the same Peripheral implementation) which provides additional functionality. This includes the original ...
5
votes
How to enable SPI1 and SPI0 at the same time?
In order to use the spi1 port of the Raspberry Pi, you need to set the dtoverlay=spi1-1cs in /boot/config.txt. By default this will use the pins (https://pinout.xyz/pinout/spi):
MOSI - pin 38
MISO - ...
5
votes
Accepted
Cross compiling for RPi - error while loading shared libraries
Shared or dynamic libraries are needed at run time. So you need the library not only on the build system but in on the target system, in this case on the PI.
This is different from static libraries. ...
5
votes
Accepted
Pi locking up trying to use rising/falling edge detection
Solution:
Add:
dtoverlay=gpio-no-irq
to /boot/config.txt.
Previously the kernel would automatically disable interrupts when you set one of rising/falling edge detection methods but that apparently ...
5
votes
WiFi packet sniffer for RPi in c++
Sniffing other WiFi networks you are not associated must be supported by the WiFi chip, called monitor mode. If you look at the chip configuration on the RasPi with:
rpi ~$ iw list
Wiphy phy0
--- ...
5
votes
Accepted
4
votes
Accepted
DHT11 or GPIO Library to Use in C
For the GPIO libraries available on the Pi see
http://elinux.org/RPi_GPIO_Code_Samples
For C the usual choices are
wiringPi
bcm2835
pigpio (github)
4
votes
UART interrupt in Raspberry PI with c or c++
The linux UART API (really, the POSIX termios API, but you should use the system man pages for implementation specifics; everything is mostly in man 3 termios) creates a file descriptor that can be ...
4
votes
Raspberry Pi Baremetal Programming
Well, maybe you forgot to put "break" into your switch block case?
switch (mode)
{
case GPIO_OUTPUT:
*GPFSEL |= (1 << gpio_bit);
break;
case GPIO_INPUT:
...
4
votes
Accepted
Imprecise result after bitwise operation on GPIO registers
You have misunderstood the usage of the set and clear registers.
If bit x is 1 in the set register then GPIO x is set high. If bit x is 0 then the level of GPIO x is not affected (i.e. if high it ...
4
votes
Accepted
Errors compiling C program with time.h library
This type of "clock" support isn't C99 but POSIX.
Try removing -std=c99 from your compilation command and compile your code.
If that doesn't work, Add
#define _POSIX_C_SOURCE 199309L
to your code ...
4
votes
What if I flash the ARM processor with some random firmware
No, that won't be possible. As such, ARM CPUs inside the Raspberry pi SoC are slaves to the videocore. They cannot even go out of reset until the videocore executes the right firmware which allows ...
4
votes
How do I implement an interrupt service routine on Raspberry Pi?
wiringPi uses interrupts, e.g. with the wiringPiISR function.
pigpio uses interrupts, e.g. with the gpioSetISRFunc function.
lgpio uses interrupts. e.g. with the gGpioSetAlertsFunc function.
None of ...
4
votes
Pi Pico: Software Reset using the C SDK?
I don't see another way than using the watchdog. The example in the SDK documentation looks similar to this:
void software_reset()
{
watchdog_enable(1, 1);
while(1);
}
This busy waits 1ms ...
3
votes
Accepted
System Calls From C Code
If you need to provide input for a command, you should do it via input substitution or pipes, like this:
system("echo 123456 | gpg --passphrase-fd 0 gpgTest.py.gpg");
system("gpg --passphrase-fd 0 ...
3
votes
Accepted
PN532 NFC module not working on Pi 3
Steps to install NFC PN532
The Raspberry pi 3 has changed things around a bit: ttyAMA0 now refers to the serial port that is connected to the bluetooth. The old serial port is now called ttyS0. So if ...
3
votes
pigpio servo control
The only problem I can see with the code is that it terminates straight away.
When the program ends the pigpio library will shut down so servo pulses will stop.
I suggest you add a time_sleep(10) or ...
3
votes
Interfaces besides sysfs for GPIO programing in C
The sysfs system filesystem access to the GPIO is all that is provided as a standard library from Linux.
There are dozens of third party libraries.
See http://elinux.org/RPi_GPIO_Code_Samples for ...
3
votes
How to run a persistent program at boot which prints to console?
If you want the output printed to console, you are going to have to set that up. There are lots of things started at boot, and they can't all print to console or it would be an interleaved mess. So, ...
3
votes
Accepted
Does select/multithreading make sense when dealing with multiple DS18B20 and GPIO reads simultaneously?
For asynchronous or polling access, the better approach is to serialize your hardware access into a single thread for a given bus. This thread should run at relatively high priority and establish the ...
3
votes
Accepted
How to access to I2C software with wiringpi library-
As you say in your comment just use the wiringPiI2CSetupInterface function.
This function is actually called by wiringPiI2CSetup.
E.g. rather than
fd = wiringPiI2CSetup(0x31);
Use
fd = ...
3
votes
Print the amount of vibration on the screen in C
The Raspberry Pi does not have any analog input PINs. Thus you will not be able to interpret analog input signals without some additional hardware.
In order to be able to read not only HIGH or LOW ...
3
votes
Accepted
popen() vs netcat
I bet it has to do with buffering you're doing on streams. man popen has this line
Note that output popen() streams are block buffered by default.
You'll have to increase the buffer size to ...
3
votes
Accepted
How do I implement an interrupt service routine on Raspberry Pi?
There is no way to call userspace code from an ISR. Unlike system calls which run on the stack of the userspace program, interrupt handlers use internal kernel memory for the stack. Since that memory ...
3
votes
Communication Raspberry Pico and 3B+
It is unrealistic to expect a "tenfold" increase.
There are many ways of communicating with the Pico (all the usual suspects in fact).
You may be interested in Pico as a computer peripheral.
2
votes
2
votes
how to control WIFI using Raspberry Pi (running Raspbian ) using only C programming
WPA Supplicant exposes its API via D-Bus interface typically called fi.epitest.hostap.WPASupplicant or fi.w1.wpa_supplicant1, so you can use that. The advantage of D-Bus is that you can connect to it ...
2
votes
Accepted
Read C output in Python
Thanks to the comment of @joan:
You can't. A C program (a program in any language) returns an integer status. You want to change the Python program so it gets the stdout (printf) of the C program ...
2
votes
glibconfig.h no such file or directory
found a solution, I should have just used pkg-config:
gcc `pkg-config --cflags glib-2.0` foo.c `pkg-config --libs glib-2.0`
2
votes
incorrect values shows up in ultrasonic output in a fixed position
You are running under the Linux operating system which will every now and then swap out your program at an inconvenient time. That will corrupt the timings if a reading has just been triggered.
You ...
Only top scored, non community-wiki answers of a minimum length are eligible