Exemple #1
0
int main(){

	struct termios tio;
	int tty_fd;
	fd_set rdset;
	unsigned char c=0;
	char buffer[255]; 
	char *bufptr; 
	int nbytes; 
	int fd;
	void* file_memory;
	int pos=0;

	//Prepare the mapped Memory file
	preparemappedMem();	

	RMC_DATA gpsRMCData;

	memset(&tio,0,sizeof(tio));
	tio.c_iflag=0;
	tio.c_oflag &= ~OPOST; //0;
	tio.c_cflag &= CREAD|CLOCAL;
	tio.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); // (ICANON | ECHO | ECHOE);
	tio.c_cc[VMIN]=0;
	tio.c_cc[VTIME]=0;

	tty_fd=open("/dev/ttyS1", O_RDWR | O_NONBLOCK);
	cfsetospeed(&tio,B9600);
	cfsetispeed(&tio,B9600);
	tcsetattr(tty_fd,TCSANOW,&tio);

	writeMessageToPort(enableTenHz, sizeof(enableTenHz), tty_fd);
	//readResponse();
	writeMessageToPort(disableAllMessages, sizeof(disableAllMessages), tty_fd);
	writeMessageToPort(enableRMC, sizeof(enableRMC), tty_fd);

	bufptr = buffer;
	while (1)
	{

		/* read characters into our string buffer until we get a CR or NL */
		nbytes = 0;
		
		while((nbytes=read(tty_fd,bufptr,buffer+sizeof(buffer)-bufptr-1))>0)
		{
			bufptr += nbytes;
			if (bufptr[-2] == '\r' && bufptr[-1] == '\n') {	
				*bufptr = '\0';
				bufptr = buffer;
				//printf("*** %s ***",buffer);				
				parseGPRMC(buffer, &gprmc);
				//printf("%d\r\n",gprmc.timeSecond);
				toXMLfile(&gprmc);
				//memset(&buffer,'\0',sizeof(buffer));	
			}
		}
	}

  return(0);
}
Exemple #2
0
int main(){

	struct termios tio;

	fd_set rdset;
	unsigned char c=0;
	char buffer[255]; 
 int tty_fd;
	
	int fd;
	void* file_memory;
	int pos=0;

	
	RMC_DATA gpsRMCData;

	memset(&tio,0,sizeof(tio));
	tio.c_iflag=0;
	tio.c_oflag &= ~OPOST; //0;
	tio.c_cflag &= CREAD|CLOCAL;
	tio.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); // (ICANON | ECHO | ECHOE);
	tio.c_cc[VMIN]=1;
	tio.c_cc[VTIME]=0;

	tty_fd=open("/dev/ttyS3", O_RDWR | O_NONBLOCK);
	cfsetospeed(&tio,B9600);
	cfsetispeed(&tio,B9600);
	tcsetattr(tty_fd,TCSANOW,&tio);

	writeMessageToPort("AT\r\n", sizeof("AT\r\n"), tty_fd);
	usleep(100000);
	read_port(tty_fd);

	//writeMessageToPort("AT+NSTAT=?\r\n", sizeof("AT+NSTAT=?\r\n"), tty_fd);
	//usleep(100000);
	//read_port(tty_fd);
	


/*	writeMessageToPort("AT+NSET=192.168.0.1,255.255.255.0,192.168.0.1\r\n", 
			sizeof("AT+NSET=192.168.1.1,255.255.255.0,192.168.1.1\r\n"), tty_fd);
	usleep(40000);
	read_port(tty_fd); */

/*	writeMessageToPort("AT+WM=1\r\n", sizeof("AT+WM=2\r\n"), tty_fd);
	usleep(40000);
	read_port(tty_fd);

	writeMessageToPort("AT+WA=PerforManD,,11\r\n", sizeof("AT+WA=PerforManD,,11\r\n"), tty_fd);
	usleep(10000000);
	read_port(tty_fd);

	//writeMessageToPort("AT+DHCPSRVR=1\r\n", sizeof("AT+DHCPSRVR=1"), tty_fd);
	//usleep(5000000);
	//read_port(tty_fd);

	writeMessageToPort("AT+NSTAT=?", sizeof("AT+NSTAT=?"), tty_fd);
	usleep(1000000);
	read_port(tty_fd);
*/
  return(1);
}