Rename timestampMultiplier to timestampResolution
We've also decided to leave it out of the message structures since, for most uses going forward, it will not be needed. Anyone who wants the timestamp resolution can always make the inexpensive device call to get it.pull/13/head
parent
d1cd34fb24
commit
7cf0ec5f4f
|
|
@ -599,13 +599,18 @@ bool icsneo_getSupportedDevices(devicetype_t* devices, size_t* count) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern bool DLLExport icsneo_getTimestampMultiplier(const neodevice_t* device, int* multiplier)
|
extern bool DLLExport icsneo_getTimestampResolution(const neodevice_t* device, uint16_t* resolution)
|
||||||
{
|
{
|
||||||
if (!icsneo_isValidNeoDevice(device)) {
|
if (!icsneo_isValidNeoDevice(device)) {
|
||||||
ErrorManager::GetInstance().add(APIError::InvalidNeoDevice);
|
ErrorManager::GetInstance().add(APIError::InvalidNeoDevice);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
*multiplier = device->device->getTimestampMultiplier();
|
if (resolution == nullptr) {
|
||||||
|
ErrorManager::GetInstance().add(APIError::RequiredParameterNull);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
*resolution = device->device->getTimestampResolution();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ static NeoDevice OldNeoDeviceFromNew(const neodevice_t* newnd) {
|
||||||
return oldnd;
|
return oldnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void NeoMessageToSpyMessage(const neomessage_t& newmsg, icsSpyMessage& oldmsg) {
|
static void NeoMessageToSpyMessage(const neodevice_t* device, const neomessage_t& newmsg, icsSpyMessage& oldmsg) {
|
||||||
memset(&oldmsg, 0, sizeof(icsSpyMessage));
|
memset(&oldmsg, 0, sizeof(icsSpyMessage));
|
||||||
oldmsg.NumberBytesData = (uint8_t)std::min(newmsg.length, (size_t)255);
|
oldmsg.NumberBytesData = (uint8_t)std::min(newmsg.length, (size_t)255);
|
||||||
oldmsg.NumberBytesHeader = 4;
|
oldmsg.NumberBytesHeader = 4;
|
||||||
|
|
@ -59,12 +59,25 @@ static void NeoMessageToSpyMessage(const neomessage_t& newmsg, icsSpyMessage& ol
|
||||||
oldmsg.Protocol = SPY_PROTOCOL_ETHERNET;
|
oldmsg.Protocol = SPY_PROTOCOL_ETHERNET;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Timestamp - epoch = 1/1/2007 - 25ns per tick most of the time
|
// Timestamp - epoch = 1/1/2007 - 25ns per tick most of the time
|
||||||
uint64_t t = newmsg.timestamp;
|
uint64_t t = newmsg.timestamp;
|
||||||
if (newmsg.timestampMultiplier)
|
uint16_t res = 0;
|
||||||
t /= newmsg.timestampMultiplier;
|
if (icsneo_getTimestampResolution(device, &res)) {
|
||||||
oldmsg.TimeHardware2 = (unsigned long)(t >> 32);
|
t /= res;
|
||||||
oldmsg.TimeHardware = (unsigned long)(t & 0xFFFFFFFF);
|
oldmsg.TimeHardware2 = (unsigned long)(t >> 32);
|
||||||
|
oldmsg.TimeHardware = (unsigned long)(t & 0xFFFFFFFF);
|
||||||
|
switch (res) {
|
||||||
|
case 25:
|
||||||
|
oldmsg.TimeStampHardwareID = HARDWARE_TIMESTAMP_ID_NEORED_25NS;
|
||||||
|
break;
|
||||||
|
case 10:
|
||||||
|
oldmsg.TimeStampHardwareID = HARDWARE_TIMESTAMP_ID_NEORED_10NS;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
oldmsg.TimeStampHardwareID = HARDWARE_TIMESTAMP_ID_NONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Basic Functions
|
//Basic Functions
|
||||||
|
|
@ -186,7 +199,7 @@ int icsneoGetMessages(void* hObject, icsSpyMessage* pMsg, int* pNumberOfMessages
|
||||||
*pNumberOfErrors = 0;
|
*pNumberOfErrors = 0;
|
||||||
|
|
||||||
for(size_t i = 0; i < messageCount; i++)
|
for(size_t i = 0; i < messageCount; i++)
|
||||||
NeoMessageToSpyMessage(messages[i], pMsg[i]);
|
NeoMessageToSpyMessage(device, messages[i], pMsg[i]);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -236,8 +249,8 @@ int icsneoGetTimeStampForMsg(void* hObject, icsSpyMessage* pMsg, double* pTimeSt
|
||||||
return false;
|
return false;
|
||||||
neodevice_t* device = (neodevice_t*)hObject;
|
neodevice_t* device = (neodevice_t*)hObject;
|
||||||
|
|
||||||
int multiplier = 0;
|
uint16_t resolution = 0;
|
||||||
if (!icsneo_getTimestampMultiplier(device, &multiplier))
|
if (!icsneo_getTimestampResolution(device, &resolution))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Convert back to ticks
|
// Convert back to ticks
|
||||||
|
|
@ -246,7 +259,7 @@ int icsneoGetTimeStampForMsg(void* hObject, icsSpyMessage* pMsg, double* pTimeSt
|
||||||
ticks += pMsg->TimeHardware;
|
ticks += pMsg->TimeHardware;
|
||||||
|
|
||||||
// convert to ns
|
// convert to ns
|
||||||
ticks *= multiplier;
|
ticks *= resolution;
|
||||||
|
|
||||||
// icsneoGetTimeStampForMsg() expects pTimeStamp to be in seconds
|
// icsneoGetTimeStampForMsg() expects pTimeStamp to be in seconds
|
||||||
*pTimeStamp = ticks / (double)1000000000;
|
*pTimeStamp = ticks / (double)1000000000;
|
||||||
|
|
|
||||||
|
|
@ -25,10 +25,9 @@ bool Decoder::decode(std::shared_ptr<Message>& result, const std::shared_ptr<Pac
|
||||||
if(!result)
|
if(!result)
|
||||||
return false; // A nullptr was returned, the packet was not long enough to decode
|
return false; // A nullptr was returned, the packet was not long enough to decode
|
||||||
|
|
||||||
// Timestamps are in (multiplier) ns increments since 1/1/2007 GMT 00:00:00.0000
|
// Timestamps are in (resolution) ns increments since 1/1/2007 GMT 00:00:00.0000
|
||||||
// The resolution (multiplier) depends on the device
|
// The resolution depends on the device
|
||||||
result->timestamp *= timestampMultiplier;
|
result->timestamp *= timestampResolution;
|
||||||
result->timestampMultiplier = timestampMultiplier;
|
|
||||||
result->network = packet->network;
|
result->network = packet->network;
|
||||||
return true;
|
return true;
|
||||||
case Network::Type::CAN:
|
case Network::Type::CAN:
|
||||||
|
|
@ -41,10 +40,9 @@ bool Decoder::decode(std::shared_ptr<Message>& result, const std::shared_ptr<Pac
|
||||||
if(!result)
|
if(!result)
|
||||||
return false; // A nullptr was returned, the packet was malformed
|
return false; // A nullptr was returned, the packet was malformed
|
||||||
|
|
||||||
// Timestamps are in (multiplier) ns increments since 1/1/2007 GMT 00:00:00.0000
|
// Timestamps are in (resolution) ns increments since 1/1/2007 GMT 00:00:00.0000
|
||||||
// The resolution (multiplier) depends on the device
|
// The resolution depends on the device
|
||||||
result->timestamp *= timestampMultiplier;
|
result->timestamp *= timestampResolution;
|
||||||
result->timestampMultiplier = timestampMultiplier;
|
|
||||||
result->network = packet->network;
|
result->network = packet->network;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ neomessage_t icsneo::CreateNeoMessage(const std::shared_ptr<Message> message) {
|
||||||
neomsg.length = message->data.size();
|
neomsg.length = message->data.size();
|
||||||
neomsg.data = message->data.data();
|
neomsg.data = message->data.data();
|
||||||
neomsg.timestamp = message->timestamp;
|
neomsg.timestamp = message->timestamp;
|
||||||
neomsg.timestampMultiplier = message->timestampMultiplier;
|
|
||||||
neomsg.status.globalError = message->error;
|
neomsg.status.globalError = message->error;
|
||||||
neomsg.status.transmitMessage = message->transmitted;
|
neomsg.status.transmitMessage = message->transmitted;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@ std::shared_ptr<CANMessage> HardwareCANPacket::DecodeToMessage(const std::vector
|
||||||
msg->arbid = data->header.SID;
|
msg->arbid = data->header.SID;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This timestamp is raw off the device (in timestampMultiplier increments)
|
// This timestamp is raw off the device (in timestampResolution increments)
|
||||||
// Decoder will fix as it has information about the timestampMultiplier increments
|
// Decoder will fix as it has information about the timestampResolution increments
|
||||||
msg->timestamp = data->timestamp.TS;
|
msg->timestamp = data->timestamp.TS;
|
||||||
|
|
||||||
// DLC
|
// DLC
|
||||||
|
|
|
||||||
|
|
@ -40,8 +40,8 @@ std::shared_ptr<EthernetMessage> HardwareEthernetPacket::DecodeToMessage(const s
|
||||||
if(message.frameTooShort)
|
if(message.frameTooShort)
|
||||||
message.error = true;
|
message.error = true;
|
||||||
|
|
||||||
// This timestamp is raw off the device (in timestampMultiplier increments)
|
// This timestamp is raw off the device (in timestampResolution increments)
|
||||||
// Decoder will fix as it has information about the timestampMultiplier increments
|
// Decoder will fix as it has information about the timestampResolution increments
|
||||||
message.timestamp = packet->timestamp.TS;
|
message.timestamp = packet->timestamp.TS;
|
||||||
|
|
||||||
// Network ID is also not set, this will be fixed in the Decoder as well
|
// Network ID is also not set, this will be fixed in the Decoder as well
|
||||||
|
|
|
||||||
|
|
@ -67,8 +67,8 @@ bool Device::SerialStringIsNumeric(const std::string& serial) {
|
||||||
return isdigit(serial[0]) && isdigit(serial[1]);
|
return isdigit(serial[0]) && isdigit(serial[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Device::getTimestampMultiplier() const {
|
uint16_t Device::getTimestampResolution() const {
|
||||||
return com->decoder->timestampMultiplier;
|
return com->decoder->timestampResolution;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Device::describe() const {
|
std::string Device::describe() const {
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ public:
|
||||||
Decoder(device_errorhandler_t err) : err(err) {}
|
Decoder(device_errorhandler_t err) : err(err) {}
|
||||||
bool decode(std::shared_ptr<Message>& result, const std::shared_ptr<Packet>& packet);
|
bool decode(std::shared_ptr<Message>& result, const std::shared_ptr<Packet>& packet);
|
||||||
|
|
||||||
int timestampMultiplier = 25;
|
uint16_t timestampResolution = 25;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
device_errorhandler_t err;
|
device_errorhandler_t err;
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ public:
|
||||||
Network network;
|
Network network;
|
||||||
std::vector<uint8_t> data;
|
std::vector<uint8_t> data;
|
||||||
uint64_t timestamp = 0;
|
uint64_t timestamp = 0;
|
||||||
int timestampMultiplier = 0;
|
|
||||||
uint16_t description = 0;
|
uint16_t description = 0;
|
||||||
bool transmitted = false;
|
bool transmitted = false;
|
||||||
bool error = false;
|
bool error = false;
|
||||||
|
|
|
||||||
|
|
@ -108,8 +108,7 @@ typedef struct {
|
||||||
uint8_t header[4];
|
uint8_t header[4];
|
||||||
uint16_t netid;
|
uint16_t netid;
|
||||||
uint8_t type;
|
uint8_t type;
|
||||||
uint8_t reserved[15];
|
uint8_t reserved[17];
|
||||||
uint16_t timestampMultiplier;
|
|
||||||
} neomessage_t; // 72 bytes total
|
} neomessage_t; // 72 bytes total
|
||||||
// Any time you add another neomessage_*_t type, make sure to add it to the static_asserts below!
|
// Any time you add another neomessage_*_t type, make sure to add it to the static_asserts below!
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ public:
|
||||||
static uint32_t SerialStringToNum(const std::string& serial);
|
static uint32_t SerialStringToNum(const std::string& serial);
|
||||||
static bool SerialStringIsNumeric(const std::string& serial);
|
static bool SerialStringIsNumeric(const std::string& serial);
|
||||||
|
|
||||||
int getTimestampMultiplier() const;
|
uint16_t getTimestampResolution() const;
|
||||||
DeviceType getType() const { return DeviceType(data.type); }
|
DeviceType getType() const { return DeviceType(data.type); }
|
||||||
uint16_t getProductId() const { return productId; }
|
uint16_t getProductId() const { return productId; }
|
||||||
std::string getSerial() const { return data.serial; }
|
std::string getSerial() const { return data.serial; }
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ protected:
|
||||||
|
|
||||||
virtual void setupDecoder(Decoder& decoder) override {
|
virtual void setupDecoder(Decoder& decoder) override {
|
||||||
Device::setupDecoder(decoder);
|
Device::setupDecoder(decoder);
|
||||||
decoder.timestampMultiplier = 10; // Timestamps are in 10ns increments instead of the usual 25ns
|
decoder.timestampResolution = 10; // Timestamps are in 10ns increments instead of the usual 25ns
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void setupSupportedRXNetworks(std::vector<Network>& rxNetworks) override {
|
virtual void setupSupportedRXNetworks(std::vector<Network>& rxNetworks) override {
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ protected:
|
||||||
|
|
||||||
virtual void setupDecoder(Decoder& decoder) override {
|
virtual void setupDecoder(Decoder& decoder) override {
|
||||||
Device::setupDecoder(decoder);
|
Device::setupDecoder(decoder);
|
||||||
decoder.timestampMultiplier = 10; // Timestamps are in 10ns increments instead of the usual 25ns
|
decoder.timestampResolution = 10; // Timestamps are in 10ns increments instead of the usual 25ns
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void setupSupportedRXNetworks(std::vector<Network>& rxNetworks) override {
|
virtual void setupSupportedRXNetworks(std::vector<Network>& rxNetworks) override {
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void setupDecoder(Decoder& decoder) override {
|
virtual void setupDecoder(Decoder& decoder) override {
|
||||||
decoder.timestampMultiplier = 10; // Timestamps are in 10ns increments instead of the usual 25ns
|
decoder.timestampResolution = 10; // Timestamps are in 10ns increments instead of the usual 25ns
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
|
|
@ -398,6 +398,18 @@ typedef unsigned __int64 uint64_t;
|
||||||
#define NEOVI_RED_TIMESTAMP_2_10NS 429.4967296
|
#define NEOVI_RED_TIMESTAMP_2_10NS 429.4967296
|
||||||
#define NEOVI_RED_TIMESTAMP_1_10NS 0.000000010
|
#define NEOVI_RED_TIMESTAMP_1_10NS 0.000000010
|
||||||
|
|
||||||
|
#define HARDWARE_TIMESTAMP_ID_NONE (unsigned char)0
|
||||||
|
#define HARDWARE_TIMESTAMP_ID_VSI (unsigned char)1
|
||||||
|
#define HARDWARE_TIMESTAMP_ID_AVT_716 (unsigned char)2
|
||||||
|
#define HARDWARE_TIMESTAMP_ID_NI_CAN (unsigned char)3
|
||||||
|
#define HARDWARE_TIMESTAMP_ID_NEOVI (unsigned char)4
|
||||||
|
#define HARDWARE_TIMESTAMP_ID_AVT_717 (unsigned char)5
|
||||||
|
#define HARDWARE_TIMESTAMP_ID_NEOv6_VCAN (unsigned char)6
|
||||||
|
#define HARDWARE_TIMESTAMP_ID_DOUBLE_SEC (unsigned char)7
|
||||||
|
#define HARDWARE_TIMESTAMP_ID_NEORED_10US (unsigned char)8
|
||||||
|
#define HARDWARE_TIMESTAMP_ID_NEORED_25NS (unsigned char)9
|
||||||
|
#define HARDWARE_TIMESTAMP_ID_NEORED_10NS (unsigned char)10
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
uint32_t DeviceType;
|
uint32_t DeviceType;
|
||||||
|
|
|
||||||
|
|
@ -627,13 +627,13 @@ extern size_t DLLExport icsneo_getErrorLimit(void);
|
||||||
extern bool DLLExport icsneo_getSupportedDevices(devicetype_t* devices, size_t* count);
|
extern bool DLLExport icsneo_getSupportedDevices(devicetype_t* devices, size_t* count);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Get the devices timestamp multiplier
|
* \brief Get the timestamp resolution for the given device
|
||||||
* \param[out] device A pointer to a buffer of devicetype_t structures which will be written to.
|
* \param[out] device A pointer to the neodevice_t structure specifying the device to read out the timestamp for.
|
||||||
* \param[inout] multiplier A pointer to an int, for legacy tick rate to ns
|
* \param[out] resolution A pointer to a uint16_t where the resolution will be stored. This value is in nanoseconds.
|
||||||
|
|
||||||
* \returns True unless device is invalid
|
* \returns True if the resolution was written
|
||||||
*/
|
*/
|
||||||
extern bool DLLExport icsneo_getTimestampMultiplier(const neodevice_t* device, int* multiplier);
|
extern bool DLLExport icsneo_getTimestampResolution(const neodevice_t* device, uint16_t* resolution);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue