1 #include <windows.h>
2 #include <stdio.h>
3
ptt_(int * nport,int * ntx,int * iptt)4 int ptt_(int *nport, int *ntx, int *iptt)
5 {
6 static HANDLE hFile;
7 static int open=0;
8 char s[10];
9 int i3=1,i4=1,i5=1,i6=1,i9=1,i00=1;
10
11 if(*nport==0) {
12 *iptt=*ntx;
13 return(0);
14 }
15
16 if(*ntx && (!open)) {
17 sprintf(s,"\\\\.\\COM%d",*nport);
18 hFile=CreateFile(TEXT(s),GENERIC_WRITE,0,NULL,OPEN_EXISTING,
19 FILE_ATTRIBUTE_NORMAL,NULL);
20 if(hFile==INVALID_HANDLE_VALUE) {
21 // printf("PTT: Cannot open COM port %d.\n",*nport);
22 return 1;
23 }
24 open=1;
25 }
26
27 if(*ntx && open) {
28 i3=EscapeCommFunction(hFile,3);
29 i5=EscapeCommFunction(hFile,5);
30 *iptt=1;
31 }
32
33 else {
34 i4=EscapeCommFunction(hFile,4);
35 i6=EscapeCommFunction(hFile,6);
36 i9=EscapeCommFunction(hFile,9);
37 i00=CloseHandle(hFile);
38 *iptt=0;
39 open=0;
40 }
41 /*
42 if(i3==0) return 3;
43 if(i4==0) return 4;
44 if(i5==0) return 5;
45 if(i6==0) return 6;
46 if(i9==0) return 9;
47 if(i00==0) return 10;
48 */
49 return 0;
50 }
51