Linux / UNIX Tech Support Forum
This is a discussion on how to connect mysql to my c program ... within the Databases servers forums, part of the Mastering Servers category; hi everyone... Can anyone help me to build the code to link my c language to the mysql server...this program ...
|
|||||||
| Databases servers Discussions of databases of all types - especially MySQL. |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
hi everyone...
Can anyone help me to build the code to link my c language to the mysql server...this program wiill receive the data from the RFID tag using the serial connection then the data will send into mysql server.. now i dont now how to write the program to connection to mysql server .... Can you all help me.... this my code to get the data from serial .. #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <termios.h> #include <stdio.h> #include <string.h> #define BAUDRATE B2400 #define MODEMDEVICE "/dev/ttyr01" #define _POSIX_SOURCE 1 #define FALSE 0 #define TRUE 1 volatile int STOP=FALSE; main() { int fd,c,res,i; struct termios oldtio , newtio; char buf[20]; FILE *fid; fd = open(MODEMDEVICE, O_RDWR | O_NOCTTY); if (fd<0) {perror(MODEMDEVICE); exit(-1); } tcgetattr (fd,&oldtio); bzero(&newtio, sizeof(newtio)); newtio.c_cflag = BAUDRATE | CRTSCTS | CS8 | CLOCAL | CREAD; newtio.c_iflag = IGNPAR | ICRNL; newtio.c_oflag = 0; newtio.c_lflag = ICANON; tcflush(fd, TCIFLUSH); tcsetattr (fd,TCSANOW, &newtio); char id [16]; printf("Opening COm Port : %s\n\n",MODEMDEVICE); fid = fopen ("data1.dat","w+"); if (fid<0) printf ("Error \n"); while (STOP==FALSE) { res = read(fd,buf,16); buf[res]=0; strcpy(id,buf); fprintf(fid,"ID: %\n", id); printf("ID: %s\n", buf); } fclose(fid); tcsetattr(fd,TCSANOW,&oldtio); } |
| Sponsored Links | ||
|
|
|
||||
|
__________________
Vivek Gite Linux Evangelist |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| is any one good in c program ? | oronno | Shell scripting | 0 | 19-09-2007 01:04 PM |
| Connect mysql in c | raj | Databases servers | 1 | 10-08-2007 08:10 PM |
| start program | schaapmansz | Getting started tutorials | 1 | 26-06-2007 09:49 PM |
| mysql connect failed for root | raghuram | Databases servers | 1 | 15-02-2007 11:06 AM |
| Failed in mysql_real_connect(): Can't connect to local MySQL | Linux software | 1 | 17-07-2006 02:05 AM | |