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;
}