diff options
chore: Add documentation comments where needed
1 files changed, 11 insertions, 5 deletions
| -rw-r--r-- | src/frame.cpp | 16 |
diff --git a/src/frame.cpp b/src/frame.cpp index babfef7..bfa9daf 100644 --- a/src/frame.cpp +++ b/src/frame.cpp @@ -9,6 +9,7 @@ unsigned char hex_byte_to_byte(unsigned char byte) { } unsigned char hex_value_to_byte(const unsigned char* hex) { + // Could've been done with sprintf, however this is faster return (hex_byte_to_byte(hex[0]) << 4) | hex_byte_to_byte(hex[1]); } @@ -23,13 +24,16 @@ unsigned char next_hex_byte(const unsigned char*& iso_tp_frame) { /* Private */ -// b0 b1 b2 b3 b4 b5 b6 b7 -// 02 10 C0 00 00 00 00 00 void Frame::parse_frame_str(const unsigned char* iso_tp_frame) { + // Every two characters in a frame represent the hex value of a single byte + // Example (spaces added for visual clarity): + // b0 b1 b2 b3 b4 b5 b6 b7 + // 02 10 C0 00 00 00 00 00 + unsigned char byte0 = next_hex_byte(iso_tp_frame); this->type =(FrameType)((byte0 & 0b11110000) >> 4); - this->size = byte0 & 0b00001111; + this->size = byte0 & 0b00001111; switch (this->type) { // Single frame @@ -45,11 +49,13 @@ void Frame::parse_frame_str(const unsigned char* iso_tp_frame) { break; // Consecutive frame - case CF: this->data_size = 7; + case CF: this->data_size = 7; // Message objects track total amount of data + // from multipart messages break; // Flow control frame - case FC: this->data_size = 2; + case FC: this->data_size = 2; // The FC flag takes less than a byte, so I'm + // not considering it data. Maybe I should? this->size = 2; break; } |
