PIC vs ATMEL #2 volt most: LOVE C
Andras Tantos
andras_tantos at yahoo.com
Thu Feb 12 17:06:31 CET 2004
Hali!
Csak most kapcsolodom be a vitaba, most se nagyon...
> > Ez mukodik:
> > ------------
> > if(comm_newcmd0){
> > if( comm_ibuf0[comm_ibuf0[2]-'@'] ==
> > w1_crcgen((uchar*)&comm_ibuf0[0],comm_ibuf0[2]-'@') ) {
> > if( sscanf(comm_ibuf0,"<BMHP%5f%3u%*c",&temp_f,&temp_c)!=2 ) {
> > d_main->tmp=0,d_main->hum=0;
> > myprintf(SER1,"SHT scanf error\r\n");
> > }
> > d_main->tmp=temp_f;
> > d_main->hum=temp_c;
> > }
> > else {
> > myprintf(SER1,"SHT CRC error\r\n");
> > }
> > comm_newcmd0=0;
> > }
> >
> > Ez meg nem:
> > ------------
> > if(comm_newcmd0){
> > if( comm_ibuf0[comm_ibuf0[2]-'@'] ==
> > w1_crcgen((uchar*)&comm_ibuf0[0],comm_ibuf0[2]-'@') ) {
> > if(
> > sscanf(comm_ibuf0,"<BMHP%5f%3u%*c",d_main->tmp,d_main->hum)!=2 ) {
> > d_main->tmp=0,d_main->hum=0;
> > myprintf(SER1,"SHT scanf error\r\n");
> > }
> > }
> > else {
> > myprintf(SER1,"SHT CRC error\r\n");
> > }
> > comm_newcmd0=0;
> > }
> >
> > A scanf bugzik...Az a lenyeges sor.
> > Ha egy strukturaelemre mutato pointeren keresztul irom a struktura
elemet,
> > akkor a kovetkezo strukturaelembe
> > is belenyul (masodik variáció).
> > Ha meg beteszem atmeneti valtozoba(első variácó), és utana toltom be,
> akkor
> > oke minden.
> >
> > Az a gyanum, hogy a scanf körül van vmi galiba...Vagy én nem használom
jól
> a
> > formátumstringjét, vagy nemtom.
> > Van valakinek tippje?
Kimaradt egy-egy &. Helyesen igy nez ki:
if( sscanf(comm_ibuf0,"<BMHP%5f%3u%*c",&(d_main->tmp),&(d_main->hum))!=2 ) {
Vannak fordito-hibak? Persze. De a forditok speciel eleg jol tesztelt (mert
aranylag jol tesztelheto) programok, a hibak zome szinte sose hasznalt
specialis esetek korul merulnek fel. En eddig egy emberrel beszeltem, aki
latott fordito-hibat (es nem fordito fejlesztesen dolgozott). De o is egy
alpha-verziot hasznalt.
Udv,
Tantos Andras
<http://andras.tantos.homedns.org>
More information about the Elektro
mailing list