<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2523" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>
<DIV><FONT face=Arial size=2>hello, </FONT></DIV>
<DIV><FONT face=Arial size=2>I am new in the programming of the CHARONII, I test
dialogue I2C (PCF857AP). </FONT></DIV>
<DIV><FONT face=Arial size=2>I write without problem, but not to
read with a pointer !? can somebody explain
me? </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> here part of my code, with < dev/twif.h
></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> thank you in advance</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Joel</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>static char buff[128];<BR>static u_char
BuffRead[8];</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>../..</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>void ProcessRequests(FILE *
stream)<BR>{<BR> int got, i;<BR> char
*cp;<BR> u_char write[8];<BR>
<BR>
TwInit(0x39);<BR> write[0]=0x80;<BR> <BR>
for (;;) {<BR> <BR>
/*<BR> * Flush output and read a
line.<BR>
*/<BR>
fflush(stream);<BR> if (fgets(buff,
sizeof(buff), stream) == 0) //lit une ligne venant du
stream<BR>
break;<BR> <BR>
/*<BR> * Chop off
EOL.<BR>
*/<BR> if ((cp = strchr(buff, '\r'))
!= 0)<BR> *cp
= 0;<BR> if ((cp = strchr(buff, '\n'))
!= 0)<BR> *cp
= 0;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>
/*<BR> * Ignore blank
lines.<BR>
*/<BR> got =
strlen(buff);<BR> if (got ==
0)<BR>
continue;<BR> <BR>
<BR> if (strncmp("write PCF8574AP", buff, got) ==
0) {<BR> fputs("write on PCF8574AP ads :0x39 led:
8 on \r\n", stream);<BR> fputs("send value > ",
stream); <BR> write[0]=128;<BR>
fprintf(stream,"%d\r\n",write[0]);<BR>
write[0]=255-write[0]; // reverse state<BR>
TwMasterTransact(0x39,&write,1,0,0,500);<BR>
fputs("Slave State after = ", stream);<BR>
TwMasterTransact(0x39,0,0,BuffRead,1,500);<BR>
for( i=0 ; i < 1;i++) fprintf(stream,"%d\r\n",255-TWDR); //with TWDR is
OK ! > value is
128<BR> continue;<BR> }<BR>
<BR> <BR> if (strncmp("read PCF8574AP ", buff, got) == 0)
{<BR> fputs("test read PCF8574AP ads :
0x39 \r\n", stream);<BR> fputs("Read Slave
State = ", stream); <BR> for( i=0 ; i <
TwMasterTransact(0x39,0,0,BuffRead,8,500) +1;i++)
fprintf(stream,"%d\t",255-BuffRead[i]); // !! value is 0
!!<BR>
continue;<BR>
}</FONT></DIV></FONT></DIV></BODY></HTML>