diff options
Diffstat (limited to 'WINMOR.c')
| -rw-r--r-- | WINMOR.c | 195 |
1 files changed, 104 insertions, 91 deletions
@@ -151,6 +151,8 @@ VOID WritetoTraceSupport(struct TNCINFO * TNC, char * Msg, int Len) if (Len < 0)
return;
+ TNC->PageChanged = TNC->WebSockUsed;
+
Save = Msg[Len];
Msg[Len] = 0;
@@ -215,7 +217,7 @@ lineloop: #endif
// Write to Web Buffer
- T = time(NULL);
+ T = NOW;
tm = gmtime(&T);
sprintf_s(Time, sizeof(Time),"%02d:%02d ", tm->tm_hour, tm->tm_min);
@@ -263,7 +265,7 @@ lineloop: #else
index=SendMessage(TNC->hMonitor, LB_ADDSTRING, 0, (LPARAM)(LPCTSTR) ptr1 );
#endif
- T = time(NULL);
+ T = NOW;
tm = gmtime(&T);
sprintf_s(Time, sizeof(Time),"%02d:%02d ", tm->tm_hour, tm->tm_min);
@@ -314,24 +316,28 @@ int C_Q_ADD_NP(VOID *PQ, VOID *PBUFF); struct SEM SetWindTextSem = {0, 0, 0, 0};
-VOID MySetWindowText(HWND hWnd, char * Msg)
+VOID MySetWindowText(struct TNCINFO * TNC, HWND hWnd, char * Msg)
{
+ if (TNC)
+ TNC->PageChanged = TNC->WebSockUsed;
+
#ifndef LINBPQ
+ {
+ PMSGWITHLEN buffptr;
- PMSGWITHLEN buffptr;
+ GetSemaphore(&SetWindTextSem, 61);
+ buffptr = zalloc(400);
- GetSemaphore(&SetWindTextSem, 61);
- buffptr = zalloc(400);
+ if (buffptr)
+ {
+ buffptr->Len= (UINT)hWnd;
+ memcpy(&buffptr->Data[0], Msg, strlen(Msg) + 1);
- if (buffptr)
- {
- buffptr->Len= (UINT)hWnd;
- memcpy(&buffptr->Data[0], Msg, strlen(Msg) + 1);
-
- C_Q_ADD_NP(&SetWindowTextQ, buffptr);
- }
+ C_Q_ADD_NP(&SetWindowTextQ, buffptr);
+ }
- FreeSemaphore(&SetWindTextSem);
+ FreeSemaphore(&SetWindTextSem);
+ }
#endif
}
@@ -592,13 +598,13 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff) switch (fn)
{
- case 1: // poll
+ case 7: // poll
// Check session limit timer
if ((STREAM->Connecting || STREAM->Connected) && !STREAM->Disconnecting)
{
- if (TNC->SessionTimeLimit && STREAM->ConnectTime && time(NULL) > (TNC->SessionTimeLimit + STREAM->ConnectTime))
+ if (TNC->SessionTimeLimit && STREAM->ConnectTime && NOW > (TNC->SessionTimeLimit + STREAM->ConnectTime))
{
send(TNC->TCPSock,"DISCONNECT\r\n", 12, 0);
STREAM->Disconnecting = TRUE;
@@ -680,7 +686,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff) {
char wtext[100];
sprintf (wtext, "WINMOR Sound Card TNC - BPQ %s", TNC->PortRecord->PORTCONTROL.PORTDESCRIPTION);
- MySetWindowText(TNC->hWnd, wtext);
+ MySetWindowText(TNC, TNC->hWnd, wtext);
}
TNC->HeartBeat = 0;
@@ -693,7 +699,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff) send(TNC->TCPSock, "MODE\r\n", 6, 0);
else
{
- if (time(NULL) - TNC->WinmorRestartCodecTimer > 900) // 15 mins
+ if (NOW - TNC->WinmorRestartCodecTimer > 900) // 15 mins
{
send(TNC->TCPSock, "CODEC FALSE\r\n", 13, 0);
send(TNC->TCPSock, "CODEC TRUE\r\n", 12, 0);
@@ -759,19 +765,19 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff) if (TNC->TimeSinceLast++ > 800) // Allow 10 secs for Keepalive
{
// Restart TNC
-
+
if (TNC->ProgramPath && TNC->CONNECTED)
{
if (strstr(TNC->ProgramPath, "WINMOR TNC"))
{
struct tm * tm;
char Time[80];
-
+
TNC->Restarts++;
- TNC->LastRestart = time(NULL);
+ TNC->LastRestart = NOW;
tm = gmtime(&TNC->LastRestart);
-
+
sprintf_s(Time, sizeof(Time),"%04d/%02d/%02d %02d:%02dZ",
tm->tm_year +1900, tm->tm_mon+1, tm->tm_mday, tm->tm_hour, tm->tm_min);
@@ -781,7 +787,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff) sprintf_s(Time, sizeof(Time),"%d", TNC->Restarts);
SetWindowText(TNC->xIDC_RESTARTS, Time);
strcpy(TNC->WEB_RESTARTS, Time);
-
+
KillTNC(TNC);
RestartTNC(TNC);
@@ -819,7 +825,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff) // Stop Scanning
sprintf(Msg, "%d SCANSTOP", TNC->Port);
-
+
Rig_Command( (TRANSPORTENTRY *) -1, Msg);
}
@@ -827,72 +833,76 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff) if (TNC->Streams[0].Attached)
CheckForDetach(TNC, 0, &TNC->Streams[0], TidyClose, ForcedClose, CloseComplete);
- if (TNC->Streams[0].ReportDISC)
- {
- TNC->Streams[0].ReportDISC = FALSE;
- buff->PORT = 0;
- return -1;
- }
-
- if (TNC->CONNECTED == FALSE && TNC->CONNECTING == FALSE)
+ if (TNC->CONNECTED == FALSE && TNC->CONNECTING == FALSE)
+ {
+ // See if time to reconnect
+
+ time(<ime);
+ if (ltime - TNC->lasttime > 9 )
{
- // See if time to reconnect
-
- time(<ime);
- if (ltime - TNC->lasttime > 9 )
- {
- ConnecttoWINMOR(port);
- TNC->lasttime = ltime;
- }
+ ConnecttoWINMOR(port);
+ TNC->lasttime = ltime;
}
-
- FD_ZERO(&readfs);
-
- if (TNC->CONNECTED) FD_SET(TNC->TCPDataSock,&readfs);
-
- FD_ZERO(&writefs);
+ }
- if (TNC->BPQtoWINMOR_Q) FD_SET(TNC->TCPDataSock,&writefs); // Need notification of busy clearing
+ FD_ZERO(&readfs);
- FD_ZERO(&errorfs);
-
- if (TNC->CONNECTING || TNC->CONNECTED) FD_SET(TNC->TCPDataSock,&errorfs);
+ if (TNC->CONNECTED) FD_SET(TNC->TCPDataSock,&readfs);
+
+ FD_ZERO(&writefs);
+
+ if (TNC->BPQtoWINMOR_Q) FD_SET(TNC->TCPDataSock,&writefs); // Need notification of busy clearing
+
+ FD_ZERO(&errorfs);
+
+ if (TNC->CONNECTING || TNC->CONNECTED) FD_SET(TNC->TCPDataSock,&errorfs);
+
+ timeout.tv_sec = 0;
+ timeout.tv_usec = 0; // poll
+
+ if (select((int)TNC->TCPDataSock + 1, &readfs, &writefs, &errorfs, &timeout) > 0)
+ {
+ // See what happened
- timeout.tv_sec = 0;
- timeout.tv_usec = 0; // poll
+ if (FD_ISSET(TNC->TCPDataSock, &readfs))
+ ProcessDataSocketData(port);
- if (select((int)TNC->TCPDataSock + 1, &readfs, &writefs, &errorfs, &timeout) > 0)
+ if (FD_ISSET(TNC->TCPDataSock, &writefs))
{
- // See what happened
+ // Write block has cleared. Send rest of packet
- if (FD_ISSET(TNC->TCPDataSock, &readfs))
- ProcessDataSocketData(port);
-
- if (FD_ISSET(TNC->TCPDataSock, &writefs))
- {
- // Write block has cleared. Send rest of packet
+ buffptr=Q_REM(&TNC->BPQtoWINMOR_Q);
+ txlen = buffptr->Len;
+ memcpy(txbuff,buffptr->Data,txlen);
+ bytes=send(TNC->TCPSock, (const char FAR *)&txbuff, (int)txlen, 0);
+ ReleaseBuffer(buffptr);
+ }
- buffptr=Q_REM(&TNC->BPQtoWINMOR_Q);
- txlen = buffptr->Len;
- memcpy(txbuff,buffptr->Data,txlen);
- bytes=send(TNC->TCPSock, (const char FAR *)&txbuff, (int)txlen, 0);
- ReleaseBuffer(buffptr);
- }
-
- if (FD_ISSET(TNC->TCPDataSock, &errorfs))
- {
- i=sprintf(ErrMsg, "WINMOR Data Connection lost for BPQ Port %d\r\n", port);
- WritetoConsole(ErrMsg);
- TNC->CONNECTING = FALSE;
- TNC->CONNECTED = FALSE;
- TNC->Streams[0].ReportDISC = TRUE;
- }
+ if (FD_ISSET(TNC->TCPDataSock, &errorfs))
+ {
+ i=sprintf(ErrMsg, "WINMOR Data Connection lost for BPQ Port %d\r\n", port);
+ WritetoConsole(ErrMsg);
+ TNC->CONNECTING = FALSE;
+ TNC->CONNECTED = FALSE;
+ TNC->Streams[0].ReportDISC = TRUE;
}
-
+ }
+
+ return 0;
+
+ case 1:
+
// See if any frames for this port
+ if (TNC->Streams[0].ReportDISC)
+ {
+ TNC->Streams[0].ReportDISC = FALSE;
+ buff->PORT = 0;
+ return -1;
+ }
+
if (TNC->WINMORtoBPQ_Q != 0)
{
buffptr=Q_REM(&TNC->WINMORtoBPQ_Q);
@@ -1336,12 +1346,12 @@ VOID ReleaseTNC(struct TNCINFO * TNC) send(TNC->TCPSock, "LISTEN TRUE\r\nMAXCONREQ 4\r\n", 26, 0);
strcpy(TNC->WEB_TNCSTATE, "Free");
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
if (TNC->hWnd)
{
sprintf (wtext, "WINMOR Sound Card TNC - BPQ %s", TNC->PortRecord->PORTCONTROL.PORTDESCRIPTION);
- MySetWindowText(TNC->hWnd, wtext);
+ MySetWindowText(TNC, TNC->hWnd, wtext);
}
// Start Scanner
@@ -1416,7 +1426,7 @@ VOID WinmorSuspendPort(struct TNCINFO * TNC, struct TNCINFO * ThisTNC) if (TNC->Busy)
{
TNC->Busy = FALSE; // Can't clear detector if CODEC off.
- MySetWindowText(TNC->xIDC_CHANSTATE, "Clear");
+ MySetWindowText(TNC, TNC->xIDC_CHANSTATE, "Clear");
strcpy(TNC->WEB_CHANSTATE, "Clear");
}
}
@@ -1429,15 +1439,18 @@ VOID WinmorReleasePort(struct TNCINFO * TNC) extern char WebProcTemplate[];
extern char sliderBit[];
+extern char Menubit[];
static int WebProc(struct TNCINFO * TNC, char * Buff, BOOL LOCAL)
{
- int Len = sprintf(Buff, WebProcTemplate, TNC->Port, TNC->Port, "WINMOR Status", "WINMOR Status");
+ int Len = sprintf(Buff, WebProcTemplate, "WINMOR Status");
+
+ if (LOCAL)
+ Len += sprintf(&Buff[Len], Menubit);
if (TNC->TXFreq)
Len += sprintf(&Buff[Len], sliderBit, TNC->TXOffset, TNC->TXOffset);
-
Len += sprintf(&Buff[Len], "<table style=\"text-align: left; width: 500px; font-family: monospace; align=center \" border=1 cellpadding=2 cellspacing=2>");
Len += sprintf(&Buff[Len], "<tr><td width=110px>Comms State</td><td>%s</td></tr>", TNC->WEB_COMMSSTATE);
Len += sprintf(&Buff[Len], "<tr><td>TNC State</td><td>%s</td></tr>", TNC->WEB_TNCSTATE);
@@ -1801,7 +1814,7 @@ VOID WINMORThread(void * portptr) i=sprintf(Msg, "Connect Failed for WINMOR socket - error code = %d\r\n", err);
WritetoConsole(Msg);
sprintf(TNC->WEB_COMMSSTATE, "Connection to TNC failed");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
TNC->Alerted = TRUE;
}
@@ -1867,7 +1880,7 @@ VOID WINMORThread(void * portptr) sprintf(TNC->WEB_COMMSSTATE, "Connected to WINMOR TNC");
GetSemaphore(&Semaphore, 40);
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
FreeSemaphore(&Semaphore);
}
@@ -1925,7 +1938,7 @@ Lost: sprintf(TNC->WEB_COMMSSTATE, "Connection to TNC lost");
GetSemaphore(&Semaphore, 40);
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
FreeSemaphore(&Semaphore);
TNC->CONNECTED = FALSE;
@@ -1955,7 +1968,7 @@ Lost: sprintf(TNC->WEB_COMMSSTATE, "Connection to TNC lost");
GetSemaphore(&Semaphore, 40);
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
FreeSemaphore(&Semaphore);
TNC->CONNECTED = FALSE;
@@ -2082,7 +2095,7 @@ VOID ProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen) SetWindowText(TNC->xIDC_CHANSTATE, "Busy");
strcpy(TNC->WEB_CHANSTATE, "Busy");
- TNC->WinmorRestartCodecTimer = time(NULL);
+ TNC->WinmorRestartCodecTimer = NOW;
return;
}
@@ -2095,7 +2108,7 @@ VOID ProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen) strcpy(TNC->WEB_CHANSTATE, "Clear");
SetWindowText(TNC->xIDC_CHANSTATE, TNC->WEB_CHANSTATE);
- TNC->WinmorRestartCodecTimer = time(NULL);
+ TNC->WinmorRestartCodecTimer = NOW;
return;
}
@@ -2132,7 +2145,7 @@ VOID ProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen) WritetoTrace(TNC, Buffer, MsgLen - 2);
FreeSemaphore(&Semaphore);
- STREAM->ConnectTime = time(NULL);
+ STREAM->ConnectTime = NOW;
STREAM->bytesRXed = STREAM->bytesTXed = STREAM->PacketsSent = 0;
if (TNC->StartInRobust)
@@ -2483,7 +2496,7 @@ VOID ProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen) strcpy(TNC->WEB_MODE, &Buffer[5]);
GetSemaphore(&Semaphore, 50);
- MySetWindowText(TNC->xIDC_MODE, &Buffer[5]);
+ MySetWindowText(TNC, TNC->xIDC_MODE, &Buffer[5]);
FreeSemaphore(&Semaphore);
return;
}
@@ -2499,7 +2512,7 @@ VOID ProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen) if (_memicmp(Buffer, "NEWSTATE", 8) == 0)
{
- TNC->WinmorRestartCodecTimer = time(NULL);
+ TNC->WinmorRestartCodecTimer = NOW;
SetWindowText(TNC->xIDC_PROTOSTATE, &Buffer[9]);
strcpy(TNC->WEB_PROTOSTATE, &Buffer[9]);
@@ -2710,7 +2723,7 @@ loop: // Does this mean closed?
sprintf(TNC->WEB_COMMSSTATE, "Connection to TNC lost");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
TNC->CONNECTING = FALSE;
TNC->CONNECTED = FALSE;
|
