Pinky
16.08.07, 22:47
Hallo,
ich versuche gerade die verschiedenen Leitungen am Comport auf LOW und HI zu setzen. Mit DTR und RTS funktionierts es schon prima ! Leider weiß ich aber nicht wie es bei TXT funktioniert.
Hier mein bisheriger Quellcode:
#include <termios.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <unistd.h>
#define DTR_LOW status &= ~TIOCM_DTR; ioctl(fd, TIOCMSET, &status)
#define DTR_HI status |= TIOCM_DTR; ioctl(fd, TIOCMSET, &status)
#define RTS_LOW status &= ~TIOCM_RTS; ioctl(fd, TIOCMSET, &status)
#define RTS_HI status |= TIOCM_RTS; ioctl(fd, TIOCMSET, &status)
int main(void) {
int fd, i;
int interval = 3;
int status;
fd = open("/dev/ttyS0",O_RDWR);
if(fd >= 0 ) {
ioctl(fd, TIOCMGET, &status);
for(i=0; i<=4; i++) {
DTR_LOW;
printf("low\n");
sleep(interval);
DTR_HI;
printf("hi\n");
sleep(interval);
}
}
else {
printf("open failed\n");
return -1;
}
close(fd);
return 0;
}
Gruß
Pinky
ich versuche gerade die verschiedenen Leitungen am Comport auf LOW und HI zu setzen. Mit DTR und RTS funktionierts es schon prima ! Leider weiß ich aber nicht wie es bei TXT funktioniert.
Hier mein bisheriger Quellcode:
#include <termios.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <unistd.h>
#define DTR_LOW status &= ~TIOCM_DTR; ioctl(fd, TIOCMSET, &status)
#define DTR_HI status |= TIOCM_DTR; ioctl(fd, TIOCMSET, &status)
#define RTS_LOW status &= ~TIOCM_RTS; ioctl(fd, TIOCMSET, &status)
#define RTS_HI status |= TIOCM_RTS; ioctl(fd, TIOCMSET, &status)
int main(void) {
int fd, i;
int interval = 3;
int status;
fd = open("/dev/ttyS0",O_RDWR);
if(fd >= 0 ) {
ioctl(fd, TIOCMGET, &status);
for(i=0; i<=4; i++) {
DTR_LOW;
printf("low\n");
sleep(interval);
DTR_HI;
printf("hi\n");
sleep(interval);
}
}
else {
printf("open failed\n");
return -1;
}
close(fd);
return 0;
}
Gruß
Pinky