Yes, you can write it like that, but you need to declare the array before the call.
So the purpose of adding (uint8_t*)msg is just to tell that the message is an array of 8 bits.
Am I correct ?
The function expects to be given an array of type uint8_t.
If you give it an array of that type, you don't need the cast.
Okay. Got it.
Means if I give the function unsigned integer with 8 bits(An array), then I do not need to write the keyword uint8_t ?
Correct ?
Heheh
Means if I give the function unsigned integer with 8 bits(An array), then I do not need to write the keyword uint8_t ?
Correct ?
No. An unsigned integer is not an array and it isn't 8 bits.
So, if I want to send a number 2, then how do I wrote it in array of 8 bits ??? Thanks
So, if I want to send a number 2, then how do I wrote it in array of 8 bits ??? Thanks
uint8_t msg[1] = 2;
vw_send(msg, 1);
So from this can I say uint8_t is like a data type ?
For example int variable, so uint8_t variable ?
Thanks
PaulS:
So, if I want to send a number 2, then how do I wrote it in array of 8 bits ??? Thanks
uint8_t msg[1] = 2;
vw_send(msg, 1);
So how about the receiving part ?
void loop()
{
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
[b] if (vw_get_message(buf, &buflen)) // Non-blocking[/b]
{
int i;
digitalWrite(13, true); // Flash a light to show received good message
// Message with a good checksum received, dump it.
Serial.print("Got: ");
for (i = 0; i < buflen; i++)
{
Serial.print((char)buf[i]);
Serial.print(" ");
}
Serial.println("");
digitalWrite(13, false);
}
}
What does it means ?
What does it means ?
As you posted it, it means nothing, which is why you should post your code between code tags
Modified ! Thanks . hope you can help me
What does it means ?
In a nutshell, see if there's any data to read, read it if (vw_get_message(buf, &buflen))
, and then print it
for (i = 0; i < buflen; i++)
{
Serial.print((char)buf[i]);
Serial.print(" ");
}
.
Is this the syntax ? Thanks
AWOL:
What does it means ?
In a nutshell, see if there's any data to read, read it
if (vw_get_message(buf, &buflen))
, and then print itfor (i = 0; i < buflen; i++)
{
Serial.print((char)buf[i]);
Serial.print(" ");
}
.
Then how about vw_have_message()?
From the reference:
uint8_t vw_have_message ( )
Returns:
true if a message is available to read
OK..so means I can use the idea that vw_have_message () then do something ?
If you don't mind blocking, you could just use "vw_wait_rx", or just use "vw_get_message" as you've shown.
Blocking of what ? Blocking of the signal from transmitter ?
No, blocking of your code, waiting for a message to arrive.
Oh..it means the code sometimes will fail to execute ? Am I correct ?