summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornorly <ny-git@enpas.org>2017-03-22 22:53:40 +0100
committernorly <ny-git@enpas.org>2017-03-22 22:53:40 +0100
commit6e7f8008fe60e0fb41550ea3c401352091668119 (patch)
tree1071d0839bdf6b677a1fc5ade92b79e57521c160
parentb991d41291c8bbd85f41d8c8361207b3b9ff3496 (diff)
Add multiframe flag, finish memory management
-rw-r--r--vw-bap.c30
-rw-r--r--vw-bap.h6
2 files changed, 26 insertions, 10 deletions
diff --git a/vw-bap.c b/vw-bap.c
index 52c37e8..5e81524 100644
--- a/vw-bap.c
+++ b/vw-bap.c
@@ -81,6 +81,8 @@ struct BAP_Frame* vw_bap_handle_can_frame(struct BAP_RXer *bap, struct can_frame
return NULL;
}
+ bap_frame->is_multiframe = 1;
+
header = (frame->data[2] << 8) | frame->data[3];
bap_frame->opcode = (header >> 12) & 0x7;
bap_frame->subnode = (header >> 6) & 0x3F;
@@ -155,6 +157,8 @@ struct BAP_Frame* vw_bap_handle_can_frame(struct BAP_RXer *bap, struct can_frame
return NULL;
}
+ bap_frame->is_multiframe = 0;
+
header = (frame->data[0] << 8) | frame->data[1];
bap_frame->opcode = (header >> 12) & 0x7;
bap_frame->subnode = (header >> 6) & 0x3F;
@@ -174,6 +178,17 @@ struct BAP_Frame* vw_bap_handle_can_frame(struct BAP_RXer *bap, struct can_frame
+void vw_bap_frame_free(struct BAP_Frame *bap_frame)
+{
+ if (bap_frame->data) {
+ free(bap_frame->data);
+ }
+
+ free(bap_frame);
+}
+
+
+
struct BAP_RXer* vw_bap_alloc()
{
struct BAP_RXer *bap;
@@ -191,14 +206,13 @@ struct BAP_RXer* vw_bap_alloc()
void vw_bap_free(struct BAP_RXer *bap)
{
- /* TODO */
- free(bap);
-}
-
+ int i;
+ for (i = 0; i < 8; i++) {
+ if (bap->mfchannel[i]) {
+ vw_bap_frame_free(bap->mfchannel[i]);
+ }
+ }
-void vw_bap_frame_free(struct BAP_Frame *bap_frame)
-{
- /* TODO */
- free(bap_frame);
+ free(bap);
}
diff --git a/vw-bap.h b/vw-bap.h
index 0210104..00c9b75 100644
--- a/vw-bap.h
+++ b/vw-bap.h
@@ -11,6 +11,8 @@ typedef unsigned short BAP_FrameLen;
struct BAP_Frame {
+ int is_multiframe;
+
BAP_OpCode opcode;
BAP_SubNode subnode;
BAP_SubFunction function;
@@ -33,10 +35,10 @@ void vw_bap_frame_dump(struct BAP_Frame *bap_frame);
struct BAP_Frame* vw_bap_handle_can_frame(struct BAP_RXer *bap, struct can_frame *frame);
-struct BAP_RXer* vw_bap_alloc();
-void vw_bap_free(struct BAP_RXer *bap);
void vw_bap_frame_free(struct BAP_Frame *bap_frame);
+struct BAP_RXer* vw_bap_alloc();
+void vw_bap_free(struct BAP_RXer *bap);
#endif