Go to Post So my mom gave up most of the house to robotics.... - ElfMaster [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 03-11-2004, 13:09
cbolin's Avatar
cbolin cbolin is offline
Programming & Electrical
FRC #0342 (Burning Magnetos)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Charleston, SC
Posts: 72
cbolin is a splendid one to beholdcbolin is a splendid one to beholdcbolin is a splendid one to beholdcbolin is a splendid one to beholdcbolin is a splendid one to beholdcbolin is a splendid one to beholdcbolin is a splendid one to behold
printf problem

Hi,
I am trying to print the examples in the printf_lib.c commented examples.
I initialized the variables as directed and then called the following each second.

Code:
printf("%s\n",StrPtr);                             //will display 'Hello world!'
printf("X = %d, Y = %x, Z = %lx\n",x,y,z); // will display 'X = 15'
                                                         // 'Y = 0x50'
                                                         // 'Z  = deadface'

printf("X = %b (base 2)\n",x);                 // will display 'X = 1111 (base 2)'
printf("X = %16b\n",x);                         // will display 'X =
                                                        // 0000000000001111'
printf("X = %04x\n",x);                         // will display 'X = 000f'
Here are the results printed to the IFI_Loader Terminal.

Code:
H
  1  5  ddf    1   01  0

...sometimes I get this...

H
  1  5  ddf= 12  01 0
My printf isn't processing all the characters...only the first it seems. Any thoughts on how to get this working? A UART initialization problem? My PC?

Regards,
ChuckB
__________________
Team 342 Programming & Control Systems
Good luck and have fun!
  #2   Spotlight this post!  
Unread 03-11-2004, 15:03
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Re: printf problem

Quote:
Originally Posted by cbolin
Hi,
I am trying to print the examples in the printf_lib.c commented examples.
I initialized the variables as directed and then called the following each second.

Code:
printf("%s\n",StrPtr);                             //will display 'Hello world!'
printf("X = %d, Y = %x, Z = %lx\n",x,y,z); // will display 'X = 15'
                                                         // 'Y = 0x50'
                                                         // 'Z  = deadface'

printf("X = %b (base 2)\n",x);                 // will display 'X = 1111 (base 2)'
printf("X = %16b\n",x);                         // will display 'X =
                                                        // 0000000000001111'
printf("X = %04x\n",x);                         // will display 'X = 000f'
Here are the results printed to the IFI_Loader Terminal.

Code:
H
  1  5  ddf    1   01  0

...sometimes I get this...

H
  1  5  ddf= 12  01 0
My printf isn't processing all the characters...only the first it seems. Any thoughts on how to get this working? A UART initialization problem? My PC?

Regards,
ChuckB
Transmitting before initializing the UART results in the notorious red-green light problem. As for bad initialization, I can't tell you.

IFI's implementation of printf doesn't do all the control codes that the PC versions use. But the code given is copied from printf_lib.c (lines 19 through 27)

It looks like it's loosing characters, either totally or just garbled. They come through interminently, but when they come in they are intact. (a baud-rate mismatch usually results in framing errors, garbage, and/or extra/lost bytes)

When I can get the config dialog fixed, I'll upload Comm Test to my site (to http://endeavour.zapto.org/astro73/programs/). The version that is up at the moment is broken.
  #3   Spotlight this post!  
Unread 03-11-2004, 17:48
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,562
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: printf problem

What type of computer are you using, and what type of connection to the RC?
  #4   Spotlight this post!  
Unread 08-11-2004, 01:39
eugenebrooks eugenebrooks is offline
Team Role: Engineer
AKA: Dr. Brooks
no team (WRRF)
 
Join Date: Jan 2004
Rookie Year: 2001
Location: Livermore, CA
Posts: 601
eugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond repute
Re: printf problem

Quote:
Originally Posted by cbolin
Hi,
My printf isn't processing all the characters...only the first it seems. Any thoughts on how to get this working? A UART initialization problem? My PC?

Regards,
ChuckB
Explicitly cast the integer arguments being provided to printf
to the desired type. If x is an int, y is a int, and z is a long,
use: printf("%d %d %lx\n", (int)x, (int)y, (long)z);

The default way in which arguments are pushed, for routines
that do not have their arguments declared, is char. This is a
property of the MicroChip C-Bot compiler enironment. You may
influence this behavior by changing settings, but who knows what
else will break if you do that. The only place the problem seems
to appear is the printf calls, because the arguments for all the
other routines are explicitly declared. It is not hard to provide
the required type casts to the printf calls.

The fact that you can't print a long using the provided printf()
is quite a bother. If you would like a routine that addresses that
problem, refer to the file pl.c available in the EiC.zip file available
in the technical page at www.srvhsrobotics.org The code involved
is described in the programming tutorial (well, perhaps not quite
a tutorial) available from the same web page.

Eugene
  #5   Spotlight this post!  
Unread 09-11-2004, 02:44
eugenebrooks eugenebrooks is offline
Team Role: Engineer
AKA: Dr. Brooks
no team (WRRF)
 
Join Date: Jan 2004
Rookie Year: 2001
Location: Livermore, CA
Posts: 601
eugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond repute
Re: printf problem

Quote:
Originally Posted by eugenebrooks
Explicitly cast the integer arguments being provided to printf to the desired type.
Eugene
I was obviously answering the wrong question! Sorry...
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Anyone with a replacement Printf? Larry Barello Programming 5 19-03-2004 02:20
Victor problem Andy Baker Electrical 15 24-06-2003 09:49
Ok one problem cantwell03 Programming 3 13-02-2003 07:28
The problem with scouting... archiver 2001 10 23-06-2002 23:49
Major problem with chipphua motors aka Scott White Motors 18 19-03-2002 19:44


All times are GMT -5. The time now is 20:01.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi