summaryrefslogtreecommitdiffstats
path: root/src/isotp/isotp.c
diff options
context:
space:
mode:
authorChristopher Peplin <chris.peplin@rhubarbtech.com>2014-01-01 16:08:10 -0500
committerChristopher Peplin <chris.peplin@rhubarbtech.com>2014-01-01 16:10:57 -0500
commit482c7eafcb35a4031ab6f2241b14ac495735b7cd (patch)
tree8fdff5d9e5ae49df5ed0909dfdb8fc628674ed80 /src/isotp/isotp.c
parent8702b34a8ffdf220c9b054d8f1950a82c9387d6a (diff)
Return completed rx messages instead of relying on callbacks.
Diffstat (limited to 'src/isotp/isotp.c')
-rw-r--r--src/isotp/isotp.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/isotp/isotp.c b/src/isotp/isotp.c
index f7189d2b..9aa051bc 100644
--- a/src/isotp/isotp.c
+++ b/src/isotp/isotp.c
@@ -33,26 +33,29 @@ void isotp_message_to_string(const IsoTpMessage* message, char* destination,
message->arbitration_id, payload_string);
}
-bool isotp_receive_can_frame(IsoTpShims* shims, IsoTpHandle* handle,
+IsoTpMessage isotp_receive_can_frame(IsoTpShims* shims, IsoTpHandle* handle,
const uint16_t arbitration_id, const uint8_t data[],
const uint8_t data_length) {
- bool message_completed = false;
+ IsoTpMessage message = {
+ arbitration_id: arbitration_id,
+ completed: false
+ };
if(data_length < 1) {
- return message_completed;
+ return message;
}
if(handle->type == ISOTP_HANDLE_RECEIVING) {
if(handle->receive_handle.arbitration_id != arbitration_id) {
- return message_completed;
+ return message;
}
} else if(handle->type == ISOTP_HANDLE_SENDING) {
if(handle->send_handle.receiving_arbitration_id != arbitration_id) {
- return message_completed;
+ return message;
}
} else {
shims->log("The ISO-TP handle is corrupt");
- return message_completed;
+ return message;
}
IsoTpProtocolControlInformation pci = (IsoTpProtocolControlInformation)
@@ -70,18 +73,15 @@ bool isotp_receive_can_frame(IsoTpShims* shims, IsoTpHandle* handle,
switch(pci) {
case PCI_SINGLE: {
- IsoTpMessage message = {
- arbitration_id: arbitration_id,
- payload: payload,
- size: payload_length
- };
-
- message_completed = isotp_handle_single_frame(handle, &message);
+ message.payload = payload;
+ message.size = payload_length;
+ message.completed = true;
+ isotp_handle_single_frame(handle, &message);
break;
}
default:
shims->log("Only single frame messages are supported");
break;
}
- return message_completed;
+ return message;
}