hey guys, i need some help debugging this code:
int open_portandprint(char* load){
int fd; /* File descriptor for the port */
fd = open("/dev/ttyACM0", O_RDWR | O_NDELAY);
fcntl(fd, F_SETFL, 0);
struct termios options,oldtios;
if (tcgetattr(fd, &oldtios) != 0) return(-1);
cfsetispeed(&options, B9600); /* setze 9600 bps */
cfsetospeed(&options, B9600);
options.c_cflag &= ~PARENB; /* kein Paritybit */
options.c_cflag &= ~CSTOPB; /* 1 Stopbit */
options.c_cflag &= ~CSIZE; /* 8 Datenbits */
options.c_cflag |= CS8;
options.c_oflag &= ~OPOST;
tcsetattr(fd, TCSANOW, &options);
int n = 0;
int m = strlen(load);
n = write(fd, load, m);
return (fd);
}
it should initialize the virtual com port on my computer and write some bytes of code. but in only works, while i have telnet up an running. so i think some of my flags are wrong.
can somebody see what my problem is?
thank so far,
erik