In your function you are declaring an argument "uint8_t buffer". So that's normal sizeof(buffer) is 1.
Either you declare a pointer to uint8_t as parameter to your function. In that case it's not possible to know the size of the buffer.
Or you declare "uint8_t buffer[1000]" as parameter to your function. You can have correct value for sizeof(buffer). But it will be always 1000 bytes length.
@Guillaume K "declare "uint8_t buffer[1000]" as parameter to your function"
That would still only pass a pointer to the 1st byte of the array; not the size of the whole buffer, and certainly not the used size within the buffer.
A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
I will enter the buffer information from the user. For example, it can enter 500 bytes of information. I need to know the length. Do you think there is a way to do this?
@ZAHİDE ZEYNEP KURT "I will enter the buffer information from the user."
Does that mean it's text entry?
If so, you could make it a string - and then use strlen()...
Or, presumably, you know when the user has finished entering data - so you have the length at that point? As others have said, pass this length to your function.
This is standard C stuff - not specific to STM32.
A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Then you have BUFFER_LENGTH available to be used wherever you need it!
A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Note that it's conventional to use ALL UPPERCASE for #defined names - to distinguish them from variables (or functions).
uint8_t *arr = (uint8_t*) &buffer;
Your pointer arr is redundant here - why not just use buffer direct?
If your issue is now resolved, please mark the solution:
A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.