LivoxProto1: Remove superfluous proto methods
This commit is contained in:
@@ -230,7 +230,6 @@ uint32_t HandshakeRequest::calculateCrc32() const
|
||||
return comms::calculateCrc32(messageData, messageSize);
|
||||
}
|
||||
|
||||
|
||||
void HandshakeRequest::swapContentsToProtocolEndianness()
|
||||
{
|
||||
// Protocol uses little-endian, so on little-endian machines, no swap needed
|
||||
@@ -246,26 +245,6 @@ void HandshakeRequest::swapContentsToProtocolEndianness()
|
||||
// Note: footer.swapToHostEndianness() swaps CRC, so we skip it here
|
||||
}
|
||||
|
||||
void HandshakeRequest::swapContentsToHostEndianness()
|
||||
{
|
||||
if (endian::isLittleEndian()) { return; }
|
||||
header.swapToHostEndianness();
|
||||
command.swapToHostEndianness();
|
||||
data_port = __builtin_bswap16(data_port);
|
||||
cmd_port = __builtin_bswap16(cmd_port);
|
||||
imu_port = __builtin_bswap16(imu_port);
|
||||
// Note: footer.swapToHostEndianness() swaps CRC, so we skip it here
|
||||
}
|
||||
|
||||
|
||||
bool HandshakeRequest::sanityCheck() const
|
||||
{
|
||||
return header.sanityCheck() &&
|
||||
command.sanityCheck() &&
|
||||
(command.cmd_set == 0x00) && (command.cmd_id == 0x01) &&
|
||||
footer.sanityCheck();
|
||||
}
|
||||
|
||||
// HandshakeResponse methods
|
||||
void HandshakeResponse::swapContentsToHostEndianness()
|
||||
{
|
||||
@@ -583,7 +562,6 @@ uint32_t HeartbeatMessage::calculateCrc32() const
|
||||
return comms::calculateCrc32(messageData, messageSize);
|
||||
}
|
||||
|
||||
|
||||
void HeartbeatMessage::swapContentsToProtocolEndianness()
|
||||
{
|
||||
// Protocol is little-endian, so if host is already little-endian, no swap needed
|
||||
@@ -598,46 +576,6 @@ void HeartbeatMessage::swapContentsToProtocolEndianness()
|
||||
// Note: footer.swapToProtocolEndianness() swaps CRC, so we skip it here
|
||||
}
|
||||
|
||||
void HeartbeatMessage::swapContentsToHostEndianness()
|
||||
{
|
||||
// If host is already little-endian, no swap needed
|
||||
if (endian::isLittleEndian()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Host is big-endian, need to swap from little-endian protocol to big-endian host
|
||||
// Only swap content fields, not CRC fields
|
||||
header.swapToHostEndianness();
|
||||
command.swapToHostEndianness();
|
||||
// Note: footer.swapToHostEndianness() swaps CRC, so we skip it here
|
||||
}
|
||||
|
||||
|
||||
bool HeartbeatMessage::sanityCheck() const
|
||||
{
|
||||
return header.sanityCheck() &&
|
||||
command.sanityCheck() &&
|
||||
(command.cmd_set == 0x00) && (command.cmd_id == 0x03) &&
|
||||
footer.sanityCheck();
|
||||
}
|
||||
|
||||
bool HeartbeatMessage::validateCrc32() const
|
||||
{
|
||||
// Use the calculateCrc32 method to avoid code duplication
|
||||
uint32_t calculatedCrc = calculateCrc32();
|
||||
|
||||
// Compare with the CRC in the footer
|
||||
bool isValid = (calculatedCrc == footer.crc_32);
|
||||
|
||||
// Debug output only if validation fails
|
||||
if (!isValid) {
|
||||
std::cout << "HeartbeatMessage CRC32 Debug: calculated=0x" << std::hex << calculatedCrc
|
||||
<< ", received=0x" << footer.crc_32 << std::dec << std::endl;
|
||||
}
|
||||
|
||||
return isValid;
|
||||
}
|
||||
|
||||
// DisconnectMessage methods
|
||||
DisconnectMessage::DisconnectMessage()
|
||||
{
|
||||
@@ -681,33 +619,6 @@ void DisconnectMessage::swapContentsToProtocolEndianness()
|
||||
// Note: footer.swapToProtocolEndianness() swaps CRC, so we skip it here
|
||||
}
|
||||
|
||||
bool DisconnectMessage::sanityCheck() const
|
||||
{
|
||||
return header.sanityCheck() &&
|
||||
command.sanityCheck() &&
|
||||
(command.cmd_set == 0x00) && (command.cmd_id == 0x06) &&
|
||||
footer.sanityCheck();
|
||||
}
|
||||
|
||||
bool DisconnectMessage::validateCrc32() const
|
||||
{
|
||||
// Use the calculateCrc32 method to avoid code duplication
|
||||
uint32_t calculatedCrc = calculateCrc32();
|
||||
|
||||
// Compare with the CRC in the footer
|
||||
bool isValid = (calculatedCrc == footer.crc_32);
|
||||
|
||||
// Debug output only if validation fails
|
||||
if (!isValid)
|
||||
{
|
||||
std::cout << "DisconnectMessage CRC32 Debug: calculated=0x"
|
||||
<< std::hex << calculatedCrc
|
||||
<< ", received=0x" << footer.crc_32 << std::dec << std::endl;
|
||||
}
|
||||
|
||||
return isValid;
|
||||
}
|
||||
|
||||
// StartStopSamplingMessage methods
|
||||
StartStopSamplingMessage::StartStopSamplingMessage()
|
||||
{
|
||||
@@ -745,28 +656,6 @@ void StartStopSamplingMessage::swapContentsToProtocolEndianness()
|
||||
command.swapToProtocolEndianness();
|
||||
}
|
||||
|
||||
|
||||
bool StartStopSamplingMessage::sanityCheck() const
|
||||
{
|
||||
return header.sanityCheck() && command.sanityCheck() && footer.sanityCheck();
|
||||
}
|
||||
|
||||
bool StartStopSamplingMessage::validateCrc32() const
|
||||
{
|
||||
uint32_t calculatedCrc = calculateCrc32();
|
||||
bool isValid = (calculatedCrc == footer.crc_32);
|
||||
|
||||
// Debug output only if validation fails
|
||||
if (!isValid)
|
||||
{
|
||||
std::cout << "StartStopSamplingMessage CRC32 Debug: calculated=0x"
|
||||
<< std::hex << calculatedCrc
|
||||
<< ", received=0x" << footer.crc_32 << std::dec << std::endl;
|
||||
}
|
||||
|
||||
return isValid;
|
||||
}
|
||||
|
||||
// SamplingResponse methods
|
||||
void SamplingResponse::swapContentsToHostEndianness()
|
||||
{
|
||||
@@ -874,23 +763,6 @@ void SetLiDARReturnMode::swapContentsToProtocolEndianness()
|
||||
footer.swapToProtocolEndianness();
|
||||
}
|
||||
|
||||
bool SetLiDARReturnMode::sanityCheck() const
|
||||
{
|
||||
return header.sanityCheck() &&
|
||||
command.sanityCheck() &&
|
||||
(command.cmd_set == 0x01) && (command.cmd_id == 0x06) &&
|
||||
(mode <= 0x03) && // Valid modes: 0x00-0x03
|
||||
footer.sanityCheck();
|
||||
}
|
||||
|
||||
bool SetLiDARReturnMode::validateCrc32() const
|
||||
{
|
||||
const uint8_t* messageData = reinterpret_cast<const uint8_t*>(this);
|
||||
size_t messageSize = sizeof(SetLiDARReturnMode) - sizeof(footer.crc_32);
|
||||
uint32_t calculatedCrc = comms::calculateCrc32(messageData, messageSize);
|
||||
return (calculatedCrc == footer.crc_32);
|
||||
}
|
||||
|
||||
// SetLiDARReturnModeResponse methods
|
||||
void SetLiDARReturnModeResponse::swapContentsToHostEndianness()
|
||||
{
|
||||
@@ -950,22 +822,6 @@ void GetLiDARReturnMode::swapContentsToProtocolEndianness()
|
||||
footer.swapToProtocolEndianness();
|
||||
}
|
||||
|
||||
bool GetLiDARReturnMode::sanityCheck() const
|
||||
{
|
||||
return header.sanityCheck() &&
|
||||
command.sanityCheck() &&
|
||||
(command.cmd_set == 0x01) && (command.cmd_id == 0x07) &&
|
||||
footer.sanityCheck();
|
||||
}
|
||||
|
||||
bool GetLiDARReturnMode::validateCrc32() const
|
||||
{
|
||||
const uint8_t* messageData = reinterpret_cast<const uint8_t*>(this);
|
||||
size_t messageSize = sizeof(GetLiDARReturnMode) - sizeof(footer.crc_32);
|
||||
uint32_t calculatedCrc = comms::calculateCrc32(messageData, messageSize);
|
||||
return (calculatedCrc == footer.crc_32);
|
||||
}
|
||||
|
||||
// GetLiDARReturnModeResponse methods
|
||||
void GetLiDARReturnModeResponse::swapContentsToHostEndianness()
|
||||
{
|
||||
|
||||
@@ -191,8 +191,6 @@ struct HandshakeRequest
|
||||
// Calculate CRC32 for the entire message
|
||||
uint32_t calculateCrc32() const;
|
||||
void swapContentsToProtocolEndianness();
|
||||
void swapContentsToHostEndianness();
|
||||
bool sanityCheck() const;
|
||||
} __attribute__((packed));
|
||||
|
||||
/** EXPLANATION:
|
||||
@@ -224,9 +222,6 @@ struct HeartbeatMessage
|
||||
HeartbeatMessage();
|
||||
uint32_t calculateCrc32() const;
|
||||
void swapContentsToProtocolEndianness();
|
||||
void swapContentsToHostEndianness();
|
||||
bool sanityCheck() const;
|
||||
bool validateCrc32() const;
|
||||
} __attribute__((packed));
|
||||
|
||||
/** EXPLANATION:
|
||||
@@ -242,8 +237,6 @@ struct DisconnectMessage
|
||||
DisconnectMessage();
|
||||
uint32_t calculateCrc32() const;
|
||||
void swapContentsToProtocolEndianness();
|
||||
bool sanityCheck() const;
|
||||
bool validateCrc32() const;
|
||||
} __attribute__((packed));
|
||||
|
||||
/** EXPLANATION:
|
||||
@@ -260,8 +253,6 @@ struct StartStopSamplingMessage
|
||||
StartStopSamplingMessage();
|
||||
uint32_t calculateCrc32() const;
|
||||
void swapContentsToProtocolEndianness();
|
||||
bool sanityCheck() const;
|
||||
bool validateCrc32() const;
|
||||
} __attribute__((packed));
|
||||
|
||||
/** EXPLANATION:
|
||||
@@ -313,8 +304,6 @@ struct SetLiDARReturnMode
|
||||
SetLiDARReturnMode();
|
||||
uint32_t calculateCrc32() const;
|
||||
void swapContentsToProtocolEndianness();
|
||||
bool sanityCheck() const;
|
||||
bool validateCrc32() const;
|
||||
} __attribute__((packed));
|
||||
|
||||
/** EXPLANATION:
|
||||
@@ -346,8 +335,6 @@ struct GetLiDARReturnMode
|
||||
GetLiDARReturnMode();
|
||||
uint32_t calculateCrc32() const;
|
||||
void swapContentsToProtocolEndianness();
|
||||
bool sanityCheck() const;
|
||||
bool validateCrc32() const;
|
||||
} __attribute__((packed));
|
||||
|
||||
/** EXPLANATION:
|
||||
|
||||
Reference in New Issue
Block a user