Added time, date, and UTC offset commands. Currently initiated by the

debug button. There seems to be a bug in the 7300 where the UTC offset
has one hour subtracted, ie, -7 HRS becomes -8 HRS. The hex command
appears to be sent correctly.
merge-requests/5/head
Elliott Liggett 2021-07-09 12:02:50 -07:00
rodzic 23869fdcd2
commit e50b032716
4 zmienionych plików z 278 dodań i 3 usunięć

Wyświetl plik

@ -2020,6 +2020,143 @@ void rigCommander::setRefAdjustFine(unsigned char level)
prepDataAndSend(payload);
}
void rigCommander::setTime(timekind t)
{
QByteArray payload;
switch(rigCaps.model)
{
case model705:
payload.setRawData("\x1A\x05\x01\x66", 4);
break;
case model7300:
payload.setRawData("\x1A\x05\x00\x95", 4);
break;
case model7610:
payload.setRawData("\x1A\x05\x01\x59", 4);
break;
case model7700:
payload.setRawData("\x1A\x05\x00\x59", 4);
break;
case model7850:
payload.setRawData("\x1A\x05\x00\x96", 4);
break;
case model9700:
payload.setRawData("\x1A\x05\x01\x80", 4);
break;
case modelR8600:
payload.setRawData("\x1A\x05\x01\x32", 4);
break;
default:
return;
break;
}
payload.append(convertNumberToHex(t.hours));
payload.append(convertNumberToHex(t.minutes));
//qDebug(logRig()) << "Setting time to this: ";
//printHex(payload);
prepDataAndSend(payload);
}
void rigCommander::setDate(datekind d)
{
QByteArray payload;
switch(rigCaps.model)
{
case model705:
payload.setRawData("\x1A\x05\x01\x65", 4);
break;
case model7300:
payload.setRawData("\x1A\x05\x00\x94", 4);
break;
case model7610:
payload.setRawData("\x1A\x05\x01\x58", 4);
break;
case model7700:
payload.setRawData("\x1A\x05\x00\x58", 4);
break;
case model7850:
payload.setRawData("\x1A\x05\x00\x95", 4);
break;
case model9700:
payload.setRawData("\x1A\x05\x01\x79", 4);
break;
case modelR8600:
payload.setRawData("\x1A\x05\x01\x31", 4);
break;
default:
return;
break;
}
// YYYYMMDD
payload.append(convertNumberToHex(d.year/100)); // 20
payload.append(convertNumberToHex(d.year - 100*(d.year/100))); // 21
payload.append(convertNumberToHex(d.month));
payload.append(convertNumberToHex(d.day));
//qDebug(logRig()) << "Setting date to this: ";
//printHex(payload);
prepDataAndSend(payload);
}
void rigCommander::setUTCOffset(timekind t)
{
QByteArray payload;
switch(rigCaps.model)
{
case model705:
payload.setRawData("\x1A\x05\x01\x70", 4);
break;
case model7300:
payload.setRawData("\x1A\x05\x00\x96", 4);
break;
case model7610:
payload.setRawData("\x1A\x05\x01\x62", 4);
break;
case model7700:
payload.setRawData("\x1A\x05\x00\x61", 4);
break;
case model7850:
// Clock 1:
payload.setRawData("\x1A\x05\x00\x99", 4);
break;
case model9700:
payload.setRawData("\x1A\x05\x01\x84", 4);
break;
case modelR8600:
payload.setRawData("\x1A\x05\x01\x35", 4);
break;
default:
return;
break;
}
payload.append(convertNumberToHex(t.hours));
payload.append(convertNumberToHex(t.minutes));
payload.append((unsigned char)t.isMinus);
//qDebug(logRig()) << "Setting UTC Offset to this: ";
//printHex(payload);
prepDataAndSend(payload);
}
unsigned char rigCommander::convertNumberToHex(unsigned char num)
{
// Two digit only
if(num > 99)
{
qInfo(logRig()) << "Invalid numeric conversion from num " << num << " to hex.";
return 0xFA;
}
unsigned char result = 0;
result = (num/10) << 4;
result |= (num - 10*(num/10));
qDebug(logRig()) << "Converting number: " << num << " to hex: " + QString("0x%1").arg(result, 2, 16, QChar('0'));
return result;
}
void rigCommander::sendLevelCmd(unsigned char levAddr, unsigned char level)
{
QByteArray payload("\x14");

Wyświetl plik

@ -41,6 +41,18 @@ struct freqt {
double MHzDouble;
};
struct datekind {
uint16_t year;
unsigned char month;
unsigned char day;
};
struct timekind {
unsigned char hours;
unsigned char minutes;
bool isMinus;
};
struct rigStateStruct {
freqt vfoAFreq;
freqt vfoBFreq;
@ -226,6 +238,12 @@ public slots:
void setRefAdjustCourse(unsigned char level);
void setRefAdjustFine(unsigned char level);
// Time and Date:
void setTime(timekind t);
void setDate(datekind d);
void setUTCOffset(timekind t);
// Satellite:
void setSatelliteMode(bool enabled);
void getSatelliteMode();
@ -350,6 +368,7 @@ private:
QByteArray makeFreqPayload(freqt freq);
QByteArray encodeTone(quint16 tone, bool tinv, bool rinv);
QByteArray encodeTone(quint16 tone);
unsigned char convertNumberToHex(unsigned char num);
quint16 decodeTone(QByteArray eTone);
quint16 decodeTone(QByteArray eTone, bool &tinv, bool &rinv);

Wyświetl plik

@ -44,6 +44,9 @@ wfmain::wfmain(const QString serialPortCL, const QString hostCL, const QString s
qRegisterMetaType<mode_info>();
qRegisterMetaType<audioPacket>();
qRegisterMetaType <audioSetup>();
qRegisterMetaType <timekind>();
qRegisterMetaType <datekind>();
haveRigCaps = false;
@ -336,6 +339,11 @@ void wfmain::rigConnections()
connect(cal, SIGNAL(setRefAdjustCourse(unsigned char)), rig, SLOT(setRefAdjustCourse(unsigned char)));
connect(cal, SIGNAL(setRefAdjustFine(unsigned char)), rig, SLOT(setRefAdjustFine(unsigned char)));
// Date and Time:
connect(this, SIGNAL(setTime(timekind)), rig, SLOT(setTime(timekind)));
connect(this, SIGNAL(setDate(datekind)), rig, SLOT(setDate(datekind)));
connect(this, SIGNAL(setUTCOffset(timekind)), rig, SLOT(setUTCOffset(timekind)));
}
//void wfmain::removeRigConnections()
@ -834,6 +842,10 @@ void wfmain::setInitialTiming()
pttTimer->setInterval(180*1000); // 3 minute max transmit time in ms
pttTimer->setSingleShot(true);
connect(pttTimer, SIGNAL(timeout()), this, SLOT(handlePttLimit()));
timeSync = new QTimer(this);
connect(timeSync, SIGNAL(timeout()), this, SLOT(setRadioTimeDateSend()));
waitingToSetTimeDate = false;
}
void wfmain::setServerToPrefs()
@ -2317,6 +2329,24 @@ void wfmain::doCmd(commandtype cmddata)
emit setATU(atuOn);
break;
}
case cmdSetUTCOffset:
{
timekind u = (*std::static_pointer_cast<timekind>(data));
emit setUTCOffset(u);
break;
}
case cmdSetTime:
{
timekind t = (*std::static_pointer_cast<timekind>(data));
emit setTime(t);
break;
}
case cmdSetDate:
{
datekind d = (*std::static_pointer_cast<datekind>(data));
emit setDate(d);
break;
}
default:
doCmd(cmd);
break;
@ -2608,10 +2638,27 @@ void wfmain::issueCmd(cmds cmd, freqt f)
commandtype cmddata;
cmddata.cmd = cmd;
cmddata.data = std::shared_ptr<freqt>(new freqt(f));
//*static_cast<freqt*>(cmddata.data.get()) = f;
delayedCmdQue.push_back(cmddata);
}
void wfmain::issueCmd(cmds cmd, timekind t)
{
qDebug(logSystem()) << "Issuing timekind command with data: " << t.hours << " hours, " << t.minutes << " minutes, " << t.isMinus << " isMinus";
commandtype cmddata;
cmddata.cmd = cmd;
cmddata.data = std::shared_ptr<timekind>(new timekind(t));
delayedCmdQue.push_front(cmddata);
}
void wfmain::issueCmd(cmds cmd, datekind d)
{
qDebug(logSystem()) << "Issuing datekind command with data: " << d.day << " day, " << d.month << " month, " << d.year << " year.";
commandtype cmddata;
cmddata.cmd = cmd;
cmddata.data = std::shared_ptr<datekind>(new datekind(d));
delayedCmdQue.push_front(cmddata);
}
void wfmain::issueCmd(cmds cmd, int i)
{
commandtype cmddata;
@ -4190,6 +4237,57 @@ void wfmain::on_satOpsBtn_clicked()
sat->show();
}
void wfmain::setRadioTimeDatePrep()
{
if(!waitingToSetTimeDate)
{
// 1: Find the current time and date
QDateTime now = QDateTime::currentDateTime();
now.setTime(QTime::currentTime());
int second = now.time().second();
// 2: Find how many mseconds until next minute
int msecdelay = QTime::currentTime().msecsTo( QTime::currentTime().addSecs(60-second) );
// 3: Compute time and date at one minute later
QDateTime setpoint = now.addMSecs(msecdelay); // at HMS or posibly HMS + some ms. Never under though.
// 4: Prepare data structs for the time at one minute later
timesetpoint.hours = (unsigned char)setpoint.time().hour();
timesetpoint.minutes = (unsigned char)setpoint.time().minute();
datesetpoint.day = (unsigned char)setpoint.date().day();
datesetpoint.month = (unsigned char)setpoint.date().month();
datesetpoint.year = (uint16_t)setpoint.date().year();
unsigned int utcOffsetSeconds = (unsigned int)abs(setpoint.offsetFromUtc());
bool isMinus = setpoint.offsetFromUtc() < 0;
utcsetting.hours = utcOffsetSeconds / 60 / 60;
utcsetting.minutes = (utcOffsetSeconds - (utcsetting.hours*60*60) ) / 60;
utcsetting.isMinus = isMinus;
timeSync->setInterval(msecdelay);
timeSync->setSingleShot(true);
// 5: start one-shot timer for the delta computed in #2.
timeSync->start();
waitingToSetTimeDate = true;
showStatusBarText(QString("Setting time, date, and UTC offset for radio in %1 seconds.").arg(msecdelay/1000));
}
}
void wfmain::setRadioTimeDateSend()
{
// Issue priority commands for UTC offset, date, and time
// UTC offset must come first, otherwise the radio may "help" and correct for any changes.
showStatusBarText(QString("Setting time, date, and UTC offset for radio now."));
issueCmd(cmdSetTime, timesetpoint);
issueCmd(cmdSetDate, datesetpoint);
issueCmd(cmdSetUTCOffset, utcsetting);
waitingToSetTimeDate = false;
}
void wfmain::changeSliderQuietly(QSlider *slider, int value)
{
slider->blockSignals(true);
@ -4946,6 +5044,7 @@ void wfmain::on_pollingBtn_clicked()
void wfmain::on_debugBtn_clicked()
{
qInfo(logSystem()) << "Debug button pressed.";
trxadj->show();
//trxadj->show();
setRadioTimeDatePrep();
}

Wyświetl plik

@ -125,6 +125,11 @@ signals:
void setATU(bool atuEnabled);
void getATUStatus();
// Time and date:
void setTime(timekind t);
void setDate(datekind d);
void setUTCOffset(timekind t);
void getRigID(); // this is the model of the rig
void getRigCIV(); // get the rig's CIV addr
void spectOutputEnable();
@ -245,6 +250,9 @@ private slots:
void serverConfigRequested(SERVERCONFIG conf, bool store);
void receiveBaudRate(quint32 baudrate);
void setRadioTimeDateSend();
// void on_getFreqBtn_clicked();
// void on_getModeBtn_clicked();
@ -591,7 +599,8 @@ private:
cmdGetTxPower, cmdSetTxPower, cmdGetMicGain, cmdSetMicGain, cmdSetModLevel, cmdGetSpectrumRefLevel, cmdGetDuplexMode, cmdGetModInput, cmdGetModDataInput,
cmdGetCurrentModLevel, cmdStartRegularPolling, cmdStopRegularPolling, cmdQueNormalSpeed,
cmdGetVdMeter, cmdGetIdMeter, cmdGetSMeter, cmdGetPowerMeter, cmdGetALCMeter, cmdGetCompMeter, cmdGetTxRxMeter,
cmdGetTone, cmdGetTSQL, cmdGetDTCS, cmdGetRptAccessMode, cmdGetPreamp, cmdGetAttenuator, cmdGetAntenna};
cmdGetTone, cmdGetTSQL, cmdGetDTCS, cmdGetRptAccessMode, cmdGetPreamp, cmdGetAttenuator, cmdGetAntenna,
cmdSetTime, cmdSetDate, cmdSetUTCOffset};
struct commandtype {
cmds cmd;
@ -606,6 +615,8 @@ private:
void issueCmd(cmds cmd, freqt f);
void issueCmd(cmds cmd, mode_info m);
void issueCmd(cmds cmd, timekind t);
void issueCmd(cmds cmd, datekind d);
void issueCmd(cmds cmd, int i);
void issueCmd(cmds cmd, unsigned char c);
void issueCmd(cmds cmd, char c);
@ -626,6 +637,13 @@ private:
bool runPeriodicCommands;
bool usingLAN = false;
QTimer *timeSync;
bool waitingToSetTimeDate;
void setRadioTimeDatePrep();
timekind timesetpoint;
timekind utcsetting;
datekind datesetpoint;
freqMemory mem;
struct colors {
QColor Dark_PlotBackground;
@ -785,6 +803,8 @@ Q_DECLARE_METATYPE(struct udpPreferences)
Q_DECLARE_METATYPE(struct rigStateStruct)
Q_DECLARE_METATYPE(struct audioPacket)
Q_DECLARE_METATYPE(struct audioSetup)
Q_DECLARE_METATYPE(struct timekind)
Q_DECLARE_METATYPE(struct datekind)
Q_DECLARE_METATYPE(enum rigInput)
Q_DECLARE_METATYPE(enum meterKind)
Q_DECLARE_METATYPE(enum spectrumMode)