Questions tagged [c]

For questions pertaining to compiling C programs on the Raspberry Pi.

Filter by
Sorted by
Tagged with
0
votes
0answers
27 views

Pi Pico: Software Reset using the C SDK?

I'm looking for a method/function to be able to reset a Raspberry Pi Pico via programming, using the Pic's C SDK. Is this possible? There is a way to do it using python using machine.reset() but I can'...
1
vote
1answer
59 views

Reading MCP23S17 port expander with pigpio

I'm trying to read from a handful of switches connected to a MCP23S17 port expander using pigpio, however I'm not getting any useful results. Whatever my switch values, I have 0 returned. I've checked ...
0
votes
1answer
19 views

Can ioctl(file,I2C_SMBUS,&args) be used to read MCP3221?

I've been using C code based on a convenient linux_i2c-dev.h, but there seems to be no function to read 2 bytes without sending a command byte first. I want the code to work on both PI3s & PI4s. ...
1
vote
1answer
28 views

Is t possible/feasible to use android's NDK toolchain to cross-compile for Pi?

That's it, really. I have an x86_64 host that already cross-compiles a C application for android's 4 supported architectures, could I use the existing toolchain to build armeabi-v7a for a Pi (running ...
-1
votes
2answers
150 views

Communication Raspberry Pico and 3B+

I recently bought a Raspberry Pico to increase the capacities of my oldest Pi3B + tenfold in terms of sensors, buttons, LEDs, GPIO, etc. But I can not find for the moment any protocol or Bus allowing ...
0
votes
1answer
27 views

Pin 16 not lighting up

First time actually using the hedears on my raspberry pi zero w. These headers were soldered on when I got it. When I connect my red lead to the 5v pin, it lights up, so the circuit's correct. When I ...
0
votes
1answer
23 views

Understand the plumbing behind running RasberryPI code from Freenove in Python

I have downloaded some pre-made code from Freenove - https://github.com/Freenove/Freenove_Ultimate_Starter_Kit_for_Raspberry_Pi Freenove uses WiringPi. So I downloaded WiringPi and ran build. Question ...
0
votes
0answers
45 views

Running "make" Produces Fatal Error [duplicate]

I'm currently trying to get my raspberry pi setup with a VPN. To do so I needed a DNS provider, and so I'm trying to use No-IP's services, and after downloading their files and running a make to start ...
0
votes
1answer
69 views

Do `pthreads` work on the Pico with the native c++ SDK without posix?

I am trying to port AprilTags to the Pi Pico. This has a dependancy on pthreads. As is outlined in this SO question pthreads needs a posix layer. However there is this youtube video showing it working ...
0
votes
1answer
61 views

How to set an initial value of a variable of struct in C? [closed]

Im making a library for a raspberry pi program and im running into trouble of a struct variable having an initial value. myLib.h typedef struct { int startingNumber = 0; // this throw an error in ...
-1
votes
1answer
59 views

Pi 4 doesn't recognize .o file format? [closed]

Was trying to compile some .c files along with one .o file using gcc, and it failed with an error message saying: .o file format not recognized. The same files got compiled on centOS vm though.
0
votes
0answers
23 views

pigpio hardwareclock does not produce correct frequency

The code for generating a clock on GPIO 6 (clk2) does not output the correct frequency gpioHardwareClock(6,5000000); Its is no where near the value, my logic analyzer is showing about 680Khz range I ...
1
vote
1answer
43 views

my spidev code does not store the receive data

So i am using a trimmed down version of this code to do a spi transaction usin spidev. Here is my code /* * spi-driver-speed.c * 2016-11-23 * Public Domain */ #include <stdio.h> #include <...
0
votes
1answer
379 views

How to read any connected DS18B20 temperature sensors with C/C++

I'm new to the Raspberry Pi ecosystem so pardon me if I'm talking nonsense. I want to read the temperature data from the connected DS18B20 sensors using C/C++. I followed this schema to connect them: ...
0
votes
1answer
54 views

Shutdown from C program

I'd love to do a proper shutdown of the Pi from a program (written in C) so that the only thing left to do is pull the power plug. Is this possible?
2
votes
2answers
907 views

How do I implement an interrupt service routine on Raspberry Pi?

There are several libraries like WiringPi, RPi and pigpio, claiming to implement interrupt handling for GPIO signals. But as far as I can estimate, they all do polling on the pins, therefore implement ...
-1
votes
1answer
215 views

Raspberry Pi Software Driven servo control with PWM using C and Wiring Pi LIbrary

I'm trying to get my raspi zero to move an SG90 PWM driven servo. I have achieved this with python already using the gpiozero library, so I know my hardware works but I am trying to do it with C using ...
0
votes
2answers
45 views

What happens shortly after boot to affect timers?

I have a program that has ill effects if run from .bashrc and I've dug deeper and found a minimal reproducible example. The code below will print the elapsed time every second. If I run this program ...
1
vote
2answers
57 views

Raspberry Pi - stdin at boot with rc.local

If I run a program via rc.local I get no access to the keyboard or monitor with stdin and stdout. How can I get around this?
0
votes
0answers
33 views

How to address mem_alloc failure (update: can you diff disk images?)

My Raspberry Pi 3B+ has been behaving a little strangely lately and I suspect that the error I'm getting from my pi-bose project is a clue as to what's wrong. I get the same error from the parent ...
0
votes
1answer
58 views

Camera, splitter and encoder in OpenMAX

I want to access camera and get both encoded and not-encoded video from it in my C++ application. As I'm targetting Raspberry Pi Zero, I want it to be as efficient as possible, so I decided to use ...
0
votes
0answers
60 views

CAN communication between arduino and raspberry pi

I am trying to communicate between Raspberry Pi and Arduino. In arduino I am using this program to transmit #include <SPI.h> #include <mcp_can.h> const int spiCSPin = 10; MCP_CAN CAN(...
1
vote
2answers
254 views

Writing to framebuffer on C is very slow (Raspberry Pi)

I want to make a very intensive simulation and need the most power the Raspberry Pi gives me. So I flashed Raspberry Pi OS Lite (without Desktop) onto an Micro SD Card and wrote to the framebuffer in ...
1
vote
1answer
53 views

Unable to control GPIO from the code

I am using raspberry pi 4b along with Freenova kit. I am trying to make the LED blink however it does not blink instead it is ON of the time. I have tried different code (C,Python,Java) but none of it ...
0
votes
1answer
25 views

Deinitialize GPIO access on I2C channels

On webpage http://abyz.me.uk/rpi/pigpio/examples.html you can find Tiny GPIO Access that defines minimal set of C functions needed to control the GPIO without needing root privileges (it uses /dev/...
1
vote
3answers
1k views

Controlling Raspberry Pi GPIO with c and Python

I was searching for C and Python Libraries which support Pi4.
0
votes
0answers
149 views

using GSL with raspberry pi

I am trying to use gsl in the raspberry pi but every time I try to compile I get the following error: gcc -L/usr/local/lib -lgsl -o interface example.o -pthread -lgsl -lcblas -lm pkg-config --cflags -...
1
vote
1answer
127 views

UART - wiringSerial.h vs standard Linux open/close

I'm making an application that uses the UART port from the 40pin headers and I found online that there's a library called wiringSerial.h I was wondering what's the difference between wiringSerial.h ...
1
vote
1answer
145 views

popen() vs netcat

I'm writing a RPi based surveillance solution that, among other things, starts video feeds on demand. In my very first attempt I wrote a pretty simple TCP server that listen for a connection collect ...
0
votes
1answer
214 views

Raspberry Pi 4 - BCM2835 Library - SPI1 - data mode 1

I use the BCM2835 library to communicate in SPI with an ADC. The SPI0 interface is already used by a touch screen (https://www.pi-shop.ch/pitft-plus-480x320-3-5-tft-touchscreen-fuer-raspberry-pi-model-...
0
votes
0answers
26 views

Can't get to toggle leds with WiringPi library in C

So I got my python code to run that basically just toggles the LED, but now I tried enabling the GPIO via WiringPi library in C but it doesn't work. Considering python code runs, there isn't really ...
0
votes
0answers
36 views

Graphing out the sensor data in a C-based application

So my setup basically includes STM32 as an MCU to which a temperature sensor and an nrfl2401 radio module are hooked. On the receiving end, I am thinking of having a Raspberry pi as an MCU hooked to ...
1
vote
2answers
2k views

Rpi Neo-6M / Neo-8M GPS Module Setup / Fix / Update Problems

Hi i'm tryng to change the update rate of my gps tracker(neo 6m ublok) i know the byte that i need to send are 0xB5,0x62,0x06,0x08,0x06,0x00,0xC8,0x00,0x01,0x00,0x01,0x00,0xDE,0x6A i've tried echo -e &...
0
votes
0answers
54 views

How to prevent libvlc from opening a new window for every mp4 in playlist?

My requirement is that a list of mp4 files play sequentially in the same window. The aim is to produce a simple animated face, specific characteristics being added programmatically to the list. ...
0
votes
1answer
23 views

code gets stock in keypad function

i am doing this project where i want to put a keypad and take in password from a user and then open the door or not. i used C but every time i call the keypad function in my code the code will not ...
0
votes
0answers
49 views

Cannot get the exact wireless protocol at a raspberrypi 4b using header wireless.h

I've created a programm in C that runs on raspberry pi4B in order to get the wifi protocol that is supported. The version of raspbian is : Distributor ID: Raspbian Description: Raspbian GNU/Linux ...
0
votes
1answer
178 views

I want to mmap the GPIO on Raspberry Pi 4b+ but get invalid argument. (Running Raspbian Buster)

// The c code shown here works: int fd = open("/dev/gpiomem", O_FLAGS); printf("fd = %d\n", fd); long int* addr = mmap(0, 0x1000, PROT_RDWR, ...
2
votes
1answer
531 views

How to write 16 bit data to device address using the i2c wiringpi lib

I am trying to write 16 bit data to i2c device . As there are no registers specified to write to the slave device, I am not able to use the built-in wiringPiI2CWriteReg16 Api. Can some one guide me ...
0
votes
1answer
99 views

Program won't continuously read a value from a function

I'm in the midst of a school project and having trouble with reading ADC values from an MCP3004. I have it done in two different ways but one of them won't work. Using wiringPi.h and mcp3004.h, all ...
2
votes
2answers
1k views

WiFi packet sniffer for RPi in c++

We are currently working on a project, where we want to see the packets sent over WiFi. We are using an RPi zero w as a sniffer, and we have managed to use ioctl calls to get ssid and other ...
1
vote
1answer
172 views

Writing to GPIO 1 (ID_SC) witth Pigpiod C interface

I am writing a general-purpose stepper motor driver C shared library for the Raspberry Pi using PIGPIO (pigpiod C interface) for 4 to 7 motors using A4988 drivers. I designed an interface board (...
0
votes
0answers
84 views

C++ programming - Class for Motor rotation and control for washing machine embedded system device layer error?

#include <iostream> using namespace std; int main() { // declaring variables: int MotorControl; int MotorRotation; MotorControl = on; MotorControl = off; // process motor control and ...
2
votes
0answers
61 views

More than 2 SPI slaves

I like to connect more than two SPI slaves to the Raspberry. Just want help how to configure my Raspberry Pi Zero.
1
vote
0answers
34 views

If I want to program I2S by bit-setting the PCM registers manually, do I need to disable any kernel settings (eg snd_bcm2835)?

(I'm not with my board at the moment - if I need to share my code, I'll have to edit this post or post a new one at a later time) I didn't realize how complicated I2S setup on the Pi is. I've been ...
0
votes
0answers
133 views

Initializer element is not constant serialOpen WiringPi

I'm getting an error when trying to run some code on my raspberry pi. Here is the source code: /* SimpleReceive This sketch displays text strings received using VirtualWire Connect the Receiver data ...
1
vote
1answer
760 views

How to develop an own operating system for the raspberry pi 4 in c

I've seen the Baking Pi tutorials, but they seem to be outdated, because it says they haven't been updated for the pi 2 yet. Also, they only use assembly language, and I would like to use C instead. ...
0
votes
1answer
383 views

polling gpio raspberry 2 doesn't work

i'm writing a library for my raspberry pi 2 for gpio control. I'm trying to test a function for read a gpio driven by interrupts with sysfs but i can't do that my function stops in poll() function. ...
0
votes
1answer
77 views

What if I flash the ARM processor with some random firmware

As Pi users, we know that our boards are driven by an ARM processor. We can find these processors in tons of devices such as routers, modems, cellphones etc. An ARM developer will use C language and ...
2
votes
3answers
820 views

How to know if time is synced?

I'm writing a software in C and it is running as a systemd service. I need the service to run after time has synced or alternatively, I need a way for my C program to identify if time has synced. I'm ...
0
votes
0answers
129 views

"Couldn't find matching render driver" error [LIBVLC][LIBSDL2][RPi3 B]

I am trying the simple libvlc demo with libsdl2 from LibVLC Sample Code SDL but I am having issues when running the compiled binary. I get a "Couldn't find matching render driver" error from ...

1
2 3 4 5