Hallo, teman-teman.
Saya mau tanya ttg serial programming:
Saya mau komunikasi lewat serial dgn 8 bit, 1 stop
bit, Even parity. Saya sudah buat aplikasi untuk
kirimnya saja, tetapi kok ngga jalan yah?
Berikut listing code-nya:
int CommId;
struct termios oldtio,newtio;
CommId = open("/dev/ttyS0",O_RDWR | O_NOCTTY);
if (CommId >= 0 ) {
tcgetattr(CommId,&oldtio);
bzero(&newtio,sizeof(newtio));
newtio.c_cflag = oldtio.c_cflag;
newtio.c_cflag |= PARENB;
newtio.c_cflag &= ~PARODD;
newtio.c_cflag &= ~CSIZE;
newtio.c_cflag &= ~CSTOPB;
newtio.c_cflag |= CS8;
newtio.c_iflag = oldtio.c_iflag;
newtio.c_iflag |= (INPCK | ISTRIP);
newtio.c_iflag &= ~(IXON | IXOFF | IXANY);
newtio.c_lflag = ICANON;
cfsetispeed(&newtio,9600);
cfsetospeed(&newtio,9600);
tcflush(CommID,TCIFLUSH);
tcsetattr(CommId,TCSANOW,&newtio);
write(CommId,"TEST",4);
tcsetattr(CommId,TCSANOW,&oldtio);
close(CommId);
}
Apa ada yang kurang? Ada yang bisa bantu?
Thanks,
Andry Susanto
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus � Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
--
Utk berhenti langganan, kirim email ke [EMAIL PROTECTED]
Informasi arsip di http://www.linux.or.id/milis.php3