remove
I'm stumped. I don't see your error.
You could:
- print sx1272.packet_received.data
- put different values in it.
- swap vbat and vcap to see if it changes anything.
Thanks :(, its mind boggling.
Is it blank? or is your transmitter sending a space or a no-break-space ascii value? Print out the ascii value instead, and check what it sends.
Weird bugs like that are usually stemming from a false assumption.
When the error is not where you are looking then look elsewhere: TammyTam is right. It's one possible issue.
You have not posted a complete program. In that case the problem is usually in the piece(s) you have omitted.
Print the full string as received before you try to print the individual elements - that way you can see if there is an item different from what you expect. This seems the most likely cause of the problem.
I would be surprised if the variable name "vcap" has any special significance for the compiler - but it would be worth trying another name - perhaps "vcapxx"
...R
Buffer overflow here:
char id[3];
...
char distance[3];
...
id[0] = sx1272.packet_received.data[0];
id[1] = sx1272.packet_received.data[1];
id[3] = '\0';
...
distance[0] = sx1272.packet_received.data[6];
distance[1] = sx1272.packet_received.data[7];
distance[3] = '\0';
Hi Guix, I'm sorry, I don't understand, what am I doing wrong?
Thanks
Should be:
distance[0] = sx1272.packet_received.data[6];
distance[1] = sx1272.packet_received.data[7];
distance[2] = '\0';
Cant believe I missed that
Me too, I'm blind. Funny when you look at something for ages you can't see the obvious.
Thanks for all the help.
Hi Guix, I'm sorry, I don't understand, what am I doing wrong?
The code you posted does not compile for me, so maybe you should start over.
distance[3] = '\0';
I did not notice that!! Good catch!!!
Now that imples the compiler allocated vcap after distance.