diff options
Diffstat (limited to 'RigControl.c')
| -rw-r--r-- | RigControl.c | 105 |
1 files changed, 86 insertions, 19 deletions
diff --git a/RigControl.c b/RigControl.c index 773547d..c485792 100644 --- a/RigControl.c +++ b/RigControl.c @@ -222,13 +222,13 @@ struct TimeScan * AllocateTimeRec(struct RIGINFO * RIG) struct ScanEntry ** CheckTimeBands(struct RIGINFO * RIG)
{
int i = 0;
- time_t NOW = time(NULL) % 86400;
+ time_t Now = NOW % 86400;
// Find TimeBand
while (i < RIG->NumberofBands)
{
- if (RIG->TimeBands[i + 1]->Start > NOW)
+ if (RIG->TimeBands[i + 1]->Start > Now)
{
break;
}
@@ -275,7 +275,7 @@ VOID Rig_PTTEx(struct RIGINFO * RIG, BOOL PTTState, struct TNCINFO * TNC) if (PTTState)
{
- MySetWindowText(RIG->hPTT, "T");
+ MySetWindowText(TNC, RIG->hPTT, "T");
RIG->WEB_PTT = 'T';
RIG->PTTTimer = PTTLimit;
RIG->repeatPTTOFFTimer = 0; // Cancel repeated off command
@@ -420,7 +420,7 @@ VOID Rig_PTTEx(struct RIGINFO * RIG, BOOL PTTState, struct TNCINFO * TNC) {
// Drop PTT
- MySetWindowText(RIG->hPTT, " ");
+ MySetWindowText(TNC, RIG->hPTT, " ");
RIG->WEB_PTT = ' ';
RIG->PTTTimer = 0;
if (PORT->PortType == ICOM)
@@ -684,13 +684,13 @@ void saveNewFreq(struct RIGINFO * RIG, double Freq, char * Mode) {
_gcvt((Freq + RIG->rxOffset) / 1000000.0, 9, RIG->Valchar);
strcpy(RIG->WEB_FREQ, RIG->Valchar);
- MySetWindowText(RIG->hFREQ, RIG->WEB_FREQ);
+ MySetWindowText(0, RIG->hFREQ, RIG->WEB_FREQ);
}
if (Mode[0])
{
strcpy(RIG->ModeString, Mode);
- MySetWindowText(RIG->hMODE, Mode);
+ MySetWindowText(0, RIG->hMODE, Mode);
}
}
@@ -905,7 +905,7 @@ int Rig_CommandEx(struct RIGPORTINFO * PORT, struct RIGINFO * RIG, TRANSPORTENTR PORT->Closed = 1;
RigCloseConnection(PORT);
- MySetWindowText(RIG->hSCAN, "C");
+ MySetWindowText(0, RIG->hSCAN, "C");
RIG->WEB_SCAN = 'C';
sprintf(Command, "Ok\r");
@@ -917,7 +917,7 @@ int Rig_CommandEx(struct RIGPORTINFO * PORT, struct RIGINFO * RIG, TRANSPORTENTR PORT->ReopenDelay = 300;
PORT->Closed = 0;
- MySetWindowText(RIG->hSCAN, "");
+ MySetWindowText(0, RIG->hSCAN, "");
RIG->WEB_SCAN = ' ';
sprintf(Command, "Ok\r");
@@ -965,7 +965,7 @@ int Rig_CommandEx(struct RIGPORTINFO * PORT, struct RIGINFO * RIG, TRANSPORTENTR if (Session != (TRANSPORTENTRY *) -1) // Used for internal Stop/Start
RIG->ScanStopped |= 1; // Set Manual Stopped Bit
- MySetWindowText(RIG->hSCAN, "");
+ MySetWindowText(0, RIG->hSCAN, "");
RIG->WEB_SCAN = ' ';
sprintf(Command, "Ok\r");
@@ -2470,10 +2470,9 @@ DllExport BOOL APIENTRY Rig_Init() if (RIG->NumberofBands)
CheckTimeBands(RIG); // Set initial timeband
-#ifdef WIN32
if (RIG->PTTCATPort[0]) // Serial port RTS to CAT
_beginthread(PTTCATThread,0,RIG);
-#endif
+
if (RIG->HAMLIBPORT)
{
// Open listening socket
@@ -3218,6 +3217,14 @@ int GetPermissionToChange(struct RIGPORTINFO * PORT, struct RIGINFO *RIG) // Get Permission to change
+ if (RIG->PTTTimer) // Dont allow change if PTT ia active
+ {
+ if (RIG->RIG_DEBUG)
+ Debugprintf("GetPermissionToChange - Blocked by active PTT");
+
+ return 0;
+ }
+
if (RIG->RIG_DEBUG)
Debugprintf("GetPermissionToChange - WaitingForPermission = %d", RIG->WaitingForPermission);
@@ -3309,7 +3316,7 @@ CheckOtherPorts: PortRecord->PORT_DLL_NAME, PORT->FreqPtr->Dwell);
RIG->WaitingForPermission = FALSE;
- MySetWindowText(RIG->hSCAN, "-");
+ MySetWindowText(0, RIG->hSCAN, "-");
RIG->WEB_SCAN = '-';
if (PORT->FreqPtr)
@@ -3364,7 +3371,7 @@ CheckOtherPorts: if (RIG->ScanCounter == 0) // ? After manual change
RIG->ScanCounter = 150;
- MySetWindowText(RIG->hSCAN, "S");
+ MySetWindowText(0, RIG->hSCAN, "S");
RIG->WEB_SCAN = 'S';
// Do Bandwidth and antenna switches (if needed)
@@ -6075,6 +6082,8 @@ CheckOtherParams: ptr = strtok_s(NULL, " \t\n\r", &Context);
+#ifdef WIN32
+
while (memcmp(ptr, "COM", 3) == 0)
{
char * tncport = strlop(ptr, '/');
@@ -6092,6 +6101,14 @@ CheckOtherParams: if (ptr == NULL)
break;
}
+
+#else
+
+ strcpy(RIG->PTTCATPort[0], _strlwr(ptr));
+ ptr = strtok_s(NULL, " \t\n\r", &Context);
+
+#endif
+
if (ptr == NULL)
break;
else
@@ -7710,6 +7727,56 @@ WaitAgain: }
}
*/
+#else
+
+// Linux Version. Use with tty0tty Kernel Module. Only supports one device for now
+
+VOID PTTCATThread(void * Param)
+{
+ struct RIGINFO * RIG = (struct RIGINFO *)Param;
+ EndPTTCATThread = FALSE;
+
+ Debugprintf("RigControl Opening %s for RTS PTT\n", RIG->PTTCATPort[0]);
+
+ int fd = open(RIG->PTTCATPort[0], O_RDWR | O_NOCTTY);
+ if (fd < 0)
+ {
+ perror("Error opening serial port");
+ return;
+ }
+
+ while (1)
+ {
+ // 2. Block until the CTS line changes status
+ // The hardware interrupt wakes the driver, which wakes this ioctl
+ if (ioctl(fd, TIOCMIWAIT, TIOCM_CTS) < 0)
+ {
+ perror("ioctl TIOCMIWAIT failed");
+ close(fd);
+ return;
+ }
+
+ // 3. Determine if it went HIGH or LOW
+ int status;
+ ioctl(fd, TIOCMGET, &status);
+
+ if (status & TIOCM_CTS)
+ {
+ Rig_PTTEx(RIG, TRUE, RIG->PTTCATTNC[0]);
+ }
+ else
+ {
+ Rig_PTTEx(RIG, FALSE, RIG->PTTCATTNC[0]);
+ }
+ }
+
+ close(fd);
+ EndPTTCATThread = FALSE;
+ return;
+
+}
+
+
#endif
// HAMLIB Support Code
@@ -7992,7 +8059,7 @@ void ProcessFLRIGFrame(struct RIGPORTINFO * PORT) else
sprintf(RIG->WEB_MODE, "%s/%d", RIG->ModeString, b1);
- MySetWindowText(RIG->hMODE, RIG->WEB_MODE);
+ MySetWindowText(0, RIG->hMODE, RIG->WEB_MODE);
}
}
else
@@ -8011,7 +8078,7 @@ void ProcessFLRIGFrame(struct RIGPORTINFO * PORT) _gcvt(RIG->RigFreq, 9, RIG->Valchar);
sprintf(RIG->WEB_FREQ,"%s", RIG->Valchar);
- MySetWindowText(RIG->hFREQ, RIG->WEB_FREQ);
+ MySetWindowText(0, RIG->hFREQ, RIG->WEB_FREQ);
// Read Mode
@@ -8036,7 +8103,7 @@ void ProcessFLRIGFrame(struct RIGPORTINFO * PORT) else
SetWindowText(RIG->hMODE, RIG->WEB_MODE);
- MySetWindowText(RIG->hMODE, RIG->WEB_MODE);
+ MySetWindowText(0, RIG->hMODE, RIG->WEB_MODE);
Len = sprintf(ReqBuf, Req, "rig.get_bw", "");
Len = sprintf(SendBuff, MsgHddr, Len, ReqBuf);
@@ -8106,7 +8173,7 @@ void ProcessFLRIGFrame(struct RIGPORTINFO * PORT) _gcvt(RIG->RigFreq, 9, RIG->Valchar);
sprintf(RIG->WEB_FREQ,"%s", RIG->Valchar);
- MySetWindowText(RIG->hFREQ, RIG->WEB_FREQ);
+ MySetWindowText(TNC, RIG->hFREQ, RIG->WEB_FREQ);
strcpy(PORT->TXBuffer, "rig.get_mode");
Len = sprintf(ReqBuf, Req, "rig.get_mode", "");
@@ -8123,7 +8190,7 @@ void ProcessFLRIGFrame(struct RIGPORTINFO * PORT) {
strlop(val, '<');
sprintf(RIG->WEB_MODE, "%s", val);
- MySetWindowText(RIG->hMODE, RIG->WEB_MODE);
+ MySetWindowText(TNC, RIG->hMODE, RIG->WEB_MODE);
}
}
@@ -8843,7 +8910,7 @@ VOID FLRIGPoll(struct RIGPORTINFO * PORT) _gcvt(RIG->RigFreq, 9, RIG->Valchar);
sprintf(RIG->WEB_FREQ,"%s", RIG->Valchar);
- MySetWindowText(RIG->hFREQ, RIG->WEB_FREQ);
+ MySetWindowText(0, RIG->hFREQ, RIG->WEB_FREQ);
}
|
