Summary Files Commits Branches @commit @diff @stats
path: root / src / frame.h
diff options
context:
space:
mode:
Commitb3ec912b0594fbcfe9a33b0372884219862aef1b (patch)
Author
 Syndamia <kamen@syndamia.com>
2025-07-03 14:34:11 +0300
Committer
 Syndamia <kamen@syndamia.com>
2025-07-03 14:34:11 +0300
Files34cac8ae9eb4d812d88603c208a45b85770264a3 /src/frame.h
iso-tp-parser-carista-b3ec912b0594fbcfe9a33b0372884219862aef1b.tar
iso-tp-parser-carista-b3ec912b0594fbcfe9a33b0372884219862aef1b.tar.gz
iso-tp-parser-carista-b3ec912b0594fbcfe9a33b0372884219862aef1b.zip
Parent9d5eda5b08aef00ebe1698609a51ffe249f0a88e (diff)
feat(frame): Implemented frame class
Recieves a hex string, containing all frame data and stores it as something more useful
1 files changed, 48 insertions, 0 deletions
-rw-r--r--src/frame.h48
diff --git a/src/frame.h b/src/frame.h
new file mode 100644
index 0000000..92b9c8f
--- /dev/null
+++ b/src/frame.h
@@ -0,0 +1,48 @@
+#ifndef ISO_TP_FRAME
+#define ISO_TP_FRAME
+
+#include <ostream>
+
+enum FrameType {
+ SF = 0, FF = 1, CF = 2, FC = 3
+};
+
+class Frame {
+ FrameType type;
+ unsigned int size;
+ unsigned int data_size;
+ unsigned char* data;
+
+ void parse_frame_str(const unsigned char* iso_tp_frame);
+
+public:
+ Frame(const char* iso_tp_frame) {
+ this->parse_frame_str((const unsigned char*)iso_tp_frame);
+ }
+
+ ~Frame() {
+ delete[] this->data;
+ }
+
+ FrameType get_type() const {
+ return this->type;
+ }
+
+ unsigned int get_size() const {
+ return this->size;
+ }
+
+ unsigned int get_data_size() const {
+ return this->data_size;
+ }
+
+ const unsigned char* get_data() const {
+ return this->data;
+ }
+
+ friend std::ostream& operator<<(std::ostream& os, const Frame& f);
+};
+
+std::ostream& operator<<(std::ostream& os, const Frame& f);
+
+#endif /* ISO_TP_FRAME */