Questions tagged [pointer]
A variable in C/C++ which stores the type and location of data in memory.
97 questions
0
votes
1
answer
111
views
Serialise a struct containing a flexible array
I want to serialise and deserialise a struct containing a flexible array.
I did find a working code but wondering if it is the most elegant and optimum way to do it.
This is my first attempt below ...
1
vote
2
answers
155
views
How to manage mixed pointers to RAM and PROGMEM on Arduino?
I'm working on a project where I want to implement something like a FORTH interpreter on Arduino. The interpreter consists of "WORDS," where each WORD has a name, a header, and an array of ...
2
votes
0
answers
183
views
Program crashes when calling external library code via function pointer
I've written a user library for the Pi Pico that uses the TaskScheduler library to abstract timing away from the user. The user provides a function in their sketch which the library calls periodically ...
2
votes
1
answer
127
views
How to pass Encoder object to constructor of a different class
I am trying to create a class (Arm) that controls an arm. The arms have 2 motors, each with an encoder, so I pass 4 integers for the pins and I am trying to pass 2 pointers (one for each encoder ...
1
vote
2
answers
3k
views
Difference between (*(volatile unsigned int *) and (volatile unsigned int)?
I have been watching tutorials on STM32 bare metal programming. I couldn't understand the purpose of the below code
#define RCC_AHB1EN_R (*(volatile unsigned int *)(RCC_BASE + AHB1EN_R_OFFSET))
and ...
0
votes
4
answers
1k
views
How to send multiple bytes with Wire without copying
When I need to send multiple bytes via Wire, for example a long int, I cast it to a byte array and specify a length
long int i;
Wire.write((byte*)&i, 4);
But if I want to send bytes from more ...
-1
votes
1
answer
964
views
Cannot read values stored in bool* pointer [closed]
I'm trying to read values stored in a bool* pointer from a modbus coil call.
I'm using modbus-esp8266 library. it's all ok with Input Registers and Holding Registers but i cannot read the result of a ...
0
votes
1
answer
98
views
Failure using references variables in classes [closed]
Theoretical Q
I'm having some trouble when using a referenced variable in a class.
Class A have an int a=0. Class B has an instance of Class A, and referencing int &a=A.a, and in the same manner ...
0
votes
2
answers
1k
views
Why I cant get sizeof a pointer Array
well I am trying to get array size to convert hex value to int value. but if I try to get size of array it returns every time 2. Actually .I dont understand. how to get array size, can you help me?
...
0
votes
2
answers
1k
views
Passing a two dimensional array to a function
I'm working on an led matrix project where I'm running a series of patterns made of bitmap frames.
Here's an example: https://vimeo.com/564184465
Right now I'm using a series of method calls named per ...
1
vote
1
answer
962
views
Can you create an array for functions? [closed]
Let's say I want to create 10 functions, named Function1, Function2 until 10. Each function is used if a certain variable is equal to its number. Rather than using individual functions, I was ...
0
votes
1
answer
635
views
esp32 crashes when trying to dereference a pointer value
I have a websocket listener that is giving me a std::string of my message payload (I want the bytes) and I wrote a function that pulls each of the bytes out and puts them into 32 bit integer variables,...
1
vote
1
answer
3k
views
converting an unsigned integer into a const char pointer
I know this is simple basic C stuff, but I can't quite figure it out or find a solution when searching and reading.
I have a method I want to call from a library that wants a const char pointer
...
0
votes
1
answer
331
views
Accessing funcition in object via `->` is crashing (resetting) Arduino
I have several classes that call each other running on an Arduino Mega. I am using the ArduinoSTL library to get the std library, most notably the std::vector.
The core problem is as follows: my ...
0
votes
3
answers
1k
views
Run multiple function with different argument/return structure by one function pointer
Edit:
I tried a simple code in Arduino IDE which should've done in the first place instead in doing it in a desktop compiler. Because the results are different by experiment. In the desktop C compiler,...