By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,436 Members | 1,344 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,436 IT Pros & Developers. It's quick & easy.

diag_printf

P: n/a
hi all,

I am working in ARM9(AT91rm9200),I need to develop small diagniostic
code to test the configured gpio lines through loopback test(one end I
will write somthing in other end i need to read the same through
registers).

I am not able to print the datatypes (Other than character),While i am
trying to print some garbage value are printed.

with the following lines :

diag_printf ("\r\nConfigured Port A= %x", *(VULONG*)0XFFFFF418);
int gpio_data_counter = 0;
diag_printf("\r\n %d Noordeen\r\n",gpio_data_counter);

void
diag_printf (const char *format,...)
{
int *dataptr = (int *) &format;
char c, str[16];
unsigned long mask = 0xFFFFFFFF;

dataptr++;

while ((c = *(format++)) != 0)
{
if (c != '%')
diag_putchar (c);
else
switch (c = *(format++))
{
case 'b':
mask = 0xFF;
/* Fall down intentionally! */
case 'd':
case 'x':
case 'X':

case 'u':

*convert_to_ascii (str, c , *((unsigned long *) dataptr++) &
mask )= 0;

diag_putstr (str);
break;

case 'c':
diag_putchar ((*(dataptr++)) & 0xff);
break;

case 's':
diag_putstr ((char *) *(dataptr++));
break;
}
}
}

Kindly suggest...

regards,
fazal

May 24 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
fazulu deen wrote:
hi all,

I am working in ARM9(AT91rm9200),I need to develop small diagniostic
code to test the configured gpio lines through loopback test(one end I
will write somthing in other end i need to read the same through
registers).

I am not able to print the datatypes (Other than character),While i am
trying to print some garbage value are printed.

with the following lines :

diag_printf ("\r\nConfigured Port A= %x", *(VULONG*)0XFFFFF418);
int gpio_data_counter = 0;
diag_printf("\r\n %d Noordeen\r\n",gpio_data_counter);

void
diag_printf (const char *format,...)
{
That is not how you do it.

Look up the va_start, va_arg and va_end macros. Use those to manipulate
functions with variable arguments

http://www.dinkumware.com/manuals/de...ge=stdarg.html
john
May 24 '07 #2

P: n/a
Hi john,

thanks for the reply..I am afraid it is working fine only for
characters...Wats wrong in the specified codes....diag_printf once
worked properly...wat has to done to use the same code without
changing..where i am wrong??

regards,
fazal

May 24 '07 #3

P: n/a
On Thu, 24 May 2007 07:40:33 GMT in comp.lang.c++, John Harrison
<jo*************@hotmail.comwrote,
>Look up the va_start, va_arg and va_end macros. Use those to manipulate
functions with variable arguments
See also:
http://groups.google.com/gr*********....earthlink.net

May 24 '07 #4

P: n/a
On 24 May, 09:06, fazulu deen <fazulu.v...@gmail.comwrote:

Please quote some context in your reply so your post can be read and
understood without having to look back up the thread at other posts.
Thanks. Meta-context added back in.

[Question about variadic function that wasn't working as expected.
Code didn't use standard method of variadic function parameters]

[Response suggested the use of va_start, va_arg and va_end]
Hi john,

thanks for the reply..I am afraid it is working fine only for
characters...Wats wrong in the specified codes....diag_printf once
worked properly...wat has to done to use the same code without
changing..where i am wrong??
Did you look up the variadic function macros John Harrison suggested?
Have you rewritten the function to use them? They are the only
standard way to achieve what you want. There may be some platform-
specific alternative solution. It seems you have two choices:

1. If you want the standard solution, look up the variadic function
macros and rewrite your function to use them. If you have any problems
with that, people here should be able to help.

2. If you think there is a platform-specific solution and you can get
this function working without using the standard variadic function
macros, you will need to ask for help from a group that knows your
platform. comp.lang.c++ won't be able to help you.

Gavin Deane

May 24 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.