Summary Files Commits Branches @commit @diff @stats
path: root / src / frame.cpp
diff options
context:
space:
mode:
Commita1b252f1552492ac2b928276ef9d1ac95ea567af (patch)
Author
 Syndamia <kamen@syndamia.com>
2025-07-03 15:22:05 +0300
Committer
 Syndamia <kamen@syndamia.com>
2025-07-03 15:22:05 +0300
Filesaebba26ab308174730515907aad5ed273f885c74 /src/frame.cpp
iso-tp-parser-carista-a1b252f1552492ac2b928276ef9d1ac95ea567af.tar
iso-tp-parser-carista-a1b252f1552492ac2b928276ef9d1ac95ea567af.tar.gz
iso-tp-parser-carista-a1b252f1552492ac2b928276ef9d1ac95ea567af.zip
Parent61c4f3192d742be4c9a7a5f5e2bf84e42b9a6306 (diff)
chore: Add documentation comments where needed
1 files changed, 11 insertions, 5 deletions
-rw-r--r--src/frame.cpp16
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;
}