mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-07-31 10:39:57 -04:00
Formatted code (#1007)
* Updated style * Updated files * fixed new line * Updated spacing * File fix WIP * Updated to clang 13 * updated comment style * Removed old comment code
This commit is contained in:
parent
7aca7ce74d
commit
033c4e9a5b
599 changed files with 70746 additions and 66896 deletions
|
@ -29,79 +29,79 @@
|
|||
namespace acars {
|
||||
|
||||
size_t Packet::length() const {
|
||||
return packet_.size();
|
||||
return packet_.size();
|
||||
}
|
||||
|
||||
bool Packet::is_valid() const {
|
||||
return true; //length_valid() && crc_ok();
|
||||
return true; // length_valid() && crc_ok();
|
||||
}
|
||||
|
||||
Timestamp Packet::received_at() const {
|
||||
return packet_.timestamp();
|
||||
return packet_.timestamp();
|
||||
}
|
||||
|
||||
uint8_t Packet::block_id() const {
|
||||
return field_.read(96, 8);
|
||||
return field_.read(96, 8);
|
||||
}
|
||||
|
||||
std::string Packet::registration_number() const {
|
||||
std::string result;
|
||||
result.reserve(7);
|
||||
|
||||
const size_t character_length = 8;
|
||||
for(size_t i=16; i<(16+7*character_length); i+=character_length) {
|
||||
result += (field_.read(i, character_length) & 0x7F);
|
||||
}
|
||||
std::string result;
|
||||
result.reserve(7);
|
||||
|
||||
return result;
|
||||
const size_t character_length = 8;
|
||||
for (size_t i = 16; i < (16 + 7 * character_length); i += character_length) {
|
||||
result += (field_.read(i, character_length) & 0x7F);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
uint32_t Packet::read(const size_t start_bit, const size_t length) const {
|
||||
return field_.read(start_bit, length);
|
||||
return field_.read(start_bit, length);
|
||||
}
|
||||
|
||||
/*std::string Packet::text(
|
||||
const size_t start_bit,
|
||||
const size_t character_count
|
||||
const size_t start_bit,
|
||||
const size_t character_count
|
||||
) const {
|
||||
std::string result;
|
||||
result.reserve(character_count);
|
||||
|
||||
const size_t character_length = 6;
|
||||
const size_t end_bit = start_bit + character_count * character_length;
|
||||
for(size_t i=start_bit; i<end_bit; i+=character_length) {
|
||||
result += char_to_ascii(field_.read(i, character_length));
|
||||
}
|
||||
std::string result;
|
||||
result.reserve(character_count);
|
||||
|
||||
return result;
|
||||
const size_t character_length = 6;
|
||||
const size_t end_bit = start_bit + character_count * character_length;
|
||||
for(size_t i=start_bit; i<end_bit; i+=character_length) {
|
||||
result += char_to_ascii(field_.read(i, character_length));
|
||||
}
|
||||
|
||||
return result;
|
||||
}*/
|
||||
|
||||
bool Packet::crc_ok() const {
|
||||
CRCReader field_crc { packet_ };
|
||||
CRC<16> acars_fcs { 0x1021, 0x0000, 0x0000 };
|
||||
|
||||
for(size_t i=0; i<data_length(); i+=8) {
|
||||
acars_fcs.process_byte(field_crc.read(i, 8));
|
||||
}
|
||||
CRCReader field_crc{packet_};
|
||||
CRC<16> acars_fcs{0x1021, 0x0000, 0x0000};
|
||||
|
||||
return (acars_fcs.checksum() == (unsigned)field_crc.read(data_length(), fcs_length));
|
||||
for (size_t i = 0; i < data_length(); i += 8) {
|
||||
acars_fcs.process_byte(field_crc.read(i, 8));
|
||||
}
|
||||
|
||||
return (acars_fcs.checksum() == (unsigned)field_crc.read(data_length(), fcs_length));
|
||||
}
|
||||
|
||||
size_t Packet::data_and_fcs_length() const {
|
||||
return length() - 8;
|
||||
return length() - 8;
|
||||
}
|
||||
|
||||
size_t Packet::data_length() const {
|
||||
return data_and_fcs_length() - fcs_length;
|
||||
return data_and_fcs_length() - fcs_length;
|
||||
}
|
||||
|
||||
bool Packet::length_valid() const {
|
||||
const size_t extra_bits = data_and_fcs_length() & 7;
|
||||
if( extra_bits != 0 ) {
|
||||
return false;
|
||||
}
|
||||
const size_t extra_bits = data_and_fcs_length() & 7;
|
||||
if (extra_bits != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
} /* namespace ais */
|
||||
} // namespace acars
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue