Offline
Full Member
Karma: 0
Posts: 207
|
 |
« Reply #30 on: January 22, 2013, 02:56:11 am » |
Modified ! Thanks . hope you can help me
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 138
Posts: 19067
I don't think you connected the grounds, Dave.
|
 |
« Reply #31 on: January 22, 2013, 03:17:59 am » |
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(" "); } .
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
Offline
Full Member
Karma: 0
Posts: 207
|
 |
« Reply #32 on: January 22, 2013, 03:24:37 am » |
Is this the syntax ? Thanks
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Full Member
Karma: 0
Posts: 207
|
 |
« Reply #33 on: January 22, 2013, 04:02:14 am » |
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(" "); } . Then how about vw_have_message()?
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 138
Posts: 19067
I don't think you connected the grounds, Dave.
|
 |
« Reply #34 on: January 22, 2013, 04:11:30 am » |
From the reference: uint8_t vw_have_message ( )
Returns: true if a message is available to read
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
Offline
Full Member
Karma: 0
Posts: 207
|
 |
« Reply #35 on: January 22, 2013, 04:22:54 am » |
OK..so means I can use the idea that vw_have_message () then do something ?
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 138
Posts: 19067
I don't think you connected the grounds, Dave.
|
 |
« Reply #36 on: January 22, 2013, 04:25:27 am » |
If you don't mind blocking, you could just use "vw_wait_rx", or just use "vw_get_message" as you've shown.
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
Offline
Full Member
Karma: 0
Posts: 207
|
 |
« Reply #37 on: January 22, 2013, 04:31:59 am » |
Blocking of what ? Blocking of the signal from transmitter ?
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 138
Posts: 19067
I don't think you connected the grounds, Dave.
|
 |
« Reply #38 on: January 22, 2013, 04:33:29 am » |
No, blocking of your code, waiting for a message to arrive.
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
Offline
Full Member
Karma: 0
Posts: 207
|
 |
« Reply #39 on: January 22, 2013, 04:49:19 am » |
Oh..it means the code sometimes will fail to execute ? Am I correct ?
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 138
Posts: 19067
I don't think you connected the grounds, Dave.
|
 |
« Reply #40 on: January 22, 2013, 04:53:47 am » |
it means the code sometimes will fail to execute ? Am I correct ? During development, code will always sometimes fail to execute as we expect it to. But, no, you are not correct. "Blocking" means the code will loop waiting until a message is received. This may or may not be a problem for you. The great thing about the Arduino is that you can try things, and if they don't work, try something different. The frequency of your questions leads me to suspect you're not trying the things you're asking about.
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
Offline
Full Member
Karma: 0
Posts: 207
|
 |
« Reply #41 on: January 22, 2013, 04:59:31 am » |
Cool..yea I shall work for it now..thanks so much ..This library is easy to use !
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 316
Posts: 35590
Seattle, WA USA
|
 |
« Reply #42 on: January 22, 2013, 06:29:53 am » |
So from this can I say uint8_t is like a data type ? It isn't "like a data type". It IS a data type, just like int, float, byte, char, long, etc. The u up front indicates unsigned. The int differentiates the type from floating point types. The 8 explicitly defines the size of the variables, in bits. The _t indicates that the type is a standard type. Every compiler is supposed to recognize the type, and allocate the same space for it. This is not true of types like int. An int can be 16 bits, 32 bits, or 64 bits (or other unusual sizes), depending on the platform. A uint8_t is always 8 bits. A int32_t is always 32 bits. A uint64_t is always 64 bits.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Full Member
Karma: 0
Posts: 207
|
 |
« Reply #43 on: January 22, 2013, 07:22:57 am » |
it means the code sometimes will fail to execute ? Am I correct ? During development, code will always sometimes fail to execute as we expect it to. But, no, you are not correct. "Blocking" means the code will loop waiting until a message is received. This may or may not be a problem for you. The great thing about the Arduino is that you can try things, and if they don't work, try something different. The frequency of your questions leads me to suspect you're not trying the things you're asking about. #include <VirtualWire.h> #undef int #undef abs #undef double #undef float #undef round void setup() { Serial.begin(9600); // Debugging only Serial.println("setup");
// Initialise the IO and ISR vw_set_ptt_inverted(true); // Required for DR3100 vw_setup(2000); // Bits per sec
vw_rx_start(); // Start the receiver PLL running pinMode(13, OUTPUT); }
void loop() { uint8_t count; if(count==true) { count = false; } count = vw_wait_rx_max(2000);// Non-blocking if (true) { digitalWrite(13, HIGH); // Flash a light to show received good message delay(500);// Message with a good checksum received, dump it. digitalWrite(13, LOW); delay(500); } else if(false) { digitalWrite(13, HIGH); delay(100); digitalWrite(13,LOW); delay(100); }
} I write this code..I want it to be like when it does not receive message for 2s, then it will return false. If it receive message, then return true. Then it will only blink once then the whole system become false again. So what moddification I need to do ? Thanks
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 138
Posts: 19067
I don't think you connected the grounds, Dave.
|
 |
« Reply #44 on: January 22, 2013, 07:27:16 am » |
void loop() { uint8_t count; if(count==true) It doesn't make sense to test an automatic variable like this. If you want "count" to retain its value, make it "static". if (true) Will always be true. if(false) Will always be false.
|
|
|
|
« Last Edit: January 22, 2013, 08:36:25 am by AWOL »
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
|