mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 01:18:36 +02:00
MSVC: Resolve warnings
This commit is contained in:
@@ -11,19 +11,19 @@ static optional<uint8_t> CAN_DLCToLength(uint8_t length, bool fd) {
|
||||
if (fd) {
|
||||
switch(length) {
|
||||
case 0x9:
|
||||
return 12;
|
||||
return uint8_t(12);
|
||||
case 0xa:
|
||||
return 16;
|
||||
return uint8_t(16);
|
||||
case 0xb:
|
||||
return 20;
|
||||
return uint8_t(20);
|
||||
case 0xc:
|
||||
return 24;
|
||||
return uint8_t(24);
|
||||
case 0xd:
|
||||
return 32;
|
||||
return uint8_t(32);
|
||||
case 0xe:
|
||||
return 48;
|
||||
return uint8_t(48);
|
||||
case 0xf:
|
||||
return 64;
|
||||
return uint8_t(64);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,23 +33,23 @@ static optional<uint8_t> CAN_DLCToLength(uint8_t length, bool fd) {
|
||||
static optional<uint8_t> CAN_LengthToDLC(size_t dataLength, bool fd)
|
||||
{
|
||||
if (dataLength <= 8)
|
||||
return dataLength;
|
||||
return uint8_t(dataLength);
|
||||
|
||||
if (fd) {
|
||||
if (dataLength <= 12)
|
||||
return 0x9;
|
||||
return uint8_t(0x9);
|
||||
else if (dataLength <= 16)
|
||||
return 0xA;
|
||||
return uint8_t(0xA);
|
||||
else if (dataLength <= 20)
|
||||
return 0xB;
|
||||
return uint8_t(0xB);
|
||||
else if (dataLength <= 24)
|
||||
return 0xC;
|
||||
return uint8_t(0xC);
|
||||
else if (dataLength <= 32)
|
||||
return 0xD;
|
||||
return uint8_t(0xD);
|
||||
else if (dataLength <= 48)
|
||||
return 0xE;
|
||||
return uint8_t(0xE);
|
||||
else if (dataLength <= 64)
|
||||
return 0xF;
|
||||
return uint8_t(0xF);
|
||||
}
|
||||
|
||||
return nullopt;
|
||||
@@ -161,7 +161,7 @@ bool HardwareCANPacket::EncodeFromMessage(const CANMessage& message, std::vector
|
||||
|
||||
// The only way this fails is if we're transmitting a DLC > 8 on standard CAN
|
||||
const uint8_t paddedLength = CAN_DLCToLength(*dlc, message.isCANFD).value_or(8);
|
||||
const uint8_t paddingBytes = paddedLength - dataSize;
|
||||
const uint8_t paddingBytes = uint8_t(paddedLength - dataSize);
|
||||
|
||||
// Pre-allocate as much memory as we will possibly need for speed
|
||||
result.reserve(16 + dataSize + paddingBytes);
|
||||
|
||||
@@ -27,7 +27,7 @@ bool HardwareISO9141Packet::EncodeFromMessage(const ISO9141Message& message, std
|
||||
const uint8_t maxSize = (firstPacket ? 9 : 12);
|
||||
uint8_t currentSize = maxSize;
|
||||
if(bytesToSend - currentStart < maxSize)
|
||||
currentSize = bytesToSend - currentStart;
|
||||
currentSize = (uint8_t)(bytesToSend - currentStart);
|
||||
|
||||
packet.insert(packet.begin(), {
|
||||
(uint8_t)Network::NetID::RED, // 0x0C for long message
|
||||
@@ -75,7 +75,7 @@ bool HardwareISO9141Packet::EncodeFromMessage(const ISO9141Message& message, std
|
||||
}
|
||||
|
||||
std::shared_ptr<ISO9141Message> HardwareISO9141Packet::Decoder::decodeToMessage(const std::vector<uint8_t>& bytestream) {
|
||||
const HardwareISO9141Packet* data = (const HardwareISO9141Packet*)bytestream.data();
|
||||
const HardwareISO9141Packet& packet = *reinterpret_cast<const HardwareISO9141Packet*>(bytestream.data());
|
||||
|
||||
if(!mMsg) {
|
||||
mMsg = std::make_shared<ISO9141Message>();
|
||||
@@ -84,8 +84,8 @@ std::shared_ptr<ISO9141Message> HardwareISO9141Packet::Decoder::decodeToMessage(
|
||||
|
||||
mGotPackets++;
|
||||
|
||||
const bool morePacketsComing = data->c3.frm == 0;
|
||||
const uint8_t bytesInCurrentMessage = data->c3.len;
|
||||
const bool morePacketsComing = packet.c3.frm == 0;
|
||||
const uint8_t bytesInCurrentMessage = packet.c3.len;
|
||||
if(mMsg->data.size() + bytesInCurrentMessage > 500) {
|
||||
mMsg.reset();
|
||||
return std::shared_ptr<ISO9141Message>();
|
||||
@@ -93,9 +93,9 @@ std::shared_ptr<ISO9141Message> HardwareISO9141Packet::Decoder::decodeToMessage(
|
||||
|
||||
// This timestamp is raw off the device (in timestampResolution increments)
|
||||
// Decoder will fix as it has information about the timestampResolution increments
|
||||
mMsg->timestamp = data->timestamp.TS;
|
||||
mMsg->timestamp = packet.timestamp.TS;
|
||||
|
||||
auto* dataStart = data->data;
|
||||
auto* dataStart = packet.data;
|
||||
if(mGotPackets == 1) {
|
||||
// Header
|
||||
if(bytesInCurrentMessage < 3) {
|
||||
@@ -103,31 +103,31 @@ std::shared_ptr<ISO9141Message> HardwareISO9141Packet::Decoder::decodeToMessage(
|
||||
return std::shared_ptr<ISO9141Message>();
|
||||
}
|
||||
|
||||
std::copy(data->data, data->data + 3, mMsg->header.begin());
|
||||
std::copy(packet.data, packet.data + 3, mMsg->header.begin());
|
||||
dataStart += 3;
|
||||
}
|
||||
|
||||
// Data
|
||||
mMsg->data.insert(mMsg->data.end(), dataStart, data->data + (bytesInCurrentMessage > 8 ? 8 : bytesInCurrentMessage));
|
||||
mMsg->data.insert(mMsg->data.end(), dataStart, packet.data + (bytesInCurrentMessage > 8 ? 8 : bytesInCurrentMessage));
|
||||
if(bytesInCurrentMessage > 8)
|
||||
mMsg->data.push_back(data->c1.d8);
|
||||
mMsg->data.push_back(packet.c1.d8);
|
||||
if(bytesInCurrentMessage > 9)
|
||||
mMsg->data.push_back(data->c2.d9);
|
||||
mMsg->data.push_back(packet.c2.d9);
|
||||
if(bytesInCurrentMessage > 10)
|
||||
mMsg->data.push_back(data->c2.d10);
|
||||
mMsg->data.push_back(packet.c2.d10);
|
||||
if(bytesInCurrentMessage > 11)
|
||||
mMsg->data.push_back(data->c3.d11);
|
||||
mMsg->data.push_back(packet.c3.d11);
|
||||
|
||||
if(morePacketsComing)
|
||||
return std::shared_ptr<ISO9141Message>();
|
||||
|
||||
mMsg->transmitted = data->c1.tx;
|
||||
mMsg->isInit = data->c3.init;
|
||||
mMsg->framingError = data->c1.options & 0x1;
|
||||
mMsg->overflowError = data->c1.options & 0x2;
|
||||
mMsg->parityError = data->c1.options & 0x4;
|
||||
mMsg->rxTimeoutError = data->c1.options & 0x8;
|
||||
mMsg->description = data->stats;
|
||||
mMsg->transmitted = packet.c1.tx;
|
||||
mMsg->isInit = packet.c3.init;
|
||||
mMsg->framingError = packet.c1.options & 0x1;
|
||||
mMsg->overflowError = packet.c1.options & 0x2;
|
||||
mMsg->parityError = packet.c1.options & 0x4;
|
||||
mMsg->rxTimeoutError = packet.c1.options & 0x8;
|
||||
mMsg->description = packet.stats;
|
||||
|
||||
auto ret = mMsg;
|
||||
mMsg.reset();
|
||||
|
||||
Reference in New Issue
Block a user