Show Posts
Pages: [1]
1  Development / Suggestions for the Arduino Project / Re: if(a=b) is not if(a==b) could IDE check this b4 upload? on: February 12, 2011, 11:59:08 pm
I'd like to add another voice to this being an issue.  I'm not a full-time developer and so when I get the time to work on Arduino, I can be a little rusty.  I have wasted more hours than I care to admit tracking down problems that turned out to be precisely this.  I would call it my #1 "d'oh" bug and I've tried to train myself to look for this particular problem whenever things go awry.  Alas, I forget.

Anyway, if turning on compiler options would be an option, I'd be all for it.

Charlie O.
2  Forum 2005-2010 (read only) / Syntax & Programs / Re: Debug C with printf to Arduino serial monitor? on: March 09, 2010, 03:27:22 pm
Very interesting Ben and thank you for this info.  

So you are saying that if I rename to CPP, I can use any of Arduino's functions in that file?  To use Serial,print, will I just need to #include WProgram.h or others as well?

If using CPP allows one to inherit all the Arduino functions, then here's another dumb question: Wouldn't CPP then be the preferred choice for any add-on code...excepting for the case that one needs some C function not allowed in C++?  Are there other downsides?

Context: I am using Asynclabs WiShield.  The webserver code which they provide is .c and now I'm wondering why not cpp.

Thanks again to all,
Charlie
3  Forum 2005-2010 (read only) / Syntax & Programs / Re: Debug C with printf to Arduino serial monitor? on: March 09, 2010, 02:06:23 am
So this was a good idea but I understand that Serial class is a c++ object which means I won't be able to access it from a .c file.

Is there any way to direct printf output to the Arduino serial monitor?

Other suggestions?

Thanks,
Charlie
4  Forum 2005-2010 (read only) / Syntax & Programs / Re: Debug C with printf to Arduino serial monitor? on: March 08, 2010, 08:22:55 am
Yes, this is a second tab with a .c file where I'm having the challenge.  No problem at all getting serial monitor output from the usual Arduino code file...it's just the .c file where I'm guessing there's a slightly different approach that I need to understand.
5  Forum 2005-2010 (read only) / Syntax & Programs / Re: Debug C with printf to Arduino serial monitor? on: March 08, 2010, 01:06:26 am
@thatSteve,

I have Serial.begin(115200); in the arduino code in the setup section.  For grins, I tried also adding this to the C file (where the Serial.prints are being called out and received the following message from the compiler while highlighting Serial.begin(115200);

error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token

I really don't know what this message means.

This is different than the prior message about 'Serial' undeclared (first use in this function)

Don't get it...

Thanks for the help.

Charlie
6  Forum 2005-2010 (read only) / Syntax & Programs / Re: Debug C with printf to Arduino serial monitor? on: March 07, 2010, 10:42:57 pm
I should be more specific.  The error I'm getting is 'Serial' undeclared (first use in this function).

So I guess the overall question is "what do I need to do to use Serial.print" within c code that's part of my sketch?

Thanks again,
Charlie
7  Forum 2005-2010 (read only) / Syntax & Programs / Re: Debug C with printf to Arduino serial monitor? on: March 07, 2010, 10:20:19 pm
Thanks.  That's what I first tried but the compiler is complaining that it doesn't understand the serial function in the C code.  Is there a library I need to #INCLUDE in the C code?

Thanks again,
Charlie
8  Forum 2005-2010 (read only) / Syntax & Programs / Debug C with printf to Arduino serial monitor? on: March 07, 2010, 01:56:37 pm
Hi,

I'm new to using a C file in conjunction with an Arduino sketch.  The sketch including the C code is full running but now I'm trying to change the C code and I need to debug it.

I'm new to C.  How do I set up and use printf from the C code so that it will output to the Arduino serial monitor?  Is there a preferred method other than printf?

Thanks!
Charlie O
9  Forum 2005-2010 (read only) / Interfacing / Re: arduino simulator on: April 18, 2010, 07:31:45 pm
@VBB,

Great news on the CPP files!

One other thing that I've noticed but that might be more difficult...it seems that the systems does not like compiler directives (e.g. DEFINE) after any code statements.  Don't know if that's a complex part of the parser or easy but would be helpful to not have to have the constraint.

Thanks again,
Charlie
10  Forum 2005-2010 (read only) / Interfacing / Re: arduino simulator on: April 18, 2010, 01:42:19 am
@VBB

This looks great!

I have a sketch that has a PDE file and three cpp files.  Will that work here?  How to I add the cpp's?

Thanks,
Charlie O.
11  Forum 2005-2010 (read only) / Troubleshooting / Re: How can I veryfy that I'm connected to Arduino BT? on: April 20, 2009, 03:17:54 pm
Did you ever figure this out.  I just got mine working with Windows.

Charlie O.
12  Forum 2005-2010 (read only) / Uno Punto Zero / Suggest: Warn on = vs == in "if" statement on: May 27, 2010, 10:26:52 pm
I bet this is an old topic and there are lots of opinions on the subject.  But I can't tell you how many times I've inadvertently typed "if (x=y)" when I meant "if (x==y)" and then wasted time trying to figure out what was wrong until I spotted this typo.  I can only imagine how many beginners get nailed by this over and over.

Of if we don't like warnings, another suggestion would be a compiler switch that by default doesn't allow a single = in an "if" unless you override the switch.  Only experienced programmers are going to demand assignment within an "if" anyway and this surely seems like something where we're unnecessarily burdening newbies.

Charlie
Pages: [1]