Fleshed out ptt_linux.c to control DTR/RTS lines on serial port.

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/trunk@48 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Joe Taylor 2006-01-05 19:39:21 +00:00
parent 5f5e711917
commit 1ed2fa8262
2 changed files with 33 additions and 22 deletions

View File

@ -1,41 +1,52 @@
#include <unistd.h>
#include <stdio.h> #include <stdio.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/io.h>
int ptt_(int *nport, int *ntx, int *iptt) int ptt_(int *nport, int *ntx, int *iptt)
{ {
static int open=0; static int nopen=0;
char s[10]; int i;
// int i3,i4,i5,i6,i9,i00; int fd;
char s[11];
if(*nport==0) { if(*nport < 0) {
*iptt=*ntx; *iptt=*ntx;
return(0); return(0);
} }
if(*ntx && (!open)) { if(*ntx && (!nopen)) {
sprintf(s,"COM%d",*nport); sprintf(s,"/dev/ttyS%d",*nport);
// hFile=CreateFile(TEXT(s),GENERIC_WRITE,0,NULL,OPEN_EXISTING, //open the device
// FILE_ATTRIBUTE_NORMAL,NULL); if ((fd = open(s, O_RDWR | O_NDELAY)) < 0) {
// if(hFile==INVALID_HANDLE_VALUE) { fprintf(stderr, "device not found");
// printf("PTT: Cannot open COM port %d.\n",*nport); return(1);
// return(1); }
// } nopen=1;
open=1;
return(0); return(0);
} }
if(*ntx && open) { //enable privileges for I/O port controls
// EscapeCommFunction(hFile,3); if(ioperm(0,0x3ff,1) < 0) {
// EscapeCommFunction(hFile,5); printf("Cannot set privileges for serial I/O\n");
return(1);
}
// ioctl(fd, TIOCMGET, &flags); //get line bits for serial port
if(*ntx && nopen) {
i = TIOCM_RTS + TIOCM_DTR;
ioctl(fd, TIOCMSET, &i); // Set DTR and RTS
*iptt=1; *iptt=1;
} }
else { else {
// EscapeCommFunction(hFile,4); i=0;
// EscapeCommFunction(hFile,6); ioctl(fd, TIOCMSET, &i);
// EscapeCommFunction(hFile,9); close(fd);
// i00=CloseHandle(hFile);
*iptt=0; *iptt=0;
open=0; nopen=0;
} }
return(0); return(0);
} }

View File

@ -1,4 +1,4 @@
#---------------------------------------------------------- WSJT #----------------------------------------------------------- WSJT
from Tkinter import * from Tkinter import *
from tkFileDialog import * from tkFileDialog import *
import Pmw import Pmw