Add description field for messages

Closes https://github.com/intrepidcs/libicsneo/issues/28
pull/32/head
Kyle Schwarz 2020-11-13 16:15:04 -05:00
parent e5920417ff
commit ffbb5e20c5
3 changed files with 13 additions and 3 deletions

View File

@ -46,6 +46,7 @@ static void NeoMessageToSpyMessage(const neodevice_t* device, const neomessage_t
memcpy(oldmsg.Data, newmsg.data, std::min(newmsg.length, (size_t)8)); memcpy(oldmsg.Data, newmsg.data, std::min(newmsg.length, (size_t)8));
oldmsg.ArbIDOrHeader = *(uint32_t*)newmsg.header; oldmsg.ArbIDOrHeader = *(uint32_t*)newmsg.header;
oldmsg.NetworkID = (uint8_t)newmsg.netid; // Note: NetID remapping from the original API is not supported oldmsg.NetworkID = (uint8_t)newmsg.netid; // Note: NetID remapping from the original API is not supported
oldmsg.DescriptionID = newmsg.description;
oldmsg.StatusBitField = newmsg.status.statusBitfield[0]; oldmsg.StatusBitField = newmsg.status.statusBitfield[0];
oldmsg.StatusBitField2 = newmsg.status.statusBitfield[1]; oldmsg.StatusBitField2 = newmsg.status.statusBitfield[1];
oldmsg.StatusBitField3 = newmsg.status.statusBitfield[2]; oldmsg.StatusBitField3 = newmsg.status.statusBitfield[2];
@ -221,6 +222,7 @@ int icsneoTxMessagesEx(void* hObject, icsSpyMessage* pMsg, unsigned int lNetwork
const icsSpyMessage& oldmsg = pMsg[i]; const icsSpyMessage& oldmsg = pMsg[i];
newmsg = {}; newmsg = {};
newmsg.netid = (uint16_t)lNetworkID; newmsg.netid = (uint16_t)lNetworkID;
newmsg.description = oldmsg.DescriptionID;
memcpy(newmsg.header, &oldmsg.ArbIDOrHeader, sizeof(newmsg.header)); memcpy(newmsg.header, &oldmsg.ArbIDOrHeader, sizeof(newmsg.header));
newmsg.length = oldmsg.NumberBytesData | (oldmsg.NodeID << 8); newmsg.length = oldmsg.NumberBytesData | (oldmsg.NodeID << 8);
if (oldmsg.ExtraDataPtr != nullptr) if (oldmsg.ExtraDataPtr != nullptr)

View File

@ -11,6 +11,7 @@ neomessage_t icsneo::CreateNeoMessage(const std::shared_ptr<Message> message) {
neomessage_t neomsg = {}; // Clear out the memory neomessage_t neomsg = {}; // Clear out the memory
neomsg.netid = (uint32_t)message->network.getNetID(); neomsg.netid = (uint32_t)message->network.getNetID();
neomsg.type = (uint8_t)type; neomsg.type = (uint8_t)type;
neomsg.description = message->description;
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;
@ -61,6 +62,7 @@ std::shared_ptr<Message> icsneo::CreateMessageFromNeoMessage(const neomessage_t*
neomessage_can_t& can = *(neomessage_can_t*)neomessage; neomessage_can_t& can = *(neomessage_can_t*)neomessage;
auto canmsg = std::make_shared<CANMessage>(); auto canmsg = std::make_shared<CANMessage>();
canmsg->network = network; canmsg->network = network;
canmsg->description = can.description;
canmsg->data.insert(canmsg->data.end(), can.data, can.data + can.length); canmsg->data.insert(canmsg->data.end(), can.data, can.data + can.length);
canmsg->arbid = can.arbid; canmsg->arbid = can.arbid;
canmsg->isExtended = can.status.extendedFrame; canmsg->isExtended = can.status.extendedFrame;
@ -74,6 +76,7 @@ std::shared_ptr<Message> icsneo::CreateMessageFromNeoMessage(const neomessage_t*
neomessage_eth_t& eth = *(neomessage_eth_t*)neomessage; neomessage_eth_t& eth = *(neomessage_eth_t*)neomessage;
auto ethmsg = std::make_shared<EthernetMessage>(); auto ethmsg = std::make_shared<EthernetMessage>();
ethmsg->network = network; ethmsg->network = network;
ethmsg->description = eth.description;
ethmsg->data.insert(ethmsg->data.end(), eth.data, eth.data + eth.length); ethmsg->data.insert(ethmsg->data.end(), eth.data, eth.data + eth.length);
return ethmsg; return ethmsg;
} }

View File

@ -108,7 +108,9 @@ 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[17]; uint8_t reserved0;
uint16_t description;
uint8_t reserved1[14];
} 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!
@ -122,7 +124,8 @@ typedef struct {
uint16_t netid; uint16_t netid;
uint8_t type; uint8_t type;
uint8_t dlcOnWire; uint8_t dlcOnWire;
uint8_t reserved[16]; uint16_t description;
uint8_t reserved[14];
} neomessage_can_t; } neomessage_can_t;
typedef struct { typedef struct {
@ -135,7 +138,9 @@ typedef struct {
uint8_t reservedHeader[3]; uint8_t reservedHeader[3];
uint16_t netid; uint16_t netid;
uint8_t type; uint8_t type;
uint8_t reserved[17]; uint8_t reserved0;
uint16_t description;
uint8_t reserved1[14];
} neomessage_eth_t; } neomessage_eth_t;
#pragma pack(pop) #pragma pack(pop)