Multi frame (#6)
[apps/low-level-can-service.git] / src / uds / uds_types.h
index 10d15d6..66bf743 100644 (file)
@@ -9,9 +9,10 @@
 extern "C" {
 #endif
 
-// TODO This isn't true for multi frame messages - we may need to dynamically
-// allocate this in the future
-#define MAX_UDS_PAYLOAD_LENGTH 7
+// TODO This still doesn't have enough space for the largest possible 
+// multiframe response. May need to dynamically allocate in the future.
+#define MAX_UDS_RESPONSE_PAYLOAD_LENGTH 255
+#define MAX_UDS_REQUEST_PAYLOAD_LENGTH 7
 #define MAX_RESPONDING_ECU_COUNT 8
 #define VIN_LENGTH 17
 
@@ -49,12 +50,12 @@ typedef enum {
  * type - the type of the request (TODO unused)
  */
 typedef struct {
-    uint16_t arbitration_id;
+    uint32_t arbitration_id;
     uint8_t mode;
     bool has_pid;
     uint16_t pid;
     uint8_t pid_length;
-    uint8_t payload[MAX_UDS_PAYLOAD_LENGTH];
+    uint8_t payload[MAX_UDS_REQUEST_PAYLOAD_LENGTH];
     uint8_t payload_length;
     bool no_frame_padding;
     DiagnosticRequestType type;
@@ -73,6 +74,7 @@ typedef enum {
     NRC_SUCCESS = 0x0,
     NRC_SERVICE_NOT_SUPPORTED = 0x11,
     NRC_SUB_FUNCTION_NOT_SUPPORTED = 0x12,
+    NRC_INCORRECT_LENGTH_OR_FORMAT = 0x13,
     NRC_CONDITIONS_NOT_CORRECT = 0x22,
     NRC_REQUEST_OUT_OF_RANGE = 0x31,
     NRC_SECURITY_ACCESS_DENIED = 0x33,
@@ -91,6 +93,8 @@ typedef enum {
  *      field isn't valid if 'completed' isn't true. If this is 'false', check
  *      the negative_response_code field for the reason.
  * arbitration_id - The arbitration ID the response was received on.
+ * multi_frame - True if this response (whether completed or not) required
+ *      multi-frame CAN support. Can be used for updating time-out functions.
  * mode - The OBD-II mode for the original request.
  * has_pid - If this is a response to a PID request, this will be true and the
  *      'pid' field will be valid.
@@ -105,12 +109,13 @@ typedef enum {
 typedef struct {
     bool completed;
     bool success;
-    uint16_t arbitration_id;
+    bool multi_frame;
+    uint32_t arbitration_id;
     uint8_t mode;
     bool has_pid;
     uint16_t pid;
     DiagnosticNegativeResponseCode negative_response_code;
-    uint8_t payload[MAX_UDS_PAYLOAD_LENGTH];
+    uint8_t payload[MAX_UDS_RESPONSE_PAYLOAD_LENGTH];
     uint8_t payload_length;
 } DiagnosticResponse;
 
@@ -133,15 +138,13 @@ typedef enum {
     OBD2_MODE_ENHANCED_DIAGNOSTIC_REQUEST = 0x22
 } DiagnosticMode;
 
-/* Public the signature for an optional function to be called when a diagnostic
+/* Public: The signature for an optional function to be called when a diagnostic
  * request is complete, and a response is received or there is a fatal error.
  *
  * response - the completed DiagnosticResponse.
  */
 typedef void (*DiagnosticResponseReceived)(const DiagnosticResponse* response);
 
-typedef float (*DiagnosticResponseDecoder)(const DiagnosticResponse* response);
-
 /* Public: A handle for initiating and continuing a single diagnostic request.
  *
  * A diagnostic request requires one or more CAN messages to be sent, and one