|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Problem with printf()
I'm getting the weirdest syntax error ever. My code is as follows (This is in the user_routines.c file)
Code:
void Process_Data_From_Master_uP(void)
{
printf("lkjhjasfdkjhashddsfkjlkasdhfdlkjkljsadhfklkjasjdhf");
// for debugging
static int counter = 0;
static int counter = 0; The error returned is: Code:
C:\2008_code_svn\08_bot_working\user_routines.c:199:Error: syntax error Halting build on first failure as requested. BUILD FAILED: Mon Jan 28 18:17:43 2008 |
|
#2
|
||||
|
||||
|
Re: Problem with printf()
Quote:
If that is indeed the problem, I would have hoped that C18 would have given a better error message. Sadly, C18 seems to do a poor job with errors in general from what I have seen. |
|
#3
|
||||
|
||||
|
Re: Problem with printf()
The problem is that you are declaring a variable after you've begun to give commands. C doesn't like this, but isn't very informative when it spits up 'syntax error.' (At least I'm pretty sure.) Anyway, I don't know why the printfs further on aren't printing, but try using your printf after the counter is declared.
|
|
#4
|
|||
|
|||
|
Re: Problem with printf()
Thanks for all of your help, but I'm still having trouble getting this working. I've moved the printf statement to below all the variable declarations. The code compiles fine with no errors or warnings, but the printf still doesn't work.
Our software mentor should be showing up in a few hours, so hopefully he'll be able to help if I can't get it working by then, but I'd like to solve this as soon as possible because it's holding up the testing of our robot. Here is the code as it looks now. I'm pretty sure there isn't anything wrong with it, but I can't explain the fact that it doesn't work. I'd like to post more relevant sections, but I'm getting 0 errors and 0 warnings. Code:
void Process_Data_From_Master_uP(void)
{
// for debugging
static int counter = 0;
unsigned char byte_count;
unsigned char data;
unsigned char j;
printf("akjsdfusdhafkjsa");
Getdata(&rxdata);
|
|
#5
|
|||
|
|||
|
Re: Problem with printf()
Make sure that you have included stdio.h at the begining of the program like so
Code:
#include <stdio.h> Code:
-mL -nw=2066 -D_FRC_BOARD Code:
-Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa- -mL -nw=2066 -D_FRC_BOARD |
|
#6
|
||||
|
||||
|
Re: Problem with printf()
Quote:
printf("akjsdfusdhafkjsa\r\n"); -Kevin |
|
#7
|
|||
|
|||
|
Re: Problem with printf()
That seems curious, Kevin. We've done printf's without "\r\n" at all, and it still works.
|
|
#8
|
||||
|
||||
|
Re: Problem with printf()
Quote:
-Kevin |
|
#9
|
|||
|
|||
|
Re: Problem with printf()
I've had some odd problems with printf myself, though I've never had a problem with \r\n.
When I used a printf with about seven %d's, something that should have shown up as a 1 or 0 was printing about 150. It wasn't until I tried using separate printf's for each value that I found that it had either swapped or skipped some of the values and was printing an input from the joystick where it should have been printing a digital input. |
|
#10
|
|||
|
|||
|
Re: Problem with printf()
I'd like to thank everyone again for their help.
Here's how we solved it: There was a lot of code not working in addition to the printf(). However, I discovered some printf()s that were actually working, in a different section of the code. It turns out that we had to have the operator interface plugged in for that code to work. We scratched our heads for awhile about this and came to the conclusion (one of us finally remembered) that without a connection to the OI, the watchdog processor must set all PWMs & Relays to 127 & 0, respectively. Upon further investigation and testing, we think that with no connection to the OI, the process_data_from_master_up() function never gets called from main.c However, once a connection with the OI has been established and then lost, the RC keeps printing whatever it should have been printing before the connection to the OI was lost. The reason we took so long to hook the OI up was that we were under the assumption that we had had this code working and printing before without an OI connection in the past. We now believe that perhaps we did have a connection to the OI at the time we were testing, but simply didn't remember that we hooked it up. This thread has still yielded some good advice. I was not aware that putting commands before all vars were declared was incorrect, and I now have a couple things to try when my printf()s stop working in the future. Again, thank you everyone for your help. |
|
#11
|
|||||
|
|||||
|
Re: Problem with printf()
Quote:
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| printf problem | miketwalker | Programming | 7 | 31-01-2005 13:19 |
| printf problem | cbolin | Programming | 4 | 09-11-2004 02:44 |
| Anyone with a replacement Printf? | Larry Barello | Programming | 5 | 19-03-2004 02:20 |
| printf isn't printf-ing. Help! | Meandmyself | Programming | 14 | 15-02-2004 16:27 |