ਪੰਜਾਬ
Offline
Edison Member
Karma: 4
Posts: 1224
WANTED! A Girl with LOVE for me and Arduino!
|
 |
« Reply #30 on: March 29, 2012, 08:06:59 am » |
My code doesn't waste resources wrapping the char array in String objects. Yours does.
Sir, Im not wasting resources i did that to print stats on Serial monitor. My code properly resets the buffer when a packet is received. Yours doesn't. OK sir but where? My code actually looks for SOP and EOP Ok
|
|
|
|
|
Logged
|
"Real Men can Accomplish Anything" - Website - skype : nishants5 ਫ਼ਤੇਹ ਕਰੂਂ !
|
|
|
|
Global Moderator
UK
Online
Brattain Member
Karma: 137
Posts: 19028
I don't think you connected the grounds, Dave.
|
 |
« Reply #31 on: March 29, 2012, 08:13:33 am » |
Sir, Im not wasting resources i did that to print stats on Serial monitor. Taking a perfectly acceptable C string (that could be compared against a constant string with a simple "strcmp"), and converting it to a String object is wasteful, in my book. YMMV.
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
ਪੰਜਾਬ
Offline
Edison Member
Karma: 4
Posts: 1224
WANTED! A Girl with LOVE for me and Arduino!
|
 |
« Reply #32 on: March 29, 2012, 08:46:45 am » |
I got it is simply appending the values so when first time there is a ON its only a ON in the inData but the second time when OFF is written then in the variable not only ON is there but also OFF so IF condition evaluates false.
first time putting ON okay its
ON ( as inData has ON only)
second time when one puts OFF its not only OFF but it is:
ON OFF
|
|
|
|
|
Logged
|
"Real Men can Accomplish Anything" - Website - skype : nishants5 ਫ਼ਤੇਹ ਕਰੂਂ !
|
|
|
|
Global Moderator
UK
Online
Brattain Member
Karma: 137
Posts: 19028
I don't think you connected the grounds, Dave.
|
 |
« Reply #33 on: March 29, 2012, 08:50:30 am » |
I got it Not quite. You reset the buffer as soon as you see "on" so "on" is no longer in the buffer, but then you read the '<'. Since you never test for this, it stays in the buffer, no matter what else you read in.
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
ਪੰਜਾਬ
Offline
Edison Member
Karma: 4
Posts: 1224
WANTED! A Girl with LOVE for me and Arduino!
|
 |
« Reply #34 on: March 29, 2012, 10:21:14 am » |
Cracked! It's because of the Serial.flush(); it just happened to flush the buffer from what was leftover from the previous Serial entry. if(Comp("on")==0){ Serial.write("Motor 1 -> Online\n"); for(int i=0;i<19;i++){ inData=0; } index=0; Serial.flush(); } if(Comp("off")==0){ Serial.write("Motor 1 -> Offline\n"); for(int i=0;i<19;i++){ inData=0; } index=0; Serial.flush(); } very minimal changes nothing changed except the ARRAY elements/width and removing the following from code: if(index < x) // One less than the size of the array { .....; }
|
|
|
|
« Last Edit: March 29, 2012, 10:53:50 am by NI$HANT »
|
Logged
|
"Real Men can Accomplish Anything" - Website - skype : nishants5 ਫ਼ਤੇਹ ਕਰੂਂ !
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 311
Posts: 35483
Seattle, WA USA
|
 |
« Reply #35 on: March 29, 2012, 10:55:37 am » |
Cracked! It's because of the Serial.flush(); it just happened to flush the buffer from what was leftover from the previous Serial entry. So, try that on Arduino 1.0.
|
|
|
|
|
Logged
|
|
|
|
|
ਪੰਜਾਬ
Offline
Edison Member
Karma: 4
Posts: 1224
WANTED! A Girl with LOVE for me and Arduino!
|
 |
« Reply #36 on: March 29, 2012, 11:03:33 am » |
So, try that on Arduino 1.0.
Tried in the Serial of Arduino 1.0 working. Sir, the code is too heavy in Arduino 1.0 its about 3842 bytes about 4kb  and in 0022 its about 2.7kb EDIT: 2 problems with using the Arduino 1.0: 1) Very heavy code, almost double as compared to when compiled in 0022. 2) Problems flush isn;t that working. but then there are problems already with the Arduino 1.0 functioning like Wishield's no library works on it, even the library that was good on the 0022.
|
|
|
|
« Last Edit: March 29, 2012, 11:13:00 am by NI$HANT »
|
Logged
|
"Real Men can Accomplish Anything" - Website - skype : nishants5 ਫ਼ਤੇਹ ਕਰੂਂ !
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 311
Posts: 35483
Seattle, WA USA
|
 |
« Reply #37 on: March 29, 2012, 11:12:03 am » |
Tried in the Serial of Arduino 1.0 working. Well, that's interesting, since the Serial.flush() function on 1.0 only affects outgoing data. the code is too heavy in Arduino 1.0 its about 3842 bytes about 4kb and in 0022 its about 2.7kb I'm pretty sure that the Arduino can handle the increased "weight".
|
|
|
|
|
Logged
|
|
|
|
|
ਪੰਜਾਬ
Offline
Edison Member
Karma: 4
Posts: 1224
WANTED! A Girl with LOVE for me and Arduino!
|
 |
« Reply #38 on: March 29, 2012, 11:15:46 am » |
I posted the EDIT in my above post. You are right,Sir, there are problem with Serial.flush() but it works , this function is so smooth in 0022 but jumbles up in 1.0 but works as compared to nothing happening previously. EDIT: I'm pretty sure that the Arduino can handle the increased "weight".
I do not like specially this trait of new Arduino 1.0 IDE , i still use a lot of ATmega8's , infact all this that im doing here im testing and working with a ATmega8, what about guys like us?
|
|
|
|
« Last Edit: March 29, 2012, 11:17:48 am by NI$HANT »
|
Logged
|
"Real Men can Accomplish Anything" - Website - skype : nishants5 ਫ਼ਤੇਹ ਕਰੂਂ !
|
|
|
|
Global Moderator
UK
Online
Brattain Member
Karma: 137
Posts: 19028
I don't think you connected the grounds, Dave.
|
 |
« Reply #39 on: March 29, 2012, 11:28:12 am » |
And does flush still work when you remove the debug prints?
Flush is a sticking plaster fix. A sticking plaster with added anthrax.
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
ਪੰਜਾਬ
Offline
Edison Member
Karma: 4
Posts: 1224
WANTED! A Girl with LOVE for me and Arduino!
|
 |
« Reply #40 on: March 29, 2012, 02:00:15 pm » |
Flush is a sticking plaster fix. A sticking plaster with added anthrax. The behaviour of elements is so irrational and haywire that controlling them all the time becomes messy in Serial, This has worked for me pretty nicely achieving what i want! but then i will manage to make it work without flushing stuff.
|
|
|
|
|
Logged
|
"Real Men can Accomplish Anything" - Website - skype : nishants5 ਫ਼ਤੇਹ ਕਰੂਂ !
|
|
|
|
Global Moderator
UK
Online
Brattain Member
Karma: 137
Posts: 19028
I don't think you connected the grounds, Dave.
|
 |
« Reply #41 on: March 29, 2012, 02:02:50 pm » |
The behaviour of elements is so irrational and haywire that controlling them all the time becomes messy in Serial, I couldn't agree less.
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 311
Posts: 35483
Seattle, WA USA
|
 |
« Reply #42 on: March 29, 2012, 02:16:58 pm » |
I couldn't agree less. Exactly. I am a firm believer in the use of start and end of packet markers because they work so well to avoid NI$HANT's issues, with the need for delay() or flushing anything.
|
|
|
|
|
Logged
|
|
|
|
|
ਪੰਜਾਬ
Offline
Edison Member
Karma: 4
Posts: 1224
WANTED! A Girl with LOVE for me and Arduino!
|
 |
« Reply #43 on: March 29, 2012, 02:19:56 pm » |
I am a firm believer in the use of start and end of packet markers because they work so well to avoid NI$HANT's issues, Yes YES Sir, I also treat them needy so i incorporated the end markers, they are there in the code.
|
|
|
|
|
Logged
|
"Real Men can Accomplish Anything" - Website - skype : nishants5 ਫ਼ਤੇਹ ਕਰੂਂ !
|
|
|
|
|