Questions tagged [pointer]
A variable in C/C++ which stores the type and location of data in memory.
97 questions
0
votes
1
answer
125
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 ...
2
votes
0
answers
185
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 ...
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 ...
-1
votes
1
answer
971
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
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?
...
1
vote
1
answer
991
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 ...
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
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,...
2
votes
2
answers
5k
views
Issues converting an uint32_t into a char*
I'm using a capacitive touch sensor that as 12 touch points and stores it's state data as a binary number.
I want to take that state, add a bit of data onto the front, and then send it up to a server ...
1
vote
1
answer
116
views
How to specify a timer's name depending on the chip it will be compiled to?
I need to enable a timer interrupt for a chip, and in the mean time, I am testing the code on Arduino Nano rather than (feed the chip, test the chip)++.
So as part of the code I have to TIMSK0 |= (1 &...
0
votes
1
answer
224
views
Assigning an empty array row to reference [duplicate]
int colors[][3] = {
{ 255, 0, 0 },
{ 0, 255, 0 },
{ 0, 0, 255 },
{ 253, 7, 210 }
};
int (*EXCLUSIVE_COLOR)[3];
I have a two-dimensional array to store some color values.
I have a 2nd array,...
0
votes
1
answer
1k
views
Swap two arrays (using pointers, not copy)
I've got two arrays, defined as:
uint8_t array1[10];
uint8_t array2[10];
I'd like to swap the arrays (actually the pointers to each array) using code like this:
uint8_t *tmp = array1;
array1 = ...
0
votes
1
answer
155
views
Boolean function call with character pointer input - dont understand how to get updated pointer value
Thank you for everyone's help in trying to find a solution. This library I'm working with was prewritten and is one of the most buggy hardware libraries I've had the misfortune to use. I have now ...
0
votes
1
answer
521
views
Passing a NeoPixel object reference to a custom library
I'm new to Arduino programming and haven't programmed in C++ in the past. I'm trying to create a custom library to cycle a rainbow on my NeoPixel LED strip. I want to pass a reference or pointer or ...
1
vote
1
answer
757
views
I can't receive string that I have sent through nrf correctly
I'm using arduino uno and nrf24l01. to monitor sensor data.
But this is the message that master receives:
⸮
this is my slave code.
void monitoring() {
delay(10);
radio.stopListening();
...
1
vote
4
answers
1k
views
How do arrays work?
It's been days now I'm trying to figure out how arrays work in Arduino IDE.
For better understanding, I assembled some pieces of code I found here and there to write this sketch:
#define arrayLength(x)...
0
votes
1
answer
455
views
typedef function pointer array declaration problem
Thanks for all your feedback. It helped.
I rewrote this yet another time and this time it works perfectly. I included three variations: a simple example using an array of function pointers, a Lambda ...
3
votes
1
answer
213
views
writting to buffer from serial input
Can some one explain this behaviour please, i have the following code
byte buffer[512];
byte block;
byte len;
Serial.setTimeout(60000L) ; // wait until 20 seconds for input from serial
...
0
votes
1
answer
95
views
Having an issue accessing values from a pointer
Context
This may be more of a C++ question than an arduino specific question, but it's dealing with arduino c++ so I thought I'd start here.
I'm building a class to abstract some simple melody ...
1
vote
1
answer
147
views
Programfault when dereferencing a 64bit int on due
I am running into a strange behaviour with my code. The following works without problems on an Arduino Nano but it seems to crash on a DUE
void putData64(byte* packet, int pos, uint64_t data)
{
...
0
votes
1
answer
278
views
Parsing array of an object in a library constructor
I am trying to develop an Arduino library that consists out of two classes. I want 'WayPointStack' to store an array of 'WPCommand', but I can't get it to work.
WayPointStack.h
#ifndef ...
2
votes
0
answers
317
views
Using pointer to a Global function
I am trying to store and use a pointer to a global function.
The function global_f returns a String and takes an object as parameter:
String global_f(Request r){
// ...
return "This is it";
}
...
1
vote
2
answers
874
views
Creating an array of structures which store bitmaps to work with u8glib
I've tried reading the documentations and I'm getting desperate because I can't find anything.
I need to create an array of structures, which contains a bitmap stored in PROGMEM space (because of ...
2
votes
1
answer
85
views
Dynamic allocation/ Pointer to Pointer to update an Array containing parameter [closed]
topicArray defined as follows:
const char* msgTopic = "Home/Messages";
const char* groupTopic = "Home/All";
char* deviceName = deviceTopic;
const char* topicArry[2] = {deviceTopic, groupTopic};
But ...
0
votes
1
answer
93
views
Message Interpreter and Handler - How to store a function name in a struct?
For a project, I need to store an array of structures in PROGMEM. Array MessageTable[] will be composed of about ten struct InMessage elements. InMessage looks sort of like this:
struct AvcInMessage {...