Hello
I'm triying to program the serial port. I need it to communicate with an
external device (dive computer). The protocol is here:
http://pakuro.is.sci.toho-u.ac.jp/aladin/memomouse-e.html
Well, the problem i have is that I cannot put the RTS pin to 0 and I
need it to be on 0.
I have follow the "Serial-Programming How-To" and the "Serial
Programming guide for POSIX operating systems" and I have a pice of code
like this:
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <termios.h>
[more code ]
void classname:execute(){
// variable declaration
int fd,c,res,status;
struct termios oldtio,newtio;
char buff[1024];
// abre puerto para lectura/escritura
fd=open(PUERTO,O_RDWR | O_NOCTTY);
if(fd<0){perror(PUERTO);return;}
//init port parameters and flush
tcgetattr(fd,&oldtio);
bzero(&newtio,sizeof(newtio));
newtio.c_cflag=0;
newtio.c_cflag=BAUDRATE | CS8 | CLOCAL | CREAD | CRTSCTS;
newtio.c_iflag= IGNPAR | ICRNL;
newtio.c_oflag=0;
newtio.c_lflag=0;
fcntl(fd, F_SETFL,FNDELAY);
tcflush(fd,TCIFLUSH);
tcsetattr(fd,TCSANOW,&newtio);
//get the pin status
ioctl(fd,TIOCMGET,&status);
// (1) the same number in the output (see below)
print_status(status); // shows the pin status (see below)
// set status only to DTR=on
status =TIOCM_DTR;
// (2)
print_status(status);
ioctl(fd,TIOCMSET,status);
//gets the status again
ioctl(fd,TIOCMGET,&status);
// (3)
print_status(status);
// pice of code triying again to put RTS to 0
status &= ~TIOCM_RTS;
// (4)
print_status(status);
ioctl(fd,TIOCMSET,status);
ioctl(fd,TIOCMGET,&status);
// (5)
print_status(status);
/** print the pins with 1 */Quote:}
void classname::print_status(int status){
fprintf(stderr,"\n--------------\n");
if(status & TIOCM_DTR)
fprintf(stderr,"DTR--on\n");
if(status & TIOCM_LE)
fprintf(stderr,"DSR--on\n");
if(status & TIOCM_RTS)
fprintf(stderr,"RTS--on\n");
if(status & TIOCM_CTS)
fprintf(stderr,"CTS--on\n");
if(status & TIOCM_CAR)
fprintf(stderr,"DCD--on\n");
if(status & TIOCM_DSR)
fprintf(stderr,"DSR--on\n");
fprintf(stderr,"--------------\n");
The results i have are the followingQuote:}
(1) the numbers indicate the position of the code executed
--------------
DTR--on
RTS--on
--------------
(2)
--------------
DTR--on
--------------
(3)
--------------
DTR--on
RTS--on
--------------
(4)
--------------
DTR--on
--------------
(5)
--------------
DTR--on
RTS--on
--------------
As you can see, my trials to get the RTS to 0 have been unsuccesfull. Do
anyone knows how to put the RTS pin to 0 ??
I need it to get absolutelly rid off the windows stuff!!! please help
me!!!
Jordi
http://www.virtual-sub.org