mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-16 13:21:50 -05:00
Merge pull request #981 from ChiefGokhlayeh/pr/higher-resolution-timestamp-in-sdriq-format
Higher resolution timestamp in sdriq format
This commit is contained in:
commit
bc3ac3731f
@ -19,6 +19,7 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QBuffer>
|
#include <QBuffer>
|
||||||
|
#include <QDateTime>
|
||||||
|
|
||||||
#include "SWGDeviceSettings.h"
|
#include "SWGDeviceSettings.h"
|
||||||
#include "SWGDeviceState.h"
|
#include "SWGDeviceState.h"
|
||||||
@ -74,8 +75,8 @@ void FileOutput::openFileStream()
|
|||||||
int actualSampleRate = m_settings.m_sampleRate * (1<<m_settings.m_log2Interp);
|
int actualSampleRate = m_settings.m_sampleRate * (1<<m_settings.m_log2Interp);
|
||||||
header.sampleRate = actualSampleRate;
|
header.sampleRate = actualSampleRate;
|
||||||
header.centerFrequency = m_settings.m_centerFrequency;
|
header.centerFrequency = m_settings.m_centerFrequency;
|
||||||
m_startingTimeStamp = time(0);
|
m_startingTimeStamp = QDateTime::currentMSecsSinceEpoch();
|
||||||
header.startTimeStamp = m_startingTimeStamp;
|
header.startTimeStamp = (quint64)m_startingTimeStamp;
|
||||||
header.sampleSize = SDR_RX_SAMP_SZ;
|
header.sampleSize = SDR_RX_SAMP_SZ;
|
||||||
|
|
||||||
FileRecord::writeHeader(m_ofstream, header);
|
FileRecord::writeHeader(m_ofstream, header);
|
||||||
|
@ -233,7 +233,7 @@ private:
|
|||||||
FileOutputWorker* m_fileOutputWorker;
|
FileOutputWorker* m_fileOutputWorker;
|
||||||
QThread m_fileOutputWorkerThread;
|
QThread m_fileOutputWorkerThread;
|
||||||
QString m_deviceDescription;
|
QString m_deviceDescription;
|
||||||
std::time_t m_startingTimeStamp;
|
qint64 m_startingTimeStamp;
|
||||||
const QTimer& m_masterTimer;
|
const QTimer& m_masterTimer;
|
||||||
QNetworkAccessManager *m_networkManager;
|
QNetworkAccessManager *m_networkManager;
|
||||||
QNetworkRequest m_networkRequest;
|
QNetworkRequest m_networkRequest;
|
||||||
|
@ -367,7 +367,7 @@ void FileInputGUI::updateWithStreamTime()
|
|||||||
QString s_timems = t.toString("HH:mm:ss.zzz");
|
QString s_timems = t.toString("HH:mm:ss.zzz");
|
||||||
ui->relTimeText->setText(s_timems);
|
ui->relTimeText->setText(s_timems);
|
||||||
|
|
||||||
qint64 startingTimeStampMsec = m_startingTimeStamp * 1000LL;
|
qint64 startingTimeStampMsec = m_startingTimeStamp;
|
||||||
QDateTime dt = QDateTime::fromMSecsSinceEpoch(startingTimeStampMsec);
|
QDateTime dt = QDateTime::fromMSecsSinceEpoch(startingTimeStampMsec);
|
||||||
dt = dt.addSecs(t_sec);
|
dt = dt.addSecs(t_sec);
|
||||||
dt = dt.addMSecs(t_msec);
|
dt = dt.addMSecs(t_msec);
|
||||||
|
@ -8,7 +8,7 @@ The header is composed as follows:
|
|||||||
|
|
||||||
- Sample rate in S/s (4 bytes, 32 bits)
|
- Sample rate in S/s (4 bytes, 32 bits)
|
||||||
- Center frequency in Hz (8 bytes, 64 bits)
|
- Center frequency in Hz (8 bytes, 64 bits)
|
||||||
- Start time Unix timestamp epoch in seconds (8 bytes, 64 bits)
|
- Start time Unix timestamp epoch in milliseconds (8 bytes, 64 bits)
|
||||||
- Sample size as 16 or 24 bits (4 bytes, 32 bits)
|
- Sample size as 16 or 24 bits (4 bytes, 32 bits)
|
||||||
- filler with all zeroes (4 bytes, 32 bits)
|
- filler with all zeroes (4 bytes, 32 bits)
|
||||||
- CRC32 (IEEE) of the 28 bytes above (4 bytes, 32 bits)
|
- CRC32 (IEEE) of the 28 bytes above (4 bytes, 32 bits)
|
||||||
|
@ -71,7 +71,7 @@ func printHeader(header *HeaderStd) {
|
|||||||
fmt.Println("Sample rate:", header.SampleRate)
|
fmt.Println("Sample rate:", header.SampleRate)
|
||||||
fmt.Println("Frequency :", header.CenterFrequency)
|
fmt.Println("Frequency :", header.CenterFrequency)
|
||||||
fmt.Println("Sample Size:", header.SampleSize)
|
fmt.Println("Sample Size:", header.SampleSize)
|
||||||
tm := time.Unix(header.StartTimestamp, 0)
|
tm := time.Unix(header.StartTimestamp / 1000, header.StartTimestamp % 1000)
|
||||||
fmt.Println("Start :", tm)
|
fmt.Println("Start :", tm)
|
||||||
fmt.Println("CRC32 :", header.CRC32)
|
fmt.Println("CRC32 :", header.CRC32)
|
||||||
fmt.Println("CRC32 OK :", GetCRC(header))
|
fmt.Println("CRC32 OK :", GetCRC(header))
|
||||||
@ -152,13 +152,13 @@ func main() {
|
|||||||
if flagSeen["ts"] {
|
if flagSeen["ts"] {
|
||||||
t, err := time.Parse(time.RFC3339, *timeStr)
|
t, err := time.Parse(time.RFC3339, *timeStr)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
headerOrigin.StartTimestamp = t.Unix()
|
headerOrigin.StartTimestamp = t.UnixNano() / int64(time.Millisecond)
|
||||||
} else {
|
} else {
|
||||||
fmt.Println("Incorrect time specified. Defaulting to now")
|
fmt.Println("Incorrect time specified. Defaulting to now")
|
||||||
headerOrigin.StartTimestamp = int64(time.Now().Unix())
|
headerOrigin.StartTimestamp = int64(time.Now().UnixNano() / int64(time.Millisecond))
|
||||||
}
|
}
|
||||||
} else if *timeNow {
|
} else if *timeNow {
|
||||||
headerOrigin.StartTimestamp = int64(time.Now().Unix())
|
headerOrigin.StartTimestamp = int64(time.Now().Unix() * 1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("\nHeader is now")
|
fmt.Println("\nHeader is now")
|
||||||
|
@ -183,8 +183,8 @@ void FileRecord::writeHeader()
|
|||||||
Header header;
|
Header header;
|
||||||
header.sampleRate = m_sampleRate;
|
header.sampleRate = m_sampleRate;
|
||||||
header.centerFrequency = m_centerFrequency;
|
header.centerFrequency = m_centerFrequency;
|
||||||
std::time_t ts = time(0);
|
qint64 ts = QDateTime::currentMSecsSinceEpoch();
|
||||||
header.startTimeStamp = ts + (m_msShift / 1000);
|
header.startTimeStamp = (quint64)(ts + m_msShift);
|
||||||
header.sampleSize = SDR_RX_SAMP_SZ;
|
header.sampleSize = SDR_RX_SAMP_SZ;
|
||||||
header.filler = 0;
|
header.filler = 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user