Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12590 Discussions

Printing 32bit signed long data alt_32

Chloé_Russell
Beginner
1,566 Views

Hi,

 

I'm trying to print out returned alt_32 data from functions defined in drivers via the JTAG UART in a Nios II system. Execuse me for being newbie on this, here are my code lines:

 

alt_32 ret_code;

 

ret_code = altera_epcq_controller_init ("/dev/epcq_controller_0");

 

printf("ret_code     = %x \n", (unsigned int) ret_code);

 

it returns an hexa value but I need to print out the following format:

-EINVAL

-EIO

 

Thank you for telling me what I suppose to write for printing out the alt_32 data.

0 Kudos
2 Replies
JOHI
New Contributor II
725 Views

Hello,

The only solution is do something like

#include "ErrNo.h"

 

if (ret_code == EIO) printf("EIO");

 

EIO is a symbol that is defined in one of the header files. (ERRNO.H)

The preprocessor replaces EIO with a decimal or hex value of 5 before compiling.

 

See below an extract of the file:

/*

 * Error numbers.

 * TODO: Can't be sure of some of these assignments, I guessed from the

 * names given by strerror and the defines in the Cygnus errno.h. A lot

 * of the names from the Cygnus errno.h are not represented, and a few

 * of the descriptions returned by strerror do not obviously match

 * their error naming.

 */

#define EPERM 1 /* Operation not permitted */

#define ENOFILE 2 /* No such file or directory */

#define ENOENT 2

#define ESRCH 3 /* No such process */

#define EINTR 4 /* Interrupted function call */

#define EIO 5 /* Input/output error */

#define ENXIO 6 /* No such device or address */

#define E2BIG 7 /* Arg list too long */

#define ENOEXEC 8 /* Exec format error */

#define EBADF 9 /* Bad file descriptor */

#define ECHILD 10 /* No child processes */

#define EAGAIN 11 /* Resource temporarily unavailable */

#define ENOMEM 12 /* Not enough space */

#define EACCES 13 /* Permission denied */

#define EFAULT 14 /* Bad address */

/* 15 - Unknown Error */

 

 

Best regards,

Johi.

Chloé_Russell
Beginner
725 Views

Hi JOHI,

 

Thank you for your reply, this helped me too much..

 

Best regards

CR

0 Kudos
Reply