Thread: answer calls and setup to recieve data using TAP

  1. #1
    Registered User
    Join Date
    Aug 2004
    Posts
    7

    answer calls and setup to recieve data using TAP

    HI, im using LINUX BTW
    I have to make a program to recieve calls,
    and then to recieve data using the TAP protocol
    To configure tap do i just open serial port, and then send
    like this?

    char fd, n;

    n = write(fd, "300,E,7,1", 6);
    // its ment to be 300 baud rate E-Even parity, 7bits, 1Paritycheck

    this is my code so far, basically i need to doto recieve calls?
    Code:
    #include <stdio.h>
    #include <string.h>
    #include <unistd.h>
    #include <fcntl.h>
    #include <termios.h>     
    #include <time.h>
    
    
    
    
    
    int main() {
    
    	
    	time_t current_time;
    	time_t timer; //sec [0-59]
    	
    	
    	timer=time(0);
    	
    	current_time = timer%3600;
    	current_time = current_time%60;
    	
    	//printf("%d\n", current_time);
    
    	
    	char            fd;
    	struct termios options;
    	/* open the port */
    	
    	fd = open("/dev/ttyS1", O_RDWR | O_NDELAY);
    	/* O_NOCTTY no controll of terminal
    	   O_NDELAY assume other port works
    	   O_RDWR open for read and write
    	*/
    	
    	fcntl(fd, F_SETFL, 0); 
    //FNDELAY causes read function to return a 0 if nothing in 
    //the input buffers
    
    	/* get the current options */
    	tcgetattr(fd, &options);
    
    	/*
    	 * Set the baud rates to 19200...
     	*/
    
    	cfsetispeed(&options, B300);
    	cfsetospeed(&options, B300);
    
    	/* set raw input, 1 second timeout */
    	options.c_cflag   |= (CLOCAL | CREAD);
    
    
    	options.c_cflag &= ~CSIZE; 
    	/* Mask the character size bits */
    	options.c_cflag |= CS7;    /* Select 8 data bits */
    
    
    	options.c_lflag  &= ~(ICANON | ECHO | ECHOE | ISIG);
    	//raw input
    	options.c_oflag     &= ~OPOST;
    	//raw output
    	options.c_cc[VMIN]  = 0; //min num of char 2 read
    	options.c_cc[VTIME] = 10; //time to wait for data 1sec
    
    	
    	/* Make changes now without waiting for data to 	complete */
    
    	//tcsetattr(fd, TCSANOW, &options);
    
    
    	//close(fd);
    	long waiting_time;
      	
    	if ( fd != -1 ) {
            	
            	char     n;
            	//n = write(fd, reset, strlen(reset));
    		//current_time
    		waiting_time = (current_time+3)%60;
    		
    		while (current_time != waiting_time) {
    			
    			timer=time(0);
    	
    			current_time = timer%3600;
    			current_time = current_time%60;
    			//printf("%d\t", current_time);
    			//printf("%d\n", waiting_time);
    		}
    		
    		printf("%c", n);
    		printf("\n");
    		printf("%c", fd);
    		printf("\n");
    		
    	
           		if ( n == -1 ) {
    			printf("Write Error");
            	}
    
    		
    
            	close( fd );
    	} else {
    		printf("Can't open serial port");
        	}
    
        	return 0;
      
      
    }

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Have you tried actually calling read? You know, you can learn by doing.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    I posted these links not too long ago, I'll regurgitate them here:

    Serial HOWTO
    Serial Programming HOWTO
    Modem-HOWTO

    gg

  4. #4
    Registered User
    Join Date
    Aug 2004
    Posts
    7
    no i am suppose to recieve signals using TAP protocol
    also what do i need to set up to recieve modem 2 modem connection look at my 1st post plz

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Unkown Hang
    By Bladactania in forum C Programming
    Replies: 31
    Last Post: 04-22-2009, 09:33 AM