I dont understand this : vw_send((uint8_t *)msg, strlen(msg));
"msg" is a null-terminated C string, probably in a "char" buffer.
So, "strlen" tell you how many characters are in the string (not including the terminator).
"(uint8_t *)" says to the compiler "look, I know I'm not giving you the exact type of pointer (msg) you expect, but it'll be OK. Trust me".
And vw_send sends the buffer.
If you want to send just '2' in this way, vw_send((uint8_t *)"2", 1);
There is no string datatype in C - strings are just "char" arrays, with the last position filled with a zero (A true zero, not an ASCII zero).
So, the string "Hello" occupies six consecutive locations in array, 'H', 'e', 'l', 'l', 'o' with '\0', where the backslash signifies to the compiler that is really is zero, not ASCII zero.
So if I use this function vw_send(message, length), the messagee must be an arrary of 8 bits ? And I must include write it like this :
vw_send((uint8_t *)msg, strlen(msg)); ???
This doesn't make sense. The array can be any number of elements. The size of an element, in bytes, is dependent on the type of the array. All bytes are 8 bits.
Okay, I think I have to read more about pointer and array. Thanks !
vw_send(message, length)
Transmit a message. "message" is an array of the bytes to send, and "length" is the number of bytes stored in the array. This function returns immediately and the message is sent slowly by an interrupt-based background process.
so the message is refering to ((uint8_t*)msg), where msg is any number of words ? It is not array anymore because we include the uint8_t already ?
It is not array anymore because we include the uint8_t already ?
I don't understand what you're saying, but obviously it still is an array, because if it were not, then we wouldn't need to specify a buffer length to transmit.
I mean I can also write like this vw_send(char msg[8],8) ? Instead of writing it like vw_send((uint8_t*)msg,8), char msg[8] = {'1','2','3','4','5','6','7','8'}