diff options
author | norly <ny-git@enpas.org> | 2017-03-22 22:53:40 +0100 |
---|---|---|
committer | norly <ny-git@enpas.org> | 2017-03-22 22:53:40 +0100 |
commit | 6e7f8008fe60e0fb41550ea3c401352091668119 (patch) | |
tree | 1071d0839bdf6b677a1fc5ade92b79e57521c160 | |
parent | b991d41291c8bbd85f41d8c8361207b3b9ff3496 (diff) |
Add multiframe flag, finish memory management
-rw-r--r-- | vw-bap.c | 30 | ||||
-rw-r--r-- | vw-bap.h | 6 |
2 files changed, 26 insertions, 10 deletions
@@ -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); } @@ -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 |