linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* I2C: Getting Compiation Error for application program
@ 2006-09-20 12:51 Sachin Rane
  2006-09-21  9:13 ` Matthias Fuchs
  0 siblings, 1 reply; 3+ messages in thread
From: Sachin Rane @ 2006-09-20 12:51 UTC (permalink / raw)
  To: linux-users-list; +Cc: i2c, linuxppc-embedded

[-- Attachment #1: Type: text/plain, Size: 1093 bytes --]

Hi,
 
I am trying to compile simple program (appended), but getting lots of compilation error.
I am using Timesys Linux 2.6.13 for ppc440 evaluation board. 
 
Command used for compilation:
$> gcc eeprom-client.c -o eeprom-client.o
 
Could you help me to find out the reason behind getting the errors?
 
Regards,
Sachin Rane
 
 
8< ------------------------eeprom-client.c -------------------------------------------------------------------------------------
 
#include <linux/i2c.h>
#include <linux/i2c-dev.h>

int main()
{
     int file;
     int adapter_nr = 0; /* probably dynamically determined */
     char filename[20];
     int addr = 0xA1; /* The I2C address */

    sprintf(filename,"/dev/i2c-%d",adapter_nr);
    if ((file = open(filename,O_RDWR)) < 0)
   {
       exit(1);
    }
   
    if (ioctl(file,I2C_SLAVE,addr) < 0)
   {
      exit(1);
   }
   else
  {
      printf("\n Able to bind the adapter");
   }
   return 0;
}

8< -------------------------------------------------------------------------------------------------------------

[-- Attachment #2: Type: text/html, Size: 2423 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: I2C: Getting Compiation Error for application program
  2006-09-20 12:51 I2C: Getting Compiation Error for application program Sachin Rane
@ 2006-09-21  9:13 ` Matthias Fuchs
  2006-09-21 11:10   ` Sachin Rane
  0 siblings, 1 reply; 3+ messages in thread
From: Matthias Fuchs @ 2006-09-21  9:13 UTC (permalink / raw)
  To: linuxppc-embedded; +Cc: Sachin Rane

On Wednesday 20 September 2006 14:51, Sachin Rane wrote:
> Hi,
>  
> I am trying to compile simple program (appended), but getting lots of 
compilation error.
It's always helpful to see the compiler output. Could you post it?

> I am using Timesys Linux 2.6.13 for ppc440 evaluation board. 
>  
> Command used for compilation:
> $> gcc eeprom-client.c -o eeprom-client.o
Are you crosscompiling? Doesn't look like that...
>  
> Could you help me to find out the reason behind getting the errors?
>  
> Regards,
> Sachin Rane
>  
>  
> 
8< ------------------------eeprom-client.c -------------------------------------------------------------------------------------
>  
> #include <linux/i2c.h>
> #include <linux/i2c-dev.h>
> 
> int main()
> {
>      int file;
>      int adapter_nr = 0; /* probably dynamically determined */
>      char filename[20];
>      int addr = 0xA1; /* The I2C address */
You propably have to use 0x50 here. 
> 
>     sprintf(filename,"/dev/i2c-%d",adapter_nr);
>     if ((file = open(filename,O_RDWR)) < 0)
>    {
>        exit(1);
>     }
>    
>     if (ioctl(file,I2C_SLAVE,addr) < 0)
>    {
>       exit(1);
>    }
>    else
>   {
>       printf("\n Able to bind the adapter");
>    }
>    return 0;
> }

Matthias

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: I2C: Getting Compiation Error for application program
  2006-09-21  9:13 ` Matthias Fuchs
@ 2006-09-21 11:10   ` Sachin Rane
  0 siblings, 0 replies; 3+ messages in thread
From: Sachin Rane @ 2006-09-21 11:10 UTC (permalink / raw)
  To: Matthias Fuchs; +Cc: linuxppc-embedded

[-- Attachment #1: Type: text/plain, Size: 3396 bytes --]

Hello Matthias,
 
Thanks for the reply.
 
I got the reason from i2c mailing list on getting compilation errors. 
 
A text from the I2C mailing list :
8<---------------------------------------------------------------------------------------
"All the above it caused by you including <linux/i2c.h>. As explained
before, this is a kernel-only header file, which you must _not_ include
in user-space code. You are not the only one to blame though, as in
fact this header file should not be in /usr/include at all, this is a
mistake which should be fixed "soon". "
--------------------------------------------------------------------------------------->8
 
Some of the error lines are appended for your reference.
 
Now I will do the changes in the code as per above above suggestion.
 
Tnaks and Regards,
Sachin Rane

 
> -bash-2.05b# gcc eeprom-client.c
> In file included from /usr/include/asm/div64.h:1,
>                  from /usr/include/linux/jiffies.h:9,
>                  from /usr/include/linux/sched.h:12,
>                  from /usr/include/linux/module.h:10,
>                  from /usr/include/linux/i2c.h:31,
>                  from eeprom-client.c:1:
> /usr/include/asm-generic/div64.h:54:3: #error do_div() does not yet support the C64
> In file included from /usr/include/linux/sched.h:12,
>                  from /usr/include/linux/module.h:10,
>                  from /usr/include/linux/i2c.h:31,
>                  from eeprom-client.c:1:
> /usr/include/linux/jiffies.h:84: error: parse error before "jiffies_64"
> /usr/include/linux/jiffies.h:88: error: parse error before "get_jiffies_64"
> In file included from /usr/include/linux/sched.h:12,
>                  from /usr/include/linux/module.h:10,
>                  from /usr/include/linux/i2c.h:31,
>                  from eeprom-
 
 

________________________________

From: Matthias Fuchs [mailto:matthias.fuchs@esd-electronics.com]
Sent: Thu 9/21/2006 5:13 AM
To: linuxppc-embedded@ozlabs.org
Cc: Sachin Rane
Subject: Re: I2C: Getting Compiation Error for application program



On Wednesday 20 September 2006 14:51, Sachin Rane wrote:
> Hi,
> 
> I am trying to compile simple program (appended), but getting lots of
compilation error.
It's always helpful to see the compiler output. Could you post it?

> I am using Timesys Linux 2.6.13 for ppc440 evaluation board.
> 
> Command used for compilation:
> $> gcc eeprom-client.c -o eeprom-client.o
Are you crosscompiling? Doesn't look like that...
> 
> Could you help me to find out the reason behind getting the errors?
> 
> Regards,
> Sachin Rane
> 
> 
>
8< ------------------------eeprom-client.c -------------------------------------------------------------------------------------
> 
> #include <linux/i2c.h>
> #include <linux/i2c-dev.h>
>
> int main()
> {
>      int file;
>      int adapter_nr = 0; /* probably dynamically determined */
>      char filename[20];
>      int addr = 0xA1; /* The I2C address */
You propably have to use 0x50 here.
>
>     sprintf(filename,"/dev/i2c-%d",adapter_nr);
>     if ((file = open(filename,O_RDWR)) < 0)
>    {
>        exit(1);
>     }
>   
>     if (ioctl(file,I2C_SLAVE,addr) < 0)
>    {
>       exit(1);
>    }
>    else
>   {
>       printf("\n Able to bind the adapter");
>    }
>    return 0;
> }

Matthias



[-- Attachment #2: Type: text/html, Size: 6315 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-09-21 11:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-20 12:51 I2C: Getting Compiation Error for application program Sachin Rane
2006-09-21  9:13 ` Matthias Fuchs
2006-09-21 11:10   ` Sachin Rane

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).