Page 318 - 완) I MDP 프로젝트 작품 보고서(전체과 1학년)1.6
P. 318

printf("mysql_init  faild!");


               conn_ptr=mysql_real_connect(conn_ptr,HOST,USER,PASS,NAME,10543,(char*)NULL,0);
              if(conn_ptr)

                     printf("connect");
              else
                     printf("disconnect");


                 if  ((fd  =  serialOpen  ("/dev/ttyAMA0",  9600))  <  0)
                {

                  fprintf  (stderr,  "Unable  to  open  serial device: %s\n",  strerror  (errno))  ;
                  return  1  ;
                }


                 if  (wiringPiSetup  ()  ==  -1)
                {

                  fprintf  (stdout,  "Unable  to start wiringPi: %s\n",  strerror  (errno))  ;
                  return  1  ;
                }

                while(1)
              {
                             len=serialGetchar(fd);

                             if(len  ==  'P')
                             {
                                     mysql_query(conn_ptr,"INSERT     INTO    usertable   (code,name,price)

             VALUES  (1,'Pizza',5000)");
                                              /*데이터베이스에  정보  전송*/
                                     //serialPutchar(fd,'P');

                             }
                             if(len  =='C')
                             {

                                     mysql_query(conn_ptr,"INSERT  INTO  usertable  (code,name,price)  values
             (2,'Cola',1000)");
                                     //serialPutchar(fd,'C');

                             }
                             if(len  =='K')
                             {
                                     mysql_query(conn_ptr,"INSERT  INTO  usertable  (code,name,price)  values

             (3,'Cookie',2000)");
                                     //serialPutchar(fd,'K');
                             }




                                                         -  311  -
   313   314   315   316   317   318   319   320   321   322   323