diff options
Diffstat (limited to 'KAMPactor.c')
| -rw-r--r-- | KAMPactor.c | 211 |
1 files changed, 198 insertions, 13 deletions
diff --git a/KAMPactor.c b/KAMPactor.c index 318c6e0..239b183 100644 --- a/KAMPactor.c +++ b/KAMPactor.c @@ -70,6 +70,8 @@ static RECT Rect; int DoScanLine(struct TNCINFO * TNC, char * Buff, int Len);
VOID WritetoTrace(struct TNCINFO * TNC, char * Msg, int Len);
+VOID SuspendOtherPorts(struct TNCINFO * ThisTNC);
+VOID ReleaseOtherPorts(struct TNCINFO * ThisTNC);
static FILE * LogHandle[32] = {0};
@@ -517,6 +519,28 @@ ok: return 0;
}
+VOID KAMSuspendPort(struct TNCINFO * TNC, struct TNCINFO * ThisTNC)
+{
+ struct STREAMINFO * STREAM = &TNC->Streams[0];
+
+ strcpy(TNC->WEB_TNCSTATE, "Interlocked");
+ MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+
+// STREAM->CmdSet = STREAM->CmdSave = zalloc(100);
+// sprintf(STREAM->CmdSet, "I%s\r", "SCSPTC"); // Should prevent connects
+
+}
+
+VOID KAMReleasePort(struct TNCINFO * TNC)
+{
+ struct STREAMINFO * STREAM = &TNC->Streams[0];
+
+ strcpy(TNC->WEB_TNCSTATE, "Free");
+ MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+
+}
+
+
static int WebProc(struct TNCINFO * TNC, char * Buff, BOOL LOCAL)
{
int Len = sprintf(Buff, "<html><meta http-equiv=expires content=0><meta http-equiv=refresh content=15>"
@@ -595,6 +619,11 @@ void * KAMExtInit(EXTPORTDATA * PortEntry) PortEntry->PORTCONTROL.PORTSTARTCODE = KAMStartPort;
PortEntry->PORTCONTROL.PORTSTOPCODE = KAMStopPort;
+// TNC->SuspendPortProc = KAMSuspendPort;
+// TNC->ReleasePortProc = KAMReleasePort;
+
+
+
ptr=strchr(TNC->NodeCall, ' ');
if (ptr) *(ptr) = 0; // Null Terminate
@@ -886,24 +915,39 @@ VOID KAMPoll(int Port) calllen = ConvFromAX25(TNC->PortRecord->ATTACHEDSESSIONS[0]->L4USER, TNC->Streams[0].MyCall);
TNC->Streams[0].MyCall[calllen] = 0;
- EncodeAndSend(TNC, "X", 1); // ??Return to packet mode??
- if (TNC->VeryOldMode)
- datalen = sprintf(TXMsg, "C20MYCALL %s", TNC->Streams[0].MyCall);
- else
- datalen = sprintf(TXMsg, "C20MYPTCALL %s", TNC->Streams[0].MyCall);
+ EncodeAndSend(TNC, "X", 1); // ??Return to packet mode??
+
+ if (TNC->VeryOldMode)
+ {
+ datalen = sprintf(TXMsg, "C20MYCALL %s", TNC->Streams[0].MyCall);
+ EncodeAndSend(TNC, TXMsg, datalen);
+ }
+ else
+ {
+ datalen = sprintf(TXMsg, "C20MYPTCALL %s", TNC->Streams[0].MyCall);
EncodeAndSend(TNC, TXMsg, datalen);
- TNC->InternalCmd = 'M';
+
+ if (TNC->OldMode == 0)
+ {
+ EncodeAndSend(TNC, TXMsg, datalen);
+ datalen = sprintf(TXMsg, "C20MYGTCALL %s", TNC->Streams[0].MyCall);
+ }
+ }
+
+ TNC->InternalCmd = 'M';
- TNC->NeedPACTOR = 0; // Cancel enter Pactor
+ TNC->NeedPACTOR = 0; // Cancel enter Pactor
- sprintf(TNC->WEB_TNCSTATE, "In Use by %s", TNC->Streams[0].MyCall);
- SetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ SuspendOtherPorts(TNC);
+
+ sprintf(TNC->WEB_TNCSTATE, "In Use by %s", TNC->Streams[0].MyCall);
+ SetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
- // Stop Scanning
+ // Stop Scanning
- sprintf(Msg, "%d SCANSTOP", TNC->Port);
+ sprintf(Msg, "%d SCANSTOP", TNC->Port);
- Rig_Command( (TRANSPORTENTRY *) -1, Msg);
+ Rig_Command( (TRANSPORTENTRY *) -1, Msg);
}
}
@@ -1036,9 +1080,22 @@ VOID KAMPoll(int Port) UCHAR TXMsg[80] = "D20";
if (TNC->VeryOldMode)
+ {
datalen = sprintf(TXMsg, "C20MYCALL %s", TNC->NodeCall);
+ EncodeAndSend(TNC, TXMsg, datalen);
+ }
else
+ {
datalen = sprintf(TXMsg, "C20MYPTCALL %s", TNC->NodeCall);
+ EncodeAndSend(TNC, TXMsg, datalen);
+
+ if (TNC->OldMode == 0)
+ {
+ datalen = sprintf(TXMsg, "C20MYGTCALL %s", TNC->NodeCall);
+ EncodeAndSend(TNC, TXMsg, datalen);
+ }
+ }
+
EncodeAndSend(TNC, TXMsg, datalen);
if (TNC->OldMode)
@@ -1046,6 +1103,7 @@ VOID KAMPoll(int Port) else
EncodeAndSend(TNC, "C20TOR", 6); // Back to Listen
+
TNC->InternalCmd = 'T';
TNC->Timeout = 50;
TNC->IntCmdDelay--;
@@ -1266,6 +1324,51 @@ VOID KAMPoll(int Port) return;
}
+ if (memcmp(MsgPtr, "GTOR ", 5) == 0) // GTOR Connect
+ {
+ memcpy(STREAM->RemoteCall, &MsgPtr[5], 9);
+ STREAM->Connecting = TRUE;
+
+ // If Stream 0, Convert C CALL to PACTOR CALL
+
+ if (Stream == 0)
+ {
+ datalen = sprintf(TXMsg, "C20GTOR %s", TNC->Streams[0].RemoteCall);
+
+ // If Pactor, check busy detecters on any interlocked ports
+
+ if (TNC->HFPacket == 0 && InterlockedCheckBusy(TNC) && TNC->OverrideBusy == 0)
+ {
+ // Channel Busy. Wait
+
+ TNC->ConnectCmd = _strdup(TXMsg);
+
+ sprintf(TNC->WEB_TNCSTATE, "Waiting for clear channel");
+ SetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+
+ TNC->BusyDelay = TNC->BusyWait * 10;
+
+ return;
+ }
+
+ TNC->OverrideBusy = FALSE;
+
+ sprintf(TNC->WEB_TNCSTATE, "%s Connecting to %s",
+ TNC->Streams[0].MyCall, TNC->Streams[0].RemoteCall);
+ SetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ }
+ else
+ datalen = sprintf(TXMsg, "C1%cC %s", Stream + '@', STREAM->RemoteCall);
+
+ EncodeAndSend(TNC, TXMsg, datalen);
+ TNC->Timeout = 50;
+ TNC->InternalCmd = 'C'; // So we dont send the reply to the user.
+ ReleaseBuffer(buffptr);
+ STREAM->Connecting = TRUE;
+
+ return;
+ }
+
if (memcmp(MsgPtr, "DISCONNECT", datalen) == 0) // Disconnect
{
if (Stream == 0)
@@ -1644,6 +1747,10 @@ VOID ProcessKHOSTPacket(struct TNCINFO * TNC, UCHAR * Msg, int Len) return;
}
+
+ WritetoTrace(TNC, Buffer, Len);
+
+
// Pass to Appl
Stream = TNC->CmdStream;
@@ -1680,6 +1787,76 @@ VOID ProcessKHOSTPacket(struct TNCINFO * TNC, UCHAR * Msg, int Len) if (Msg[0] == '?') // Status
{
TNC->Timeout = 0;
+
+/*
+ The response frame from the TNC will be:
+ <FEND>?0MSXY<FEND> - where MSXY are coded as follows:
+ M One byte indicating the current mode of operation.
+ A=Packet
+ B=RTTY
+ C=ASCII
+ D=AMTOR
+ E=FEC
+ F=SELFEC
+ G=LAMTOR
+ H=PACTOR
+ I=PTLISTEN
+ J=GTOR
+ K=NAVTEX
+ L=CW
+ M=TOR Standby
+ N=GMON
+ O=PSK31
+ S One byte indicating a sub-mode of operation. The byte
+ contains an ASCII character as follows:
+ 0=Standby
+ 1=Phasing
+ 2=Connected
+ 3=Disconnecting
+ 4=FEC
+ 5=SELFEC
+ 6=PTFEC
+ X One byte (called status byte X). This byte is bit-
+ encoded to indicate specific conditions as follows:
+ Bit 0 = (IDLE) set to 1 when receiving IDLE
+ characters in a frame.
+ Bit 1 = (ERR) set to 1 to indicate the received frame
+ failed CRC check, or was not a valid CS
+ response frame.
+ Bit 2 = (Combined receive) set to 1 to indicate that
+ the data was constructed through the use of
+ error correction (i.e. Golay error correction
+ for G-TOR or Memory ARQ for Pactor).
+ Bit 3 = (RQ) set to 1 to indicate an RQ frame. If you
+ are the ISS, it indicates that the receiving
+ station has asked for a repeat of the last
+ data due to received errors. When you are the
+ IRS, it indicates that the transmitting
+ station has sent the same data that you have
+ already received. This means that the sending
+ station did not properly copy your
+ acknowledgement (CS code).
+ Bit 4 = (Huffman) set to 1 to indicate that this
+ frame contains data which uses Huffman
+ compression.
+ Bit 5 = (ISS) set to 1 to indicate that your station
+ is currently the ISS.
+ Bit 6&7 = (Speed) these two bits indicate the current
+ speed of an ARQ link or the PSK31 mode. The
+ coding of the bits is:
+ 00 = 100 baud or BPSK31
+ 01 = 200 baud or QPSK31
+ 10 = 300 baud
+ Y One byte (called status byte Y). This byte is bit-
+ encoded to indicate specific conditions as follows:
+ Bit 0 = reserved (set to 0).
+ Bit 1 = (PTT) PTT is active.
+ Bit 2 = (Changeover) changeover in progress
+ Bits 3-7 = reserved (set to 0).
+*/
+
+
+
return;
}
@@ -1790,6 +1967,10 @@ VOID ProcessKHOSTPacket(struct TNCINFO * TNC, UCHAR * Msg, int Len) if (Msg[1] == '2' && Msg[2] == 'A')
TNC->HFPacket = TRUE;
+ // Stop other ports in same group
+
+ SuspendOtherPorts(TNC);
+
ProcessIncommingConnect(TNC, Call, Stream, TRUE);
SESS = TNC->PortRecord->ATTACHEDSESSIONS[Stream];
@@ -2047,7 +2228,11 @@ VOID ForcedClose(struct TNCINFO * TNC, int Stream) VOID CloseComplete(struct TNCINFO * TNC, int Stream)
{
- TNC->NeedPACTOR = 50;
+ sprintf(TNC->WEB_TNCSTATE, "Free");
+ SetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+
+ ReleaseOtherPorts(TNC);
+ TNC->NeedPACTOR = 50;
}
|
