diff --git a/CHANGELOG.mkd b/CHANGELOG.mkd index 22d8808ff..1bc37c254 100644 --- a/CHANGELOG.mkd +++ b/CHANGELOG.mkd @@ -1,4 +1,6 @@ # OpenXC Vehicle Interface Firmware Changelog +## v8.2.0 +* Removed: Removed messagepack format support ## v8.1.0 * BREAKING: VI-Firmware 8.0.0 is not backwards compatable due to stitched diagnostic responses and must be used with OpenXC-Python 2.1.0 or greater. diff --git a/docs/compile/example-builds.rst b/docs/compile/example-builds.rst index 1819fd830..4ebc596ba 100644 --- a/docs/compile/example-builds.rst +++ b/docs/compile/example-builds.rst @@ -257,7 +257,7 @@ while this builds the default firmware, ready for OBD2 requests for the chipKIT: fab chipkit obd2 build -You can specify the message format with ``json``, ``protobuf``, or ``messagepack``: +You can specify the message format with ``json``, or ``protobuf``: .. code-block:: sh diff --git a/docs/compile/makefile-opts.rst b/docs/compile/makefile-opts.rst index 40f35dbd4..0b4d93712 100644 --- a/docs/compile/makefile-opts.rst +++ b/docs/compile/makefile-opts.rst @@ -159,7 +159,7 @@ These options are passed as shell environment variables to the Makefile, e.g. By default, the output format is ``JSON``. Set this to ``PROTOBUF`` to use a binary output format, described more in :doc:`/advanced/binary`. - Values: ``JSON``, ``PROTOBUF``, ``MESSAGEPACK`` + Values: ``JSON``, ``PROTOBUF`` Default: ``JSON`` diff --git a/fabfile.py b/fabfile.py index 0bcd96bc4..276ba8d41 100644 --- a/fabfile.py +++ b/fabfile.py @@ -346,10 +346,6 @@ def json(): @task def protobuf(): env.payload_format = "PROTOBUF" - -@task -def messagepack(): - env.payload_format = "MESSAGEPACK" @task def clean(): diff --git a/src/commands/payload_format_command.cpp b/src/commands/payload_format_command.cpp index 7779d4a2c..a1df1e262 100644 --- a/src/commands/payload_format_command.cpp +++ b/src/commands/payload_format_command.cpp @@ -42,9 +42,6 @@ bool openxc::commands::handlePayloadFormatCommand(openxc_ControlCommand* command case openxc_PayloadFormatCommand_PayloadFormat_PROTOBUF: format = PayloadFormat::PROTOBUF; break; - case openxc_PayloadFormatCommand_PayloadFormat_MESSAGEPACK: - format = PayloadFormat::MESSAGEPACK; - break; } status = true; diff --git a/src/diagnostics.cpp b/src/diagnostics.cpp index 444eb6efd..f4d586162 100644 --- a/src/diagnostics.cpp +++ b/src/diagnostics.cpp @@ -294,47 +294,47 @@ static openxc_VehicleMessage wrapDiagnosticResponseWithSabot(CanBus* bus, return message; } -const bool originalStitchAlgo = false; static int prevFrame = -1; static openxc_VehicleMessage wrapDiagnosticStitchResponseWithSabot(CanBus* bus, const ActiveDiagnosticRequest* request, const DiagnosticResponse* response, openxc_DynamicField value) { openxc_VehicleMessage message = openxc_VehicleMessage(); // Zero fill - message.type = openxc_VehicleMessage_Type_DIAGNOSTIC_STITCH; - message.diagnostic_stitch_response = {0}; - message.diagnostic_stitch_response.bus = bus->address; + message.type = openxc_VehicleMessage_Type_DIAGNOSTIC; + message.diagnostic_response = {0}; + message.diagnostic_response.bus = bus->address; if(request->arbitration_id != OBD2_FUNCTIONAL_BROADCAST_ID) { - message.diagnostic_stitch_response.message_id = response->arbitration_id + message.diagnostic_response.message_id = response->arbitration_id - DIAGNOSTIC_RESPONSE_ARBITRATION_ID_OFFSET; } else { // must preserve responding arb ID for responses to functional broadcast // requests, as they are the actual module address and not just arb ID + // 8. - message.diagnostic_stitch_response.message_id = response->arbitration_id; + message.diagnostic_response.message_id = response->arbitration_id; } - message.diagnostic_stitch_response.mode = response->mode; - message.diagnostic_stitch_response.pid = response->pid; - message.diagnostic_stitch_response.success = response->success; - message.diagnostic_stitch_response.negative_response_code = + message.diagnostic_response.mode = response->mode; + message.diagnostic_response.pid = response->pid; + message.diagnostic_response.success = response->success; + message.diagnostic_response.negative_response_code = response->negative_response_code; - message.diagnostic_stitch_response.frame = prevFrame + 1; + message.diagnostic_response.frame = prevFrame + 1; if (response->completed) { - message.diagnostic_stitch_response.frame = -1; // Marks the last frame in the response + message.diagnostic_response.frame = -1; // Marks the last frame in the response } else { - message.diagnostic_stitch_response.success = true; + message.diagnostic_response.success = true; } - prevFrame = message.diagnostic_stitch_response.frame; + prevFrame = message.diagnostic_response.frame; if(response->payload_length > 0) { if (request->decoder != NULL) { - message.diagnostic_stitch_response.value = value; + message.diagnostic_response.value = value; } else { - memcpy(message.diagnostic_stitch_response.payload.bytes, response->payload, + memcpy(message.diagnostic_response.payload.bytes, response->payload, response->payload_length); - message.diagnostic_stitch_response.payload.size = response->payload_length; + message.diagnostic_response.payload.size = response->payload_length; + message.diagnostic_response.total_size = response->payload_length; } } return message; @@ -405,38 +405,6 @@ static void sendPartialMessage(long timestamp, (uint8_t*)messageBuffer, messageLen, MessageClass::SIMPLE); } - -// relayPartialFrame - Send the partial frame to the mobile device/web - -static void relayPartialFrame(DiagnosticsManager* manager, // Only need for the callback - ActiveDiagnosticRequest* request, - const DiagnosticResponse* response, - Pipeline* pipeline) { - - int frame = prevFrame + 1; - if (response->completed) { - frame = -1; // Marks the last frame in the response - } - prevFrame = frame; - - // see wrapDiagnosticResponseWithSabot - sendPartialMessage(00, // long timestamp, - frame, // int frame - response->arbitration_id, // int message_id, - request->bus->address, // int bus, - 0, // int total_size, - response->mode, // int mode, - response->pid, // int pid, - 0, // int value, - when the payload is a bitfield or numeric - parsed value - response->negative_response_code, // int negative_response_code - (char *)response->payload, // char *payload - response->payload_length, - pipeline); - - if (response->completed && (request->callback != NULL)) { - request->callback(manager, request, response, diagnostic_payload_to_integer(response)); - } -} #endif static void relayDiagnosticResponse(DiagnosticsManager* manager, @@ -514,11 +482,7 @@ static void receiveCanMessage(DiagnosticsManager* manager, if (response.multi_frame) { #if (MULTIFRAME != 0) - if (originalStitchAlgo) { - relayPartialFrame(manager, entry, &response, pipeline); - } else { - relayDiagnosticResponse(manager, entry, &response, pipeline, true); // Added 6/11/2020 - } + relayDiagnosticResponse(manager, entry, &response, pipeline, true); // Added 6/11/2020 #endif if (!response.completed) { time::tick(&entry->timeoutClock); diff --git a/src/libs/openxc-message-format b/src/libs/openxc-message-format index c04cb13d6..8c2f53c9f 160000 --- a/src/libs/openxc-message-format +++ b/src/libs/openxc-message-format @@ -1 +1 @@ -Subproject commit c04cb13d625e8cbcae5beef56094d0ae496193a9 +Subproject commit 8c2f53c9fa5b23b35cf1720ba63ba7bd4afc6bd3 diff --git a/src/payload/json.cpp b/src/payload/json.cpp index 64965639d..7a2d25111 100644 --- a/src/payload/json.cpp +++ b/src/payload/json.cpp @@ -28,7 +28,6 @@ const char openxc::payload::json::SD_MOUNT_STATUS_COMMAND_NAME[] = "sd_mount_sta const char openxc::payload::json::PAYLOAD_FORMAT_JSON_NAME[] = "json"; const char openxc::payload::json::PAYLOAD_FORMAT_PROTOBUF_NAME[] = "protobuf"; -const char openxc::payload::json::PAYLOAD_FORMAT_MESSAGEPACK_NAME[] = "messagepack"; const char openxc::payload::json::COMMAND_RESPONSE_FIELD_NAME[] = "command_response"; const char openxc::payload::json::COMMAND_RESPONSE_MESSAGE_FIELD_NAME[] = "message"; @@ -67,6 +66,14 @@ static bool serializeDiagnostic(openxc_VehicleMessage* message, cJSON* root) { cJSON_AddNumberToObject(root, payload::json::DIAGNOSTIC_PID_FIELD_NAME, message->diagnostic_response.pid); + if (message->diagnostic_response.total_size > 0) { + // These next 2 fields are only in a stitched message frame + cJSON_AddNumberToObject(root, payload::json::DIAGNOSTIC_FRAME_FIELD_NAME, + message->diagnostic_response.frame); + cJSON_AddNumberToObject(root, payload::json::DIAGNOSTIC_TOTAL_SIZE_FIELD_NAME, + message->diagnostic_response.total_size); + } + if(message->diagnostic_response.negative_response_code != 0) { cJSON_AddNumberToObject(root, payload::json::DIAGNOSTIC_NRC_FIELD_NAME, message->diagnostic_response.negative_response_code); @@ -98,55 +105,6 @@ static bool serializeDiagnostic(openxc_VehicleMessage* message, cJSON* root) { return true; } -static bool serializeStitchDiagnostic(openxc_VehicleMessage* message, cJSON* root) { - cJSON_AddNumberToObject(root, payload::json::BUS_FIELD_NAME, - message->diagnostic_stitch_response.bus); - cJSON_AddNumberToObject(root, payload::json::ID_FIELD_NAME, - message->diagnostic_stitch_response.message_id); - cJSON_AddNumberToObject(root, payload::json::DIAGNOSTIC_MODE_FIELD_NAME, - message->diagnostic_stitch_response.mode); - cJSON_AddBoolToObject(root, payload::json::DIAGNOSTIC_SUCCESS_FIELD_NAME, - message->diagnostic_stitch_response.success); - cJSON_AddNumberToObject(root, payload::json::DIAGNOSTIC_PID_FIELD_NAME, - message->diagnostic_stitch_response.pid); - - // These next 2 fields are only in a stitched message frame - cJSON_AddNumberToObject(root, payload::json::DIAGNOSTIC_FRAME_FIELD_NAME, - message->diagnostic_stitch_response.frame); - cJSON_AddNumberToObject(root, payload::json::DIAGNOSTIC_TOTAL_SIZE_FIELD_NAME, - message->diagnostic_stitch_response.total_size); - - if(message->diagnostic_stitch_response.negative_response_code != 0) { - cJSON_AddNumberToObject(root, payload::json::DIAGNOSTIC_NRC_FIELD_NAME, - message->diagnostic_stitch_response.negative_response_code); - } - - if(message->diagnostic_stitch_response.value.type != openxc_DynamicField_Type_UNUSED) { - if (message->diagnostic_stitch_response.value.type == openxc_DynamicField_Type_NUM) { - cJSON_AddNumberToObject(root, payload::json::DIAGNOSTIC_VALUE_FIELD_NAME, - message->diagnostic_stitch_response.value.numeric_value); - } else { - cJSON_AddStringToObject(root, payload::json::DIAGNOSTIC_VALUE_FIELD_NAME, - message->diagnostic_stitch_response.value.string_value); - } - } else if(message->diagnostic_stitch_response.payload.size > 0) { - char encodedData[MAX_DIAGNOSTIC_PAYLOAD_SIZE]; - const char* maxAddress = encodedData + sizeof(encodedData); - char* encodedDataIndex = encodedData; - encodedDataIndex += sprintf(encodedDataIndex, "0x"); - for(uint8_t i = 0; i < message->diagnostic_stitch_response.payload.size && - encodedDataIndex < maxAddress; i++) { - encodedDataIndex += snprintf(encodedDataIndex, - maxAddress - encodedDataIndex, - "%02x", - message->diagnostic_stitch_response.payload.bytes[i]); - } - cJSON_AddStringToObject(root, payload::json::DIAGNOSTIC_PAYLOAD_FIELD_NAME, - encodedData); - } - return true; -} - static bool serializeCommandResponse(openxc_VehicleMessage* message, cJSON* root) { const char* typeString = NULL; @@ -624,7 +582,7 @@ int openxc::payload::json::serialize(openxc_VehicleMessage* message, size_t finalLength = 0; if(root != NULL) { bool status = true; - if(message->type != openxc_VehicleMessage_Type_UNUSED) { + if(message->timestamp != 0) { cJSON_AddNumberToObject(root, "timestamp", message->timestamp); } if(message->type == openxc_VehicleMessage_Type_SIMPLE) { @@ -633,8 +591,6 @@ int openxc::payload::json::serialize(openxc_VehicleMessage* message, status = serializeCan(message, root); } else if(message->type == openxc_VehicleMessage_Type_DIAGNOSTIC) { status = serializeDiagnostic(message, root); - } else if(message->type == openxc_VehicleMessage_Type_DIAGNOSTIC_STITCH) { - status =serializeStitchDiagnostic(message, root); } else if(message->type == openxc_VehicleMessage_Type_COMMAND_RESPONSE) { status = serializeCommandResponse(message, root); } else { diff --git a/src/payload/json.h b/src/payload/json.h index f77fbd4b3..7ea71b3a3 100644 --- a/src/payload/json.h +++ b/src/payload/json.h @@ -20,7 +20,6 @@ extern const char PREDEFINED_OBD2_REQUESTS_COMMAND_NAME[]; extern const char PAYLOAD_FORMAT_JSON_NAME[]; extern const char PAYLOAD_FORMAT_PROTOBUF_NAME[]; -extern const char PAYLOAD_FORMAT_MESSAGEPACK_NAME[]; extern const char COMMAND_RESPONSE_FIELD_NAME[]; extern const char COMMAND_RESPONSE_MESSAGE_FIELD_NAME[]; diff --git a/src/payload/messagepack.cpp b/src/payload/messagepack.cpp deleted file mode 100644 index 8fa9d1fdd..000000000 --- a/src/payload/messagepack.cpp +++ /dev/null @@ -1,1108 +0,0 @@ -#include "payload.h" -#include -#include -#include -#include -#include -#include -#include "messagepack.h" -#include "util/strutil.h" -#include "util/log.h" -#include "config.h" -#include "util/log.h" - -#define MESSAGE_PACK_SERIAL_BUF_SZ 128 -#define MESSAGE_PACK_FIXMAP_MARKER 0x80 -#define MESSAGE_PACK_FIXMAP_SIZE 0x0F -#define MESSAGE_PACK_FALSE_MARKER 0xC2 -#define MESSAGE_PACK_TRUE_MARKER 0xC3 -#define MESSAGE_PACK_DOUBLE_MARKER 0xCB -#define MESSAGE_PACK_FIXSTR_MARKER 0xA0 -#define MESSAGE_PACK_FIXMAP_MARKER 0x80 -#define MESSAGE_PACK_MAX_STRLEN 0x1F - -#define MAX_STRLEN 25 -#define MAX_BINLEN 25 - -namespace payload = openxc::payload; -using openxc::util::log::debug; - -const char openxc::payload::messagepack::VERSION_COMMAND_NAME[] = "version"; -const char openxc::payload::messagepack::DEVICE_ID_COMMAND_NAME[] = "device_id"; -const char openxc::payload::messagepack::DEVICE_PLATFORM_COMMAND_NAME[] = "platform"; -const char openxc::payload::messagepack::DIAGNOSTIC_COMMAND_NAME[] = "diagnostic_request"; -const char openxc::payload::messagepack::PASSTHROUGH_COMMAND_NAME[] = "passthrough"; -const char openxc::payload::messagepack::ACCEPTANCE_FILTER_BYPASS_COMMAND_NAME[] = "af_bypass"; -const char openxc::payload::messagepack::PAYLOAD_FORMAT_COMMAND_NAME[] = "payload_format"; -const char openxc::payload::messagepack::PREDEFINED_OBD2_REQUESTS_COMMAND_NAME[] = "predefined_obd2"; -const char openxc::payload::messagepack::MODEM_CONFIGURATION_COMMAND_NAME[] = "modem_configuration"; -const char openxc::payload::messagepack::RTC_CONFIGURATION_COMMAND_NAME[] = "rtc_configuration"; - -const char openxc::payload::messagepack::PAYLOAD_FORMAT_MESSAGEPACK_NAME[] = "messagepack"; -const char openxc::payload::messagepack::PAYLOAD_FORMAT_PROTOBUF_NAME[] = "protobuf"; -const char openxc::payload::messagepack::PAYLOAD_FORMAT_JSON_NAME[] = "json"; - -const char openxc::payload::messagepack::COMMAND_RESPONSE_FIELD_NAME[] = "command_response"; -const char openxc::payload::messagepack::COMMAND_RESPONSE_MESSAGE_FIELD_NAME[] = "message"; -const char openxc::payload::messagepack::COMMAND_RESPONSE_STATUS_FIELD_NAME[] = "status"; - -const char openxc::payload::messagepack::BUS_FIELD_NAME[] = "bus"; -const char openxc::payload::messagepack::ID_FIELD_NAME[] = "id"; -const char openxc::payload::messagepack::DATA_FIELD_NAME[] = "data"; -const char openxc::payload::messagepack::NAME_FIELD_NAME[] = "name"; -const char openxc::payload::messagepack::VALUE_FIELD_NAME[] = "value"; -const char openxc::payload::messagepack::EVENT_FIELD_NAME[] = "event"; -const char openxc::payload::messagepack::FRAME_FORMAT_FIELD_NAME[] = "frame_format"; - -const char openxc::payload::messagepack::FRAME_FORMAT_STANDARD_NAME[] = "standard"; -const char openxc::payload::messagepack::FRAME_FORMAT_EXTENDED_NAME[] = "extended"; - -const char openxc::payload::messagepack::DIAGNOSTIC_MODE_FIELD_NAME[] = "mode"; -const char openxc::payload::messagepack::DIAGNOSTIC_PID_FIELD_NAME[] = "pid"; -const char openxc::payload::messagepack::DIAGNOSTIC_SUCCESS_FIELD_NAME[] = "success"; -const char openxc::payload::messagepack::DIAGNOSTIC_NRC_FIELD_NAME[] = "negative_response_code"; -const char openxc::payload::messagepack::DIAGNOSTIC_PAYLOAD_FIELD_NAME[] = "payload"; -const char openxc::payload::messagepack::DIAGNOSTIC_VALUE_FIELD_NAME[] = "value"; -const char openxc::payload::messagepack::SD_MOUNT_STATUS_COMMAND_NAME[] = "sd_mount_status"; - - -enum msgpack_var_type{TYPE_STRING,TYPE_NUMBER,TYPE_TRUE,TYPE_FALSE,TYPE_BINARY,TYPE_MAP}; - -int32_t dynamic_allocation_bytes = 0; - -typedef struct sMsgPackNode{ - char * string; //points to string header and not the string inorder to derive string - enum msgpack_var_type type; - double valuedouble; - int valueint; - char *valuestring; - uint8_t *bin; - uint8_t binsz; - sMsgPackNode *next,*child; -}sMsgPackNode; - -typedef struct{ - uint8_t MsgPackMapPairCount; -}meta; - -typedef struct{ - uint8_t * end; - uint8_t * start; - uint8_t * rp; - uint8_t * wp; - meta mobj; -}sFile; - -sMsgPackNode* msgPackParse(uint8_t* buf,uint32_t* len); - -static size_t msgPackWriteBuffer(cmp_ctx_t *ctx, const void *data, size_t count) { - - sFile * smsgb = (sFile *)ctx->buf; - - if(ctx->error > 0)return 0; - - if(smsgb->wp + count > (smsgb->end+1)){ - return 0; - } - memcpy(smsgb->wp, data, count); - smsgb->wp += count; - return count; -} - -static bool msgPackReadBuffer(cmp_ctx_t *ctx, void *data, size_t count) { - sFile * smsgb = (sFile *)ctx->buf; - if(smsgb->rp + count > (smsgb->end+1)){ - return 0; - } - memcpy((void*)data, (const void*)smsgb->rp, count); - smsgb->rp += count; - - return count; -} - -static void msgPackInitBuffer(sFile* smsgpackb, uint8_t* buf, uint8_t len){ - - smsgpackb->end = buf + len - 1; - smsgpackb->start = buf; - smsgpackb->rp = buf; - smsgpackb->wp = buf; - -} - -static void msgPackAddObjectString(cmp_ctx_t *ctx, const char* fname ,const char* obj){ - sFile *s = (sFile *)ctx->buf; - cmp_write_str(ctx, (const char *)fname, strlen((const char *)fname)); - cmp_write_str(ctx, (const char *)obj, strlen(obj)); - s->mobj.MsgPackMapPairCount++; -} -static void msgPackAddObjectDouble(cmp_ctx_t *ctx, const char* fname ,double obj){ - sFile *s = (sFile *)ctx->buf; - cmp_write_str(ctx, (const char *)fname, strlen((const char *)fname)); - cmp_write_double(ctx, obj); - s->mobj.MsgPackMapPairCount++; -} -static void msgPackAddObject8bNumeric(cmp_ctx_t *ctx, const char* fname ,uint8_t obj){ - sFile *s = (sFile *)ctx->buf; - cmp_write_str(ctx, (const char *)fname, strlen((const char *)fname)); - cmp_write_u8(ctx, obj); - s->mobj.MsgPackMapPairCount++; -} -static void msgPackAddObject16bNumeric(cmp_ctx_t *ctx, const char* fname ,uint16_t obj){ - sFile *s = (sFile *)ctx->buf; - cmp_write_str(ctx, (const char *)fname, strlen((const char *)fname)); - cmp_write_u16(ctx, obj); - s->mobj.MsgPackMapPairCount++; -} -/* -static void msgPackAddObject32bNumeric(cmp_ctx_t *ctx, const char* fname ,uint32_t obj){ - sFile *s = (sFile *)ctx->buf; - cmp_write_str(ctx, (const char *)fname, strlen((const char *)fname)); - cmp_write_u32(ctx, obj); - s->mobj.MsgPackMapPairCount++; -} -*/ -static void msgPackAddObject64bNumeric(cmp_ctx_t *ctx, const char* fname ,uint32_t obj){ - sFile *s = (sFile *)ctx->buf; - cmp_write_str(ctx, (const char *)fname, strlen((const char *)fname)); - cmp_write_u64(ctx, obj); - s->mobj.MsgPackMapPairCount++; -} -/* -static void msgPackAddObjectFloat(cmp_ctx_t *ctx, const char* fname ,float obj){ - sFile *s = (sFile *)ctx->buf; - cmp_write_str(ctx, (const char *)fname, strlen((const char *)fname)); - cmp_write_float(ctx, obj); - s->mobj.MsgPackMapPairCount++; -} -*/ -static void msgPackAddObjectBoolean(cmp_ctx_t *ctx, const char* fname ,bool obj){ - sFile *s = (sFile *)ctx->buf; - cmp_write_str(ctx, (const char *)fname, strlen((const char *)fname)); - cmp_write_bool(ctx, obj); - s->mobj.MsgPackMapPairCount++; -} -static void msgPackAddObjectBinary(cmp_ctx_t *ctx, const char* fname ,uint8_t* obj, uint8_t len){ - sFile *s = (sFile *)ctx->buf; - cmp_write_str(ctx, (const char *)fname, strlen((const char *)fname)); - //cmp_write_bin_marker(ctx, len); - cmp_write_bin(ctx,(const void *)obj, len); //writes marker as well - s->mobj.MsgPackMapPairCount++; -} -/* -static void msgPackAddObjectMap(cmp_ctx_t *ctx, const char* fname ,uint8_t* obj,uint8_t len){ - sFile *s = (sFile *)ctx->buf; - cmp_write_str(ctx, (const char *)fname, strlen((const char *)fname)); - msgPackWriteBuffer(ctx, obj, len); - s->mobj.MsgPackMapPairCount++; -} -*/ - - -static void msgPackAddDynamicField(cmp_ctx_t *ctx, openxc_DynamicField* field) { - - if(field->type == openxc_DynamicField_Type_NUM) { - cmp_write_double(ctx, field->numeric_value); - } else if(field->type == openxc_DynamicField_Type_BOOL) { - cmp_write_bool(ctx, field->boolean_value); - } else if(field->type == openxc_DynamicField_Type_STRING) { - cmp_write_str(ctx, field->string_value, strlen(field->string_value)); - } - -} - -static void serializeSimple(openxc_VehicleMessage* message, cmp_ctx_t *ctx) { - - const char* name = message->simple_message.name; - sFile *s = (sFile *)ctx->buf; - msgPackAddObjectString(ctx, payload::messagepack::NAME_FIELD_NAME, name); - - if(message->simple_message.value.type != openxc_DynamicField_Type_UNUSED) { - cmp_write_str(ctx, payload::messagepack::VALUE_FIELD_NAME, strlen(payload::messagepack::VALUE_FIELD_NAME)); - msgPackAddDynamicField(ctx, &message->simple_message.value); - s->mobj.MsgPackMapPairCount++; - } - - if(message->simple_message.event.type != openxc_DynamicField_Type_UNUSED) { - cmp_write_str(ctx, payload::messagepack::EVENT_FIELD_NAME, strlen(payload::messagepack::EVENT_FIELD_NAME)); - msgPackAddDynamicField(ctx, &message->simple_message.event); - s->mobj.MsgPackMapPairCount++; - } -} - -void serializeCan(openxc_VehicleMessage* message, cmp_ctx_t *ctx) { - - msgPackAddObject8bNumeric(ctx, payload::messagepack::BUS_FIELD_NAME, message->can_message.bus); - - msgPackAddObject8bNumeric(ctx, payload::messagepack::ID_FIELD_NAME, message->can_message.bus); - - msgPackAddObjectBinary(ctx, payload::messagepack::DATA_FIELD_NAME, - message->can_message.data.bytes,message->can_message.data.size); - - if(message->can_message.frame_format != openxc_CanMessage_FrameFormat_UNUSED) { - msgPackAddObjectString(ctx, payload::messagepack::FRAME_FORMAT_FIELD_NAME, - message->can_message.frame_format == openxc_CanMessage_FrameFormat_STANDARD ? - payload::messagepack::FRAME_FORMAT_STANDARD_NAME : - payload::messagepack::FRAME_FORMAT_EXTENDED_NAME); - } -} - -static void serializeDiagnostic(openxc_VehicleMessage* message, cmp_ctx_t *ctx) { - - msgPackAddObject8bNumeric(ctx, payload::messagepack::BUS_FIELD_NAME, - message->diagnostic_response.bus); - msgPackAddObject8bNumeric(ctx, payload::messagepack::ID_FIELD_NAME, - message->diagnostic_response.message_id); - msgPackAddObject8bNumeric(ctx, payload::messagepack::DIAGNOSTIC_MODE_FIELD_NAME, - message->diagnostic_response.mode); - msgPackAddObjectBoolean(ctx, payload::messagepack::DIAGNOSTIC_SUCCESS_FIELD_NAME, - message->diagnostic_response.success); - msgPackAddObject16bNumeric(ctx, payload::messagepack::DIAGNOSTIC_PID_FIELD_NAME, - message->diagnostic_response.pid); - - if(message->diagnostic_response.negative_response_code != 0) { - msgPackAddObjectDouble(ctx, payload::messagepack::DIAGNOSTIC_NRC_FIELD_NAME, - message->diagnostic_response.negative_response_code); - } - - if(message->diagnostic_response.value.type != openxc_DynamicField_Type_UNUSED) { - cmp_write_str(ctx, payload::messagepack::VALUE_FIELD_NAME, strlen(payload::messagepack::VALUE_FIELD_NAME)); - msgPackAddDynamicField(ctx, &message->diagnostic_response.value); - - } else if(message->diagnostic_response.payload.size > 0) { - msgPackAddObjectBinary(ctx, payload::messagepack::DIAGNOSTIC_PAYLOAD_FIELD_NAME, - message->diagnostic_response.payload.bytes, message->diagnostic_response.payload.size); - - } - -} - -static bool serializeCommandResponse(openxc_VehicleMessage* message, cmp_ctx_t *ctx) { - - const char* typeString = NULL; - - if(message->command_response.type == openxc_ControlCommand_Type_VERSION) { - typeString = payload::messagepack::VERSION_COMMAND_NAME; - } else if(message->command_response.type == openxc_ControlCommand_Type_DEVICE_ID) { - typeString = payload::messagepack::DEVICE_ID_COMMAND_NAME; - } else if(message->command_response.type == openxc_ControlCommand_Type_PLATFORM) { - typeString = payload::messagepack::DEVICE_PLATFORM_COMMAND_NAME; - } else if(message->command_response.type == openxc_ControlCommand_Type_DIAGNOSTIC) { - typeString = payload::messagepack::DIAGNOSTIC_COMMAND_NAME; - } else if(message->command_response.type == openxc_ControlCommand_Type_PASSTHROUGH) { - typeString = payload::messagepack::PASSTHROUGH_COMMAND_NAME; - } else if(message->command_response.type == openxc_ControlCommand_Type_ACCEPTANCE_FILTER_BYPASS) { - typeString = payload::messagepack::ACCEPTANCE_FILTER_BYPASS_COMMAND_NAME; - } else if(message->command_response.type == openxc_ControlCommand_Type_PAYLOAD_FORMAT) { - typeString = payload::messagepack::PAYLOAD_FORMAT_COMMAND_NAME; - } else if(message->command_response.type == openxc_ControlCommand_Type_PREDEFINED_OBD2_REQUESTS) { - typeString = payload::messagepack::PREDEFINED_OBD2_REQUESTS_COMMAND_NAME; - } else if(message->command_response.type == openxc_ControlCommand_Type_MODEM_CONFIGURATION) { - typeString = payload::messagepack::MODEM_CONFIGURATION_COMMAND_NAME; - } else if(message->command_response.type == openxc_ControlCommand_Type_RTC_CONFIGURATION) { - typeString = payload::messagepack::RTC_CONFIGURATION_COMMAND_NAME; - } else if(message->command_response.type == openxc_ControlCommand_Type_SD_MOUNT_STATUS) { - typeString = payload::messagepack::SD_MOUNT_STATUS_COMMAND_NAME; - } else { - return false; - } - - msgPackAddObjectString(ctx, payload::messagepack::COMMAND_RESPONSE_FIELD_NAME, - typeString); - - - if(message->command_response.type != openxc_ControlCommand_Type_UNUSED) { - msgPackAddObjectString(ctx, - payload::messagepack::COMMAND_RESPONSE_MESSAGE_FIELD_NAME, - message->command_response.message); - } - - if(message->command_response.type != openxc_ControlCommand_Type_UNUSED) { - msgPackAddObjectBoolean(ctx, - payload::messagepack::COMMAND_RESPONSE_STATUS_FIELD_NAME, - message->command_response.status); - } - return true; -} - - -int openxc::payload::messagepack::serialize(openxc_VehicleMessage* message, uint8_t payload[], size_t length) -{ - - sFile smsgpackb; - - uint8_t MessagePackBuffer[MESSAGE_PACK_SERIAL_BUF_SZ]; - - size_t finalLength = 0; - - cmp_ctx_t cmp; - - memset((void*)&smsgpackb,0,sizeof(smsgpackb)); - - msgPackInitBuffer(&smsgpackb, MessagePackBuffer, MESSAGE_PACK_SERIAL_BUF_SZ); - - cmp_init(&cmp,(void*)&smsgpackb, msgPackReadBuffer, msgPackWriteBuffer); - - cmp_write_map(&cmp,2); - - //"{\"command\": \"diagnostic_request\", \"actio" - //"n\": \"add\", \"request\": {\"bus\": 1, \"id\": 2, \"mode\": 1}}\0"; - - //"{\"command\": \"version\"}\0"; - - //msgPackAddObjectString(&cmp, "command", "device_id"); - //cmp_write_map(&cmp,3); - //msgPackAddObjectString(&cmp, "command", "passthrough"); - //msgPackAddObject8bNumeric(&cmp, "bus", 1); - //msgPackAddObjectBoolean(&cmp, "enabled", 1); - //goto x; - /* - cmp_write_map(&cmp,3); - msgPackAddObjectString(&cmp, "command", "diagnostic_request"); - msgPackAddObjectString(&cmp, "action", "add"); - cmp_write_str(&cmp, "request", 7); - cmp_write_map(&cmp,3); - msgPackAddObject8bNumeric(&cmp, "bus", 1); - msgPackAddObject8bNumeric(&cmp, "id", 2); - msgPackAddObject8bNumeric(&cmp, "mode", 1); - smsgpackb.mobj.MsgPackMapPairCount -=3; - goto x; - */ - if(message->type != openxc_VehicleMessage_Type_UNUSED) { - - msgPackAddObject64bNumeric(&cmp, "timestamp", message->timestamp); - - } - if(message->type == openxc_VehicleMessage_Type_SIMPLE) { - serializeSimple(message, &cmp); - } else if(message->type == openxc_VehicleMessage_Type_CAN) { - serializeCan(message, &cmp); - } else if(message->type == openxc_VehicleMessage_Type_DIAGNOSTIC) { - serializeDiagnostic(message, &cmp); - } else if(message->type == openxc_VehicleMessage_Type_COMMAND_RESPONSE) { - serializeCommandResponse(message, &cmp); - } else { - debug("Unrecognized message type -- not sending"); - } - - if(cmp.error > 0){ - debug("%s\n\n", cmp_strerror(&cmp)); - return 0; - } - if( smsgpackb.mobj.MsgPackMapPairCount > MESSAGE_PACK_FIXMAP_SIZE) - { - debug("Unhandled, excedded fix map limit %d",smsgpackb.mobj.MsgPackMapPairCount); - return 0; - } - - smsgpackb.start[0] = MESSAGE_PACK_FIXMAP_MARKER | smsgpackb.mobj.MsgPackMapPairCount; //todo create a function to add this more gracefully - - - finalLength = smsgpackb.wp - smsgpackb.start; - - memcpy(payload, MessagePackBuffer, finalLength); - - //debug ("parsing %d bytes",finalLength); - //openxc_VehicleMessage m; - //int l = openxc::payload::messagepack::deserialize(payload,finalLength,&m); - //debug ("deserialized %d bytes",l); - //while(1); -/* - for(int i = 0;i < finalLength; i ++) - { - debug("%x", payload[i]); - } - - debug("\n\n"); - - -*/ - return finalLength; -} -sMsgPackNode * msgPackSeekNode(sMsgPackNode* root,const char * name ){ - sMsgPackNode * node = root; - while(node){ - if(strcmp(node->string, name) == 0){ - if(node->child)return node->child; - - return node; - } - node = node->next; - } - //debug("Missing %s",name); - return node; -} - -sMsgPackNode* getnode(cmp_ctx_t * ctx){ - - - char vstr[MAX_STRLEN+1]; - char nstr[MAX_STRLEN+1]; - char binarr[MAX_BINLEN+1]; - uint32_t str_size; - char binsz = 0; - cmp_object_t obj; - enum msgpack_var_type type; - double vd=0.0; - int vi=0; - sMsgPackNode* ch; - - str_size = MAX_STRLEN; - - if (!cmp_read_str(ctx, nstr, &str_size)){ - //debug("Node incomplete %s",cmp_strerror(ctx)); - return NULL; - } - - if (cmp_read_object(ctx, &obj) == true) { //read value - switch (obj.type) { - case CMP_TYPE_FIXARRAY: - case CMP_TYPE_ARRAY16: - case CMP_TYPE_ARRAY32: - case CMP_TYPE_EXT8: - case CMP_TYPE_EXT16: - case CMP_TYPE_EXT32: - case CMP_TYPE_FIXEXT1: - case CMP_TYPE_FIXEXT2: - case CMP_TYPE_FIXEXT4: - case CMP_TYPE_FIXEXT8: - case CMP_TYPE_FIXEXT16: - case CMP_TYPE_NIL: - case CMP_TYPE_UINT64: - case CMP_TYPE_NEGATIVE_FIXNUM: - case CMP_TYPE_SINT8: - case CMP_TYPE_SINT16: - case CMP_TYPE_SINT32: - case CMP_TYPE_SINT64: - { - debug("Unhandled object %d",obj.type); - return NULL; - break; - } - case CMP_TYPE_FIXMAP: - case CMP_TYPE_MAP16: - case CMP_TYPE_MAP32: - { - sFile * s = (sFile *)ctx->buf; - s->rp--; - uint32_t plen = (s->end - s->rp) + 1; - ch = msgPackParse(s->rp,&plen); - if(ch == NULL){ - //debug("Child incomplete %s",cmp_strerror(ctx)); - return NULL; - } - - s->rp += plen + 1; - type = msgpack_var_type::TYPE_MAP; - break; - } - case CMP_TYPE_BIN8: - case CMP_TYPE_BIN16: - case CMP_TYPE_BIN32: - { - if(obj.as.bin_size > MAX_BINLEN) - { - debug("Payload exceeded limit %d bytes",obj.as.bin_size); - return NULL; - } - if (!msgPackReadBuffer(ctx, binarr, obj.as.bin_size)) - { - //debug("Data missing total %d %d %d //%dbytes",obj.as.bin_size,s->rp-s->start,s->end-s->rp,s->end-s->start); - return NULL; - } - binsz = obj.as.bin_size; - type = msgpack_var_type::TYPE_BINARY; - break; - } - - case CMP_TYPE_FIXSTR: - case CMP_TYPE_STR8: - case CMP_TYPE_STR16: - case CMP_TYPE_STR32: - { - if(obj.as.str_size > MAX_STRLEN) - return NULL; - - if (!msgPackReadBuffer(ctx, vstr, obj.as.str_size)) - return NULL; - - vstr[obj.as.str_size] = 0; - type = msgpack_var_type::TYPE_STRING; - break; - } - - case CMP_TYPE_BOOLEAN: - { - if (obj.as.boolean) - type = msgpack_var_type::TYPE_TRUE; - else - type = msgpack_var_type::TYPE_FALSE; - - break; - } - case CMP_TYPE_FLOAT: - { - type = msgpack_var_type::TYPE_NUMBER; - vd = obj.as.flt; - break; - } - - case CMP_TYPE_DOUBLE: - { - type = msgpack_var_type::TYPE_NUMBER; - vd = obj.as.dbl; - break; - } - - case CMP_TYPE_UINT16: - { - type = msgpack_var_type::TYPE_NUMBER; - vi = obj.as.u16; - break; - } - - case CMP_TYPE_UINT32: - { - type = msgpack_var_type::TYPE_NUMBER; - vi = obj.as.u32; - break; - } - - case CMP_TYPE_POSITIVE_FIXNUM: - case CMP_TYPE_UINT8: - { - type = msgpack_var_type::TYPE_NUMBER; - vi = obj.as.u8; - break; - } - - default: - { - debug("Unrecognized object type %u\n", obj.type); - break; - } - - } - } else - { - //debug("Node incomplete %s",cmp_strerror(ctx)); - return NULL; - } - sMsgPackNode* node = (sMsgPackNode*)malloc(sizeof(sMsgPackNode)); - dynamic_allocation_bytes += sizeof(sMsgPackNode); - if(node == NULL){ - debug("Unable to create node in memory"); - return NULL; - } - - str_size = strlen(nstr); - node->string = (char*)malloc(str_size + 1); - dynamic_allocation_bytes += str_size + 1; - memcpy(node->string,nstr,str_size); //copy null terminator as well - node->string[str_size] = '\0'; - node->type = type; - - if(node->type == msgpack_var_type::TYPE_BINARY){ - node->bin = (uint8_t *)malloc(binsz); - dynamic_allocation_bytes += binsz; - if(node->bin ==NULL){ - debug("Unable to allocate mem bin"); - } - memcpy(node->bin,binarr,binsz); - node->binsz = binsz; - //debug("allocated node"); - } - if(node->type == msgpack_var_type::TYPE_STRING){ - str_size = strlen(vstr); - node->valuestring = (char *)malloc(str_size+1); - dynamic_allocation_bytes += str_size + 1; - if(node->valuestring == NULL){ - debug("Unable to allocate mem str"); - } - memcpy(node->valuestring,vstr,str_size); - node->valuestring[str_size] = '\0'; - } - node->child = NULL; - if(type == msgpack_var_type::TYPE_MAP){ - node->child = ch; - } - node->valueint = vi; - node->valuedouble = vd; - node->next = NULL; - return node; -} - -void msgPackListNodes(sMsgPackNode* root) -{ - sMsgPackNode* n = root; - debug("list:"); - while(n) - { - if(n->child){ - debug("child:"); - msgPackListNodes(n->child); - } - - debug("%s",n->string); - n = n->next; - } -} - -void MsgPackDelete(sMsgPackNode* root)//rentrant -{ - sMsgPackNode *pv, *rp; - - rp = root; - while(root->next){ - pv = rp->next; - while(pv->next){ - rp = pv; - pv = pv->next; - if(pv->child){ - MsgPackDelete(pv->child); - pv->child = NULL; - goto x; - } - } - //debug("deleting:%s",pv->string); - dynamic_allocation_bytes -= (strlen(pv->string) + 1); - free(pv->string); - - if(pv->type == msgpack_var_type::TYPE_STRING){ - dynamic_allocation_bytes -= (strlen(pv->valuestring) + 1); - free(pv->valuestring); - - } - if(pv->type == msgpack_var_type::TYPE_BINARY){ - dynamic_allocation_bytes -= (pv->binsz); - free(pv->bin); - } - if(pv->child){ - MsgPackDelete(pv->child); - } - free(pv); - dynamic_allocation_bytes -= sizeof(sMsgPackNode); - rp->next = NULL; -x: - rp = root; - } - //debug("deleting:%s",root->string); - dynamic_allocation_bytes -= (strlen(root->string) + 1); - free(root->string); - if(root->type == msgpack_var_type::TYPE_STRING){ - dynamic_allocation_bytes -= (strlen(root->valuestring) + 1); - free(root->valuestring); - } - if(pv->type == msgpack_var_type::TYPE_BINARY){ - dynamic_allocation_bytes -= (root->binsz); - free(root->bin); - } - free(root); - dynamic_allocation_bytes -= sizeof(sMsgPackNode); -} - -sMsgPackNode* msgPackParse(uint8_t* buf,uint32_t* len){ //reentrant - - sMsgPackNode *node = NULL; - sMsgPackNode *root = NULL; - - sFile smsgpackb; - - cmp_ctx_t cmp; - - if (!(buf[0] > 0x80 && buf[0] < 0x8f)){ - return NULL; - } - - uint32_t map_len; - - msgPackInitBuffer(&smsgpackb, buf, *len); - - cmp_init(&cmp,(void*)&smsgpackb, msgPackReadBuffer, msgPackWriteBuffer); - - - if(cmp_read_map(&cmp, &map_len) == false) - { - return NULL; - } - - //debug("Maplen %d", map_len); - root = getnode(&cmp); //get node creates a node on the heap using malloc - - if( root == NULL) - { - //debug("Root Node missing"); - return NULL; - } - node = root; - map_len--; - while( map_len ){ - - node->next = getnode(&cmp); - - if(node->next == NULL){ - //debug("Message pack contains partial information"); - MsgPackDelete(root); - return NULL; - } - node = node->next; - map_len--; - } - *len = (uint32_t)(smsgpackb.rp - smsgpackb.start); //update bytes read from buffer - return root; -} - - -static void deserializePassthrough(sMsgPackNode* root, openxc_ControlCommand* command) { - - command->type = openxc_ControlCommand_Type_PASSTHROUGH; - - sMsgPackNode* element = msgPackSeekNode(root, "bus"); - - if(element != NULL) { - command->passthrough_mode_request.bus = element->valueint; - } - - element = msgPackSeekNode(root, "enabled"); - if(element != NULL) { - command->passthrough_mode_request.enabled = bool(element->valueint); - } -} - -static void deserializePayloadFormat(sMsgPackNode* root, - openxc_ControlCommand* command) { - - command->type = openxc_ControlCommand_Type_PAYLOAD_FORMAT; - - sMsgPackNode* element = msgPackSeekNode(root, "format"); - if(element != NULL) { - if(!strcmp(element->valuestring, - openxc::payload::messagepack::PAYLOAD_FORMAT_JSON_NAME)) { - command->payload_format_command.format = - openxc_PayloadFormatCommand_PayloadFormat_JSON; - } else if(!strcmp(element->valuestring, - openxc::payload::messagepack::PAYLOAD_FORMAT_PROTOBUF_NAME)) { - command->payload_format_command.format = - openxc_PayloadFormatCommand_PayloadFormat_PROTOBUF; - } else if(!strcmp(element->valuestring, - openxc::payload::messagepack::PAYLOAD_FORMAT_MESSAGEPACK_NAME)) { - command->payload_format_command.format = openxc_PayloadFormatCommand_PayloadFormat_MESSAGEPACK; - } - } -} - -static void deserializePredefinedObd2RequestsCommand(sMsgPackNode* root, - openxc_ControlCommand* command) { - - command->type = openxc_ControlCommand_Type_PREDEFINED_OBD2_REQUESTS; - - sMsgPackNode* element = msgPackSeekNode(root, "enabled"); - if(element != NULL) { - command->predefined_obd2_requests_command.enabled = bool(element->valueint); - } -} - -static void deserializeAfBypass(sMsgPackNode* root, openxc_ControlCommand* command) { - command->type = openxc_ControlCommand_Type_ACCEPTANCE_FILTER_BYPASS; - - sMsgPackNode* element = msgPackSeekNode(root, "bus"); - if(element != NULL) { - command->acceptance_filter_bypass_command.bus = element->valueint; - } - - element = msgPackSeekNode(root, "bypass"); - if(element != NULL) { - command->acceptance_filter_bypass_command.bypass = - bool(element->valueint); - } -} - -static void deserializeDiagnostic(sMsgPackNode* root, openxc_ControlCommand* command) { - command->type = openxc_ControlCommand_Type_DIAGNOSTIC; - - sMsgPackNode* action = msgPackSeekNode(root, "action"); - if(action != NULL && action->type == msgpack_var_type::TYPE_STRING) { - if(!strcmp(action->valuestring, "add")) { - command->diagnostic_request.action = - openxc_DiagnosticControlCommand_Action_ADD; - } else if(!strcmp(action->valuestring, "cancel")) { - command->diagnostic_request.action = - openxc_DiagnosticControlCommand_Action_CANCEL; - } - } - - sMsgPackNode* request = msgPackSeekNode(root, "request"); - if(request != NULL) { - sMsgPackNode * element = msgPackSeekNode(request, "bus"); - if(element != NULL) { - command->diagnostic_request.request.bus = element->valueint; - } - - element = msgPackSeekNode(request, "mode"); - if(element != NULL) { - command->diagnostic_request.request.mode = element->valueint; - } - - element = msgPackSeekNode(request, "id"); - if(element != NULL) { - command->diagnostic_request.request.message_id = element->valueint; - } - - element = msgPackSeekNode(request, "pid"); - if(element != NULL) { - command->diagnostic_request.request.pid = element->valueint; - } - - element = msgPackSeekNode(request, "payload"); - if(element != NULL) { - if(request->type == msgpack_var_type::TYPE_BINARY){ - command->diagnostic_request.request.payload.size = request->binsz; - memcpy(command->diagnostic_request.request.payload.bytes, - request->bin,request->binsz); - } - } - - element = msgPackSeekNode(request, "multiple_responses"); - if(element != NULL) { - command->diagnostic_request.request.multiple_responses = - bool(element->valueint); - } - - element = msgPackSeekNode(request, "frequency"); - if(element != NULL) { - command->diagnostic_request.request.frequency = - element->valuedouble; - } - - element = msgPackSeekNode(request, "decoded_type"); - if(element != NULL) { - if(!strcmp(element->valuestring, "obd2")) { - command->diagnostic_request.request.decoded_type = - openxc_DiagnosticRequest_DecodedType_OBD2; - } else if(!strcmp(element->valuestring, "none")) { - command->diagnostic_request.request.decoded_type = - openxc_DiagnosticRequest_DecodedType_NONE; - } - } - - element = msgPackSeekNode(request, "name"); - if(element != NULL && element->type == msgpack_var_type::TYPE_STRING) { - strcpy(command->diagnostic_request.request.name, - element->valuestring); - } - } -} - -static bool deserializeDynamicField(sMsgPackNode* element, - openxc_DynamicField* field) { - bool status = true; - switch(element->type) { - case msgpack_var_type::TYPE_STRING: - field->type = openxc_DynamicField_Type_STRING; - strcpy(field->string_value, element->valuestring); - break; - case msgpack_var_type::TYPE_FALSE: - case msgpack_var_type::TYPE_TRUE: - field->type = openxc_DynamicField_Type_BOOL; - field->boolean_value = bool(element->valueint); - break; - case msgpack_var_type::TYPE_NUMBER: - field->type = openxc_DynamicField_Type_NUM; - field->numeric_value = element->valuedouble; - break; - default: - debug("Unsupported type in value field: %d", element->type); - status = false; - break; - } - return status; -} - -static void deserializeSimple(sMsgPackNode* root, openxc_VehicleMessage* message) { - message->type = openxc_VehicleMessage_Type_SIMPLE; - openxc_SimpleMessage* simpleMessage = &message->simple_message; - - sMsgPackNode* element = msgPackSeekNode(root, "name"); - if(element != NULL && element->type == msgpack_var_type::TYPE_STRING) { - strcpy(simpleMessage->name, element->valuestring); - } - - element = msgPackSeekNode(root, "value"); - if(element != NULL) { - if(deserializeDynamicField(element, &simpleMessage->value)) { - } - } - - element = msgPackSeekNode(root, "event"); - if(element != NULL) { - if(deserializeDynamicField(element, &simpleMessage->event)) { - } - } -} - -static void deserializeCan(sMsgPackNode* root, openxc_VehicleMessage* message) { - message->type = openxc_VehicleMessage_Type_CAN; - openxc_CanMessage* canMessage = &message->can_message; - - sMsgPackNode* element = msgPackSeekNode(root, "id"); - if(element != NULL) { - canMessage->id = element->valueint; - element = msgPackSeekNode(root, "data"); - if(element != NULL) { - if(element->type == msgpack_var_type::TYPE_BINARY){ - canMessage->data.size = element->binsz; - memcpy(canMessage->data.bytes, - element->bin,element->binsz); - } - } - - element = msgPackSeekNode(root, "bus"); - if(element != NULL) { - canMessage->bus = element->valueint; - } - - element = msgPackSeekNode(root, payload::messagepack::FRAME_FORMAT_FIELD_NAME); - if(element != NULL) { - if(!strcmp(element->valuestring, - payload::messagepack::FRAME_FORMAT_STANDARD_NAME)) { - canMessage->frame_format = openxc_CanMessage_FrameFormat_STANDARD; - } else if(!strcmp(element->valuestring, - payload::messagepack::FRAME_FORMAT_EXTENDED_NAME)) { - canMessage->frame_format = openxc_CanMessage_FrameFormat_EXTENDED; - } - } - } -} - -static void deserializeModemConfiguration(sMsgPackNode* root, openxc_ControlCommand* command) { - // set up the struct for a modem configuration message - command->type = openxc_ControlCommand_Type_MODEM_CONFIGURATION; - openxc_ModemConfigurationCommand* modemConfigurationCommand = &command->modem_configuration_command; - - // parse server command - sMsgPackNode* server = msgPackSeekNode(root, "server"); - if(server != NULL) { - sMsgPackNode* host = msgPackSeekNode(server, "host"); - if(host != NULL) { - strcpy(modemConfigurationCommand->serverConnectSettings.host, host->valuestring); - } - sMsgPackNode* port = msgPackSeekNode(server, "port"); - if(port != NULL) { - modemConfigurationCommand->serverConnectSettings.port = port->valueint; - } - } -} - -static void deserializeRTCConfiguration(sMsgPackNode* root, openxc_ControlCommand* command) { - - command->type = openxc_ControlCommand_Type_RTC_CONFIGURATION; - openxc_RTCConfigurationCommand* rtcConfigurationCommand = &command->rtc_configuration_command; - - sMsgPackNode* time = msgPackSeekNode(root, "time"); - - if(time != NULL) { - rtcConfigurationCommand->unix_time = time->valueint; - } -} - - - - -//Entire data is chunked into a single packet by higher level protocol -//unable to decode partial messages at this moment correctly -size_t openxc::payload::messagepack::deserialize(uint8_t payload[], size_t length, - openxc_VehicleMessage* message){ - - uint32_t Messagelen=0; - uint32_t i = 0; - sMsgPackNode *root; - //debug("Deserialize %d bytes",length); - root = NULL; - //find the start of message by searching for FIXMAPMARKER - while(i < length){ - if(payload[i] > 0x80 && payload[i] < 0x8f){//attempt to parse message if found - uint32_t len = length-i; - root = msgPackParse(&payload[i],&len); - if( root != NULL)//we found a message - { - //debug("Message Pack Data Complete %d bytes", len); - //msgPackListNodes(root); - Messagelen = i + len; //message len to discard on success, discarding previous data - break; - } - } - i++; - } - if(root == NULL) - { - //debug("MessagePackMemUsed:%d bytes", dynamic_allocation_bytes); - return 0; - } - sMsgPackNode* commandNameObject = msgPackSeekNode(root, "command"); - - if(commandNameObject != NULL) { - - message->type = openxc_VehicleMessage_Type_CONTROL_COMMAND; - openxc_ControlCommand* command = &message->control_command; - - if(!strncmp(commandNameObject->valuestring, VERSION_COMMAND_NAME, - strlen(VERSION_COMMAND_NAME))) { - command->type = openxc_ControlCommand_Type_VERSION; - } else if(!strncmp(commandNameObject->valuestring, - DEVICE_ID_COMMAND_NAME, strlen(DEVICE_ID_COMMAND_NAME))) { - command->type = openxc_ControlCommand_Type_DEVICE_ID; - } else if(!strncmp(commandNameObject->valuestring, - DEVICE_PLATFORM_COMMAND_NAME, strlen(DEVICE_PLATFORM_COMMAND_NAME))) { - command->type = openxc_ControlCommand_Type_PLATFORM; - } else if(!strncmp(commandNameObject->valuestring, - DIAGNOSTIC_COMMAND_NAME, strlen(DIAGNOSTIC_COMMAND_NAME))) { - deserializeDiagnostic(root, command); - } else if(!strncmp(commandNameObject->valuestring, - PASSTHROUGH_COMMAND_NAME, strlen(PASSTHROUGH_COMMAND_NAME))) { - deserializePassthrough(root, command); - } else if(!strncmp(commandNameObject->valuestring, - PREDEFINED_OBD2_REQUESTS_COMMAND_NAME, - strlen(PREDEFINED_OBD2_REQUESTS_COMMAND_NAME))) { - deserializePredefinedObd2RequestsCommand(root, command); - } else if(!strncmp(commandNameObject->valuestring, - ACCEPTANCE_FILTER_BYPASS_COMMAND_NAME, - strlen(ACCEPTANCE_FILTER_BYPASS_COMMAND_NAME))) { - deserializeAfBypass(root, command); - } else if(!strncmp(commandNameObject->valuestring, - PAYLOAD_FORMAT_COMMAND_NAME, - strlen(PAYLOAD_FORMAT_COMMAND_NAME))) { - deserializePayloadFormat(root, command); - } - else if(!strncmp(commandNameObject->valuestring, - MODEM_CONFIGURATION_COMMAND_NAME, - strlen(MODEM_CONFIGURATION_COMMAND_NAME))) { - deserializeModemConfiguration(root, command); - } - else if(!strncmp(commandNameObject->valuestring, - RTC_CONFIGURATION_COMMAND_NAME, - strlen(RTC_CONFIGURATION_COMMAND_NAME))) { - deserializeRTCConfiguration(root, command); - } - else if(!strncmp(commandNameObject->valuestring, - SD_MOUNT_STATUS_COMMAND_NAME, - strlen(SD_MOUNT_STATUS_COMMAND_NAME))) { - command->type = openxc_ControlCommand_Type_SD_MOUNT_STATUS; - } - else { - debug("Unrecognized command: %s", commandNameObject->valuestring); - } - } else{ - sMsgPackNode* nameObject = msgPackSeekNode(root, "name"); - if(nameObject == NULL) { - deserializeCan(root, message); - } else { - deserializeSimple(root, message); - } - } - - MsgPackDelete(root); - Messagelen = MIN(Messagelen,length); - //debug("Parsed: %d bytes", Messagelen); - //debug("MessagePackMemUsed:%d bytes", dynamic_allocation_bytes); - return Messagelen; -} - diff --git a/src/payload/messagepack.h b/src/payload/messagepack.h deleted file mode 100644 index 797eaef4f..000000000 --- a/src/payload/messagepack.h +++ /dev/null @@ -1,75 +0,0 @@ -#ifndef __MESSAGEPACK_H__ -#define __MESSAGEPACK_H__ - -#include "openxc.pb.h" - -namespace openxc { -namespace payload { -namespace messagepack { - -extern const char VERSION_COMMAND_NAME[]; -extern const char DEVICE_ID_COMMAND_NAME[]; -extern const char DEVICE_PLATFORM_COMMAND_NAME[]; -extern const char DIAGNOSTIC_COMMAND_NAME[]; -extern const char PASSTHROUGH_COMMAND_NAME[]; -extern const char ACCEPTANCE_FILTER_BYPASS_COMMAND_NAME[]; -extern const char PAYLOAD_FORMAT_COMMAND_NAME[]; -extern const char PREDEFINED_OBD2_REQUESTS_COMMAND_NAME[]; - -extern const char PAYLOAD_FORMAT_JSON_NAME[]; -extern const char PAYLOAD_FORMAT_PROTOBUF_NAME[]; -extern const char PAYLOAD_FORMAT_MESSAGEPACK_NAME[]; - -extern const char COMMAND_RESPONSE_FIELD_NAME[]; -extern const char COMMAND_RESPONSE_MESSAGE_FIELD_NAME[]; -extern const char COMMAND_RESPONSE_STATUS_FIELD_NAME[]; - -extern const char BUS_FIELD_NAME[]; -extern const char ID_FIELD_NAME[]; -extern const char DATA_FIELD_NAME[]; -extern const char NAME_FIELD_NAME[]; -extern const char VALUE_FIELD_NAME[]; -extern const char EVENT_FIELD_NAME[]; -extern const char FRAME_FORMAT_FIELD_NAME[]; - -extern const char FRAME_FORMAT_STANDARD_NAME[]; -extern const char FRAME_FORMAT_EXTENDED_NAME[]; - -extern const char DIAGNOSTIC_MODE_FIELD_NAME[]; -extern const char DIAGNOSTIC_PID_FIELD_NAME[]; -extern const char DIAGNOSTIC_SUCCESS_FIELD_NAME[]; -extern const char DIAGNOSTIC_NRC_FIELD_NAME[]; -extern const char DIAGNOSTIC_PAYLOAD_FIELD_NAME[]; -extern const char DIAGNOSTIC_VALUE_FIELD_NAME[]; - -extern const char MODEM_CONFIGURATION_COMMAND_NAME[]; -extern const char RTC_CONFIGURATION_COMMAND_NAME[]; - -extern const char SD_MOUNT_STATUS_COMMAND_NAME[]; -/* Public: Deserialize an OpenXC message from a payload containing MessagePack. - * - * payload - The bytestream payload to parse a message from. - * length - The length of the payload. - * message - An output parameter, the object to store the deserialized message. - * - * Returns the number of bytes parsed as MessagePack object from the payload, if any - * was found. - */ -size_t deserialize(uint8_t payload[], size_t length, openxc_VehicleMessage* message); - -/* Public: Serialize an OpenXC message as MessagePack and store in the payload. - * - * message - The message to serialize. - * payload - The buffer to store the payload - must be allocated by the caller. - * length - The length of the payload buffer. - * - * Returns the number of bytes written to the payload. If the length is 0, an - * error occurred while serializing. - */ -int serialize(openxc_VehicleMessage* message, uint8_t payload[], size_t length); - -} // namespace messagepack -} // namespace payload -} // namespace openxc - -#endif // __MESSAGEPACK_H__ diff --git a/src/payload/payload.cpp b/src/payload/payload.cpp index 68434e51c..14ab5982b 100644 --- a/src/payload/payload.cpp +++ b/src/payload/payload.cpp @@ -1,7 +1,6 @@ #include "payload.h" #include "payload/json.h" #include "payload/protobuf.h" -#include "payload/messagepack.h" #include "util/log.h" #include @@ -68,8 +67,6 @@ size_t openxc::payload::deserialize(uint8_t payload[], size_t length, debug("deserialize protobuf"); dumpNum(bytesRead); dumpPayload(payload, bytesRead); - } else if(format == PayloadFormat::MESSAGEPACK){ - bytesRead = payload::messagepack::deserialize(payload, length, message); } else { debug("Invalid payload format: %d", format); } @@ -83,8 +80,6 @@ int openxc::payload::serialize(openxc_VehicleMessage* message, serializedLength = payload::json::serialize(message, payload, length); } else if(format == PayloadFormat::PROTOBUF) { serializedLength = payload::protobuf::serialize(message, payload, length); - } else if(format == PayloadFormat::MESSAGEPACK) { - serializedLength = payload::messagepack::serialize(message, payload, length); } else { debug("Invalid payload format: %d", format); } diff --git a/src/payload/payload.h b/src/payload/payload.h index 6edcec633..a645b7dec 100644 --- a/src/payload/payload.h +++ b/src/payload/payload.h @@ -12,7 +12,6 @@ namespace payload { typedef enum { JSON, PROTOBUF, - MESSAGEPACK, } PayloadFormat; /* Public: Deserialize an OpenXC message from the given payload, using the given diff --git a/src/pipeline.cpp b/src/pipeline.cpp index a7d7c79aa..f2c8ad8d5 100644 --- a/src/pipeline.cpp +++ b/src/pipeline.cpp @@ -177,7 +177,6 @@ void openxc::pipeline::publish(openxc_VehicleMessage* message, matched = true; break; case openxc_VehicleMessage_Type_DIAGNOSTIC: - case openxc_VehicleMessage_Type_DIAGNOSTIC_STITCH: messageClass = MessageClass::DIAGNOSTIC; matched = true; break; diff --git a/src/platform/pic32/blueNRG.c b/src/platform/pic32/blueNRG.c index 45af47d5e..bb4cb1e89 100644 --- a/src/platform/pic32/blueNRG.c +++ b/src/platform/pic32/blueNRG.c @@ -179,8 +179,11 @@ static int16_t SPI_Write(uint8_t* data1, uint8_t* data2, uint16_t Nb_bytes1, uin SPI_SendRecieve(STBTLE_SPICHANNEL, header_master, header_slave, 5); if(header_slave[0] != 0x02){ - result = -1; - goto failed; // BlueNRG not awake. + result = -1; + // Release CS line + SPI_CS_SetHigh(STBTLE_SPICHANNEL); + + return result;// BlueNRG not awake. } rx_bytes = header_slave[1]; @@ -188,7 +191,10 @@ static int16_t SPI_Write(uint8_t* data1, uint8_t* data2, uint16_t Nb_bytes1, uin if(rx_bytes < Nb_bytes1) { result = -2; - goto failed; // underflow + // Release CS line + SPI_CS_SetHigh(STBTLE_SPICHANNEL); + + return result;// underflow. } SPI_SendRecieve(STBTLE_SPICHANNEL, data1, NULL, Nb_bytes1); diff --git a/src/platform/pic32/server_task.cpp b/src/platform/pic32/server_task.cpp index b51ca2799..c4259d779 100644 --- a/src/platform/pic32/server_task.cpp +++ b/src/platform/pic32/server_task.cpp @@ -189,7 +189,6 @@ void openxc::server_task::flushDataBuffer(TelitDevice* device) { break; case PayloadFormat::PROTOBUF: - case PayloadFormat::MESSAGEPACK: // get all bytes from the send buffer (so we have room to fill it again as we POST) byteCount = 0; diff --git a/src/platform/pic32/telit_he910.cpp b/src/platform/pic32/telit_he910.cpp index 2635deaef..33e73108b 100644 --- a/src/platform/pic32/telit_he910.cpp +++ b/src/platform/pic32/telit_he910.cpp @@ -581,11 +581,8 @@ bool openxc::telitHE910::saveSettings() { if(sendCommand(telitDevice, "AT&W0\r\n", "\r\n\r\nOK\r\n", 1000) == false) { rc = false; - goto fcn_exit; + return rc; } - - fcn_exit: - return rc; } @@ -597,11 +594,8 @@ bool openxc::telitHE910::setBaud(unsigned int baudRate) { sprintf(command, "AT+IPR=%u\r\n", baudRate); if(sendCommand(telitDevice, command, "\r\n\r\nOK\r\n", 1000) == false) { rc = false; - goto fcn_exit; + return rc; } - - fcn_exit: - return rc; } @@ -611,15 +605,12 @@ bool openxc::telitHE910::getDeviceFirmwareVersion(char* firmwareVersion) { if(sendCommand(telitDevice, "AT+CGMR\r\n", "\r\n\r\nOK\r\n", 1000) == false) { rc = false; - goto fcn_exit; + return rc; } if(getResponse("AT+CGMR\r\n\r\n", "\r\n\r\nOK\r\n", firmwareVersion, 31) == false) { rc = false; - goto fcn_exit; + return rc; } - - fcn_exit: - return rc; } @@ -630,16 +621,14 @@ bool openxc::telitHE910::getSIMStatus(unsigned int* status) { if(sendCommand(telitDevice, "AT#QSS?\r\n", "\r\n\r\nOK\r\n", 1000) == false) { rc = false; - goto fcn_exit; + return rc; } if(getResponse("#QSS: ", "\r\n\r\n", temp, 7) == false) { rc = false; - goto fcn_exit; + return rc; } *status = atoi(&temp[2]); - - fcn_exit: - return rc; + } @@ -649,15 +638,12 @@ bool openxc::telitHE910::getICCID(char* ICCID) { if(sendCommand(telitDevice, "AT#CCID\r\n", "\r\n\r\nOK\r\n", 1000) == false) { rc = false; - goto fcn_exit; + return rc; } if(getResponse("#CCID: ", "\r\n\r\n", ICCID, 31) == false) { rc = false; - goto fcn_exit; + return rc; } - - fcn_exit: - return rc; } @@ -667,15 +653,12 @@ bool openxc::telitHE910::getDeviceIMEI(char* IMEI) { if(sendCommand(telitDevice, "AT+CGSN\r\n", "\r\n\r\nOK\r\n", 2000) == false) { rc = false; - goto fcn_exit; + return rc; } if(getResponse("AT+CGSN\r\n\r\n", "\r\n\r\nOK\r\n", IMEI, 31) == false) { rc = false; - goto fcn_exit; + return rc; } - - fcn_exit: - return true; } @@ -724,12 +707,9 @@ bool openxc::telitHE910::setNetworkConnectionMode(OperatorSelectMode mode, Netwo if(sendCommand(telitDevice, command, "\r\n\r\nOK\r\n", 1000) == false) { rc = false; - goto fcn_exit; + return rc; } - fcn_exit: - return rc; - } bool openxc::telitHE910::getNetworkConnectionStatus(NetworkConnectionStatus* status) { @@ -739,16 +719,13 @@ bool openxc::telitHE910::getNetworkConnectionStatus(NetworkConnectionStatus* sta if(sendCommand(telitDevice, "AT+CREG?\r\n", "\r\n\r\nOK\r\n", 1000) == false) { rc = false; - goto fcn_exit; + return rc; } if(getResponse("+CREG: ", "\r\n\r\nOK\r\n", temp, 7) == false) { rc = false; - goto fcn_exit; + return rc; } *status = (NetworkConnectionStatus)atoi(&temp[2]); - - fcn_exit: - return rc; } @@ -762,11 +739,11 @@ bool openxc::telitHE910::getCurrentNetwork(NetworkDescriptor* network) { if(sendCommand(telitDevice, "AT+COPS?\r\n", "\r\n\r\nOK\r\n", 1000) == false) { rc = false; - goto fcn_exit; + return rc; } if(getResponse("+COPS: ", "\r\n\r\nOK\r\n", temp, 31) == false) { rc = false; - goto fcn_exit; + return rc; } if(p = strchr(temp, ','), p) { p++; @@ -779,9 +756,6 @@ bool openxc::telitHE910::getCurrentNetwork(NetworkDescriptor* network) { } } } - - fcn_exit: - return rc; } @@ -793,11 +767,8 @@ bool openxc::telitHE910::configurePDPContext(NetworkDataSettings dataSettings) { sprintf(command,"AT+CGDCONT=1,\"IP\",\"%s\"\r\n", dataSettings.APN); if(sendCommand(telitDevice, command, "\r\n\r\nOK\r\n", 1000) == false) { rc = false; - goto fcn_exit; + return rc; } - - fcn_exit: - return rc; } @@ -808,18 +779,15 @@ bool openxc::telitHE910::configureSocket(unsigned int socketNumber, SocketConnec if(socketNumber == 0 || socketNumber > 6) { rc = false; - goto fcn_exit; + return rc; } sprintf(command,"AT#SCFG=%u,1,%u,%u,%u,%u\r\n", socketNumber, socketSettings.packetSize, socketSettings.idleTimeout, socketSettings.connectTimeout, socketSettings.txFlushTimer); if(sendCommand(telitDevice, command, "\r\n\r\nOK\r\n", 1000) == false) { rc = false; - goto fcn_exit; + return rc; } - - fcn_exit: - return rc; } @@ -829,11 +797,8 @@ bool openxc::telitHE910::openPDPContext() { if(sendCommand(telitDevice, "AT#SGACT=1,1\r\n", "\r\n\r\nOK\r\n", "ERROR", 30000) == false) { rc = false; - goto fcn_exit; + return rc; } - - fcn_exit: - return rc; } @@ -843,11 +808,8 @@ bool openxc::telitHE910::closePDPContext() { if(sendCommand(telitDevice, "AT#SGACT=1,0\r\n", "\r\n\r\nOK\r\n", 1000) == false) { rc = false; - goto fcn_exit; + return rc; } - - fcn_exit: - return rc; } @@ -858,16 +820,13 @@ bool openxc::telitHE910::getPDPContext(bool* connected) { if(sendCommand(telitDevice, "AT#SGACT?\r\n", "\r\n\r\nOK\r\n", 1000) == false) { rc = false; - goto fcn_exit; + return rc; } if(getResponse("#SGACT: 1,", "\r\n\r\nOK\r\n", temp, 31) == false) { rc = false; - goto fcn_exit; + return rc; } *connected = (bool)atoi(temp); - - fcn_exit: - return rc; } @@ -879,12 +838,9 @@ bool openxc::telitHE910::openSocket(unsigned int socketNumber, ServerConnectSett sprintf(command,"AT#SD=%u,0,%u,\"%s\",255,1,1\r\n", socketNumber, serverSettings.port, serverSettings.host); if(sendCommand(telitDevice, command, "\r\n\r\nOK\r\n", "ERROR", 15000) == false) { rc = false; - goto fcn_exit; + return rc; } - fcn_exit: - return rc; - } bool openxc::telitHE910::isSocketOpen(unsigned int socketNumber) { @@ -907,12 +863,9 @@ bool openxc::telitHE910::closeSocket(unsigned int socketNumber) { sprintf(command,"AT#SH=%u\r\n", socketNumber); if(sendCommand(telitDevice, command, "\r\n\r\nOK\r\n", "ERROR", 5000) == false) { rc = false; - goto fcn_exit; + return rc; } - fcn_exit: - return rc; - } bool openxc::telitHE910::getSocketStatus(unsigned int socketNumber, SocketStatus* status) { @@ -924,16 +877,13 @@ bool openxc::telitHE910::getSocketStatus(unsigned int socketNumber, SocketStatus sprintf(command, "AT#SS=%u\r\n", socketNumber); if(sendCommand(telitDevice, command, "\r\n\r\nOK\r\n", 1000) == false) { rc = false; - goto fcn_exit; + return rc; } if(getResponse("#SS: ", "\r\n\r\nOK\r\n", temp, 7) == false) { rc = false; - goto fcn_exit; + return rc; } *status = (SocketStatus)atoi(&temp[2]); - - fcn_exit: - return rc; } @@ -965,7 +915,7 @@ bool openxc::telitHE910::writeSocket(unsigned int socketNumber, char* data, unsi sprintf(command, "AT#SSENDEXT=%u,%u\r\n", socketNumber, maxWrite); if(sendCommand(telitDevice, command, "> ", 5000) == false) { rc = false; - goto fcn_exit; + return rc; } // clear the receive buffer @@ -987,7 +937,7 @@ bool openxc::telitHE910::writeSocket(unsigned int socketNumber, char* data, unsi } if(uptimeMs() >= timer) { rc = false; - goto fcn_exit; + return rc; } } @@ -1002,15 +952,12 @@ bool openxc::telitHE910::writeSocket(unsigned int socketNumber, char* data, unsi } if(uptimeMs() >= timer) { rc = false; - goto fcn_exit; + return rc; } } // update write count *len = maxWrite; - - fcn_exit: - return rc; } @@ -1034,7 +981,7 @@ bool openxc::telitHE910::readSocket(unsigned int socketNumber, char* data, unsig sprintf(reply, "#SRECV: %u,", socketNumber); if(sendCommand(telitDevice, command, reply, 1000) == false) { rc = false; - goto fcn_exit; + return rc; } // start the receive timer @@ -1044,7 +991,7 @@ bool openxc::telitHE910::readSocket(unsigned int socketNumber, char* data, unsig pS = recv_data; if(pS = strstr(pS, reply), !pS) { rc = false; - goto fcn_exit; + return rc; } pS += 10; pRx = pS; @@ -1059,7 +1006,7 @@ bool openxc::telitHE910::readSocket(unsigned int socketNumber, char* data, unsig } if(uptimeMs() >= timer) { rc = false; - goto fcn_exit; + return rc; } } // get the read count @@ -1078,7 +1025,7 @@ bool openxc::telitHE910::readSocket(unsigned int socketNumber, char* data, unsig } if(uptimeMs() >= timer) { rc = false; - goto fcn_exit; + return rc; } } // put the read data into caller @@ -1096,13 +1043,10 @@ bool openxc::telitHE910::readSocket(unsigned int socketNumber, char* data, unsig } if(uptimeMs() >= timer) { rc = false; - goto fcn_exit; + return rc; } } - fcn_exit: - return rc; - } bool openxc::telitHE910::readSocketOne(unsigned int socketNumber, char* data, unsigned int* len) { @@ -1125,7 +1069,7 @@ bool openxc::telitHE910::readSocketOne(unsigned int socketNumber, char* data, un sprintf(reply, "#SRECV: %u,", socketNumber); if(sendCommand(telitDevice, command, reply, 1000) == false) { rc = false; - goto fcn_exit; + return rc; } // start the receive timer @@ -1135,7 +1079,7 @@ bool openxc::telitHE910::readSocketOne(unsigned int socketNumber, char* data, un pS = recv_data; if(pS = strstr(pS, reply), !pS) { rc = false; - goto fcn_exit; + return rc; } pS += 10; pRx = pS; @@ -1150,7 +1094,7 @@ bool openxc::telitHE910::readSocketOne(unsigned int socketNumber, char* data, un } if(uptimeMs() >= timer) { rc = false; - goto fcn_exit; + return rc; } } // get the read count @@ -1169,7 +1113,7 @@ bool openxc::telitHE910::readSocketOne(unsigned int socketNumber, char* data, un } if(uptimeMs() >= timer) { rc = false; - goto fcn_exit; + return rc; } } // put the read data into caller @@ -1187,13 +1131,10 @@ bool openxc::telitHE910::readSocketOne(unsigned int socketNumber, char* data, un } if(uptimeMs() >= timer) { rc = false; - goto fcn_exit; + return rc; } } - fcn_exit: - return rc; - } /*SEND/RECEIVE*/ @@ -1300,17 +1241,14 @@ static bool getResponse(const char* startToken, const char* stopToken, char* res if(p1 = strstr(recv_data, startToken), !p1) { rc = false; - goto fcn_exit; + return rc; } if(p2 = strstr(recv_data, stopToken), !p2) { rc = false; - goto fcn_exit; + return rc; } p1 += strlen(startToken); memcpy(response, p1, (maxLen < p2-p1) ? (maxLen) : (p2-p1)); - - fcn_exit: - return rc; } @@ -1371,11 +1309,8 @@ bool openxc::telitHE910::setGPSPowerState(bool enable) { sprintf(command, "AT$GPSP=%u\r\n", (unsigned int)enable); if(sendCommand(telitDevice, command, "\r\n\r\nOK\r\n", 1000) == false) { rc = false; - goto fcn_exit; + return rc; } - - fcn_exit: - return rc; } @@ -1388,16 +1323,13 @@ bool openxc::telitHE910::getGPSPowerState(bool* enable) { sprintf(command, "AT$GPSP?\r\n"); if(sendCommand(telitDevice, command, "\r\n\r\nOK\r\n", 1000) == false) { rc = false; - goto fcn_exit; + return rc; } if(getResponse("$GPSP: ", "\r\n\r\nOK\r\n", temp, 7) == false) { rc = false; - goto fcn_exit; + return rc; } *enable = (bool)atoi(&temp[0]); - - fcn_exit: - return rc; } @@ -1408,26 +1340,23 @@ bool openxc::telitHE910::getGPSLocation() { static unsigned long next_update = 0; if(uptimeMs() < next_update) { - goto fcn_exit; + return rc; } // retrieve the GPS location string from the modem if(sendCommand(telitDevice, "AT$GPSACP\r\n", "\r\n\r\nOK\r\n", 1000) == false) { rc = false; - goto fcn_exit; + return rc; } if(getResponse("$GPSACP: ", "\r\n\r\nOK\r\n", temp, 127) == false) { rc = false; - goto fcn_exit; + return rc; } // now we have the GPS string in 'temp', send to parser to publish signals rc = parseGPSACP(temp); next_update = uptimeMs() + getConfiguration()->telit->config.globalPositioningSettings.gpsInterval; - - fcn_exit: - return rc; } @@ -1479,7 +1408,7 @@ static bool parseGPSACP(const char* GPSACP) { for(i = 0; i < 10; ++i) { if(p2 = strchr(p1, ','), !p2) { rc = false; - goto fcn_exit; + return rc; } memcpy(&splitString[i][0], p1, p2-p1); validString[i] = (p2-p1 > 0) ? true : false; @@ -1560,9 +1489,6 @@ static bool parseGPSACP(const char* GPSACP) { field_value_numerical = atof(&splitString[10][0]); publishGPSSignal("gps_nsat", field_value_numerical, pipeline); } - - fcn_exit: - return rc; } /*PIPELINE*/ diff --git a/src/tests/canread_tests.cpp b/src/tests/canread_tests.cpp index 6ce8ebb50..8bd1b9627 100644 --- a/src/tests/canread_tests.cpp +++ b/src/tests/canread_tests.cpp @@ -138,7 +138,7 @@ START_TEST (test_send_numerical) uint8_t snapshot[QUEUE_LENGTH(uint8_t, OUTPUT_QUEUE) + 1]; QUEUE_SNAPSHOT(uint8_t, OUTPUT_QUEUE, snapshot, sizeof(snapshot)); snapshot[sizeof(snapshot) - 1] = NULL; - ck_assert_str_eq((char*)snapshot, "{\"timestamp\":0,\"name\":\"test\",\"value\":42}\0"); + ck_assert_str_eq((char*)snapshot, "{\"name\":\"test\",\"value\":42}\0"); } END_TEST @@ -153,7 +153,7 @@ START_TEST (test_preserve_float_precision) QUEUE_SNAPSHOT(uint8_t, OUTPUT_QUEUE, snapshot, sizeof(snapshot)); snapshot[sizeof(snapshot) - 1] = NULL; ck_assert_str_eq((char*)snapshot, - "{\"timestamp\":0,\"name\":\"test\",\"value\":42.500000}\0"); + "{\"name\":\"test\",\"value\":42.500000}\0"); } END_TEST @@ -167,7 +167,7 @@ START_TEST (test_send_boolean) QUEUE_SNAPSHOT(uint8_t, OUTPUT_QUEUE, snapshot, sizeof(snapshot)); snapshot[sizeof(snapshot) - 1] = NULL; ck_assert_str_eq((char*)snapshot, - "{\"timestamp\":0,\"name\":\"test\",\"value\":false}\0"); + "{\"name\":\"test\",\"value\":false}\0"); } END_TEST @@ -181,7 +181,7 @@ START_TEST (test_send_string) QUEUE_SNAPSHOT(uint8_t, OUTPUT_QUEUE, snapshot, sizeof(snapshot)); snapshot[sizeof(snapshot) - 1] = NULL; ck_assert_str_eq((char*)snapshot, - "{\"timestamp\":0,\"name\":\"test\",\"value\":\"string\"}\0"); + "{\"name\":\"test\",\"value\":\"string\"}\0"); } END_TEST @@ -204,7 +204,7 @@ START_TEST (test_send_evented_boolean) QUEUE_SNAPSHOT(uint8_t, OUTPUT_QUEUE, snapshot, sizeof(snapshot)); snapshot[sizeof(snapshot) - 1] = NULL; ck_assert_str_eq((char*)snapshot, - "{\"timestamp\":0,\"name\":\"test\",\"value\":\"value\",\"event\":false}\0"); + "{\"name\":\"test\",\"value\":\"value\",\"event\":false}\0"); } END_TEST @@ -227,7 +227,7 @@ START_TEST (test_send_evented_string) QUEUE_SNAPSHOT(uint8_t, OUTPUT_QUEUE, snapshot, sizeof(snapshot)); snapshot[sizeof(snapshot) - 1] = NULL; ck_assert_str_eq((char*)snapshot, - "{\"timestamp\":0,\"name\":\"test\",\"value\":\"value\",\"event\":\"event\"}\0"); + "{\"name\":\"test\",\"value\":\"value\",\"event\":\"event\"}\0"); } END_TEST @@ -249,7 +249,7 @@ START_TEST (test_send_evented_float) QUEUE_SNAPSHOT(uint8_t, OUTPUT_QUEUE, snapshot, sizeof(snapshot)); snapshot[sizeof(snapshot) - 1] = NULL; ck_assert_str_eq((char*)snapshot, - "{\"timestamp\":0,\"name\":\"test\",\"value\":\"value\",\"event\":43}\0"); + "{\"name\":\"test\",\"value\":\"value\",\"event\":43}\0"); } END_TEST @@ -315,7 +315,7 @@ START_TEST (test_passthrough_message) QUEUE_SNAPSHOT(uint8_t, OUTPUT_QUEUE, snapshot, sizeof(snapshot)); snapshot[sizeof(snapshot) - 1] = NULL; ck_assert_str_eq((char*)snapshot, - "{\"timestamp\":0,\"bus\":1,\"id\":42,\"data\":\"0x123456789abcdef1\"}\0"); + "{\"bus\":1,\"id\":42,\"data\":\"0x123456789abcdef1\"}\0"); } END_TEST @@ -354,7 +354,7 @@ START_TEST (test_default_decoder) QUEUE_SNAPSHOT(uint8_t, OUTPUT_QUEUE, snapshot, sizeof(snapshot)); snapshot[sizeof(snapshot) - 1] = NULL; ck_assert_str_eq((char*)snapshot, - "{\"timestamp\":0,\"name\":\"torque_at_transmission\",\"value\":-19990}\0"); + "{\"name\":\"torque_at_transmission\",\"value\":-19990}\0"); } END_TEST @@ -383,12 +383,11 @@ START_TEST (test_translate_many_signals) } fail_unless(USB_PROCESSED); // 8 signals sent - depends on queue size - //ck_assert_int_eq(11 * 34 + 2, SENT_BYTES); // Protobuff 2 result - ck_assert_int_eq(676, SENT_BYTES); + ck_assert_int_eq(11 * 34 + 2, SENT_BYTES); // 1 in the output queue fail_if(queueEmpty()); //ck_assert_int_eq(1 * 34, QUEUE_LENGTH(uint8_t, OUTPUT_QUEUE)); // Protobuff 2 result - ck_assert_int_eq(96, QUEUE_LENGTH(uint8_t, OUTPUT_QUEUE)); + ck_assert_int_eq(170, QUEUE_LENGTH(uint8_t, OUTPUT_QUEUE)); } END_TEST @@ -406,7 +405,7 @@ START_TEST (test_translate_float) QUEUE_SNAPSHOT(uint8_t, OUTPUT_QUEUE, snapshot, sizeof(snapshot)); snapshot[sizeof(snapshot) - 1] = NULL; ck_assert_str_eq((char*)snapshot, - "{\"timestamp\":0,\"name\":\"torque_at_transmission\",\"value\":42}\0"); + "{\"name\":\"torque_at_transmission\",\"value\":42}\0"); } END_TEST @@ -465,7 +464,7 @@ START_TEST (test_translate_string) QUEUE_SNAPSHOT(uint8_t, OUTPUT_QUEUE, snapshot, sizeof(snapshot)); snapshot[sizeof(snapshot) - 1] = NULL; ck_assert_str_eq((char*)snapshot, - "{\"timestamp\":0,\"name\":\"torque_at_transmission\",\"value\":\"foo\"}\0"); + "{\"name\":\"torque_at_transmission\",\"value\":\"foo\"}\0"); } END_TEST @@ -549,7 +548,7 @@ START_TEST (test_preserve_last_value) QUEUE_SNAPSHOT(uint8_t, OUTPUT_QUEUE, snapshot, sizeof(snapshot)); snapshot[sizeof(snapshot) - 1] = NULL; ck_assert_str_eq((char*)snapshot, - "{\"timestamp\":0,\"name\":\"torque_at_transmission\",\"value\":-19990}\0"); + "{\"name\":\"torque_at_transmission\",\"value\":-19990}\0"); } END_TEST @@ -566,7 +565,7 @@ START_TEST (test_dont_send_same) QUEUE_SNAPSHOT(uint8_t, OUTPUT_QUEUE, snapshot, sizeof(snapshot)); snapshot[sizeof(snapshot) - 1] = NULL; ck_assert_str_eq((char*)snapshot, - "{\"timestamp\":0,\"name\":\"brake_pedal_status\",\"value\":true}\0"); + "{\"name\":\"brake_pedal_status\",\"value\":true}\0"); QUEUE_INIT(uint8_t, OUTPUT_QUEUE); can::read::translateSignal(testSignal, diff --git a/src/tests/diagnostics_tests.cpp b/src/tests/diagnostics_tests.cpp index 8c33f556a..20d7cf994 100644 --- a/src/tests/diagnostics_tests.cpp +++ b/src/tests/diagnostics_tests.cpp @@ -282,7 +282,7 @@ START_TEST (test_add_basic_request) uint8_t snapshot[QUEUE_LENGTH(uint8_t, OUTPUT_QUEUE) + 1]; QUEUE_SNAPSHOT(uint8_t, OUTPUT_QUEUE, snapshot, sizeof(snapshot)); snapshot[sizeof(snapshot) - 1] = NULL; - ck_assert_str_eq((char*)snapshot, "{\"timestamp\":0,\"bus\":1,\"id\":2016,\"mode\":1,\"success\":true,\"pid\":2,\"payload\":\"0x45\"}\0"); + ck_assert_str_eq((char*)snapshot, "{\"bus\":1,\"id\":2016,\"mode\":1,\"success\":true,\"pid\":2,\"payload\":\"0x45\"}\0"); } END_TEST @@ -374,7 +374,7 @@ START_TEST (test_add_request_other_bus) uint8_t snapshot[QUEUE_LENGTH(uint8_t, OUTPUT_QUEUE) + 1]; QUEUE_SNAPSHOT(uint8_t, OUTPUT_QUEUE, snapshot, sizeof(snapshot)); snapshot[sizeof(snapshot) - 1] = NULL; - ck_assert_str_eq((char*)snapshot, "{\"timestamp\":0,\"name\":\"mypid\",\"value\":69}\0"); + ck_assert_str_eq((char*)snapshot, "{\"name\":\"mypid\",\"value\":69}\0"); } END_TEST @@ -391,7 +391,7 @@ START_TEST (test_add_request_with_name) uint8_t snapshot[QUEUE_LENGTH(uint8_t, OUTPUT_QUEUE) + 1]; QUEUE_SNAPSHOT(uint8_t, OUTPUT_QUEUE, snapshot, sizeof(snapshot)); snapshot[sizeof(snapshot) - 1] = NULL; - ck_assert_str_eq((char*)snapshot, "{\"timestamp\":0,\"name\":\"mypid\",\"value\":69}\0"); + ck_assert_str_eq((char*)snapshot, "{\"name\":\"mypid\",\"value\":69}\0"); } END_TEST @@ -466,7 +466,7 @@ START_TEST (test_add_request_with_name_and_decoder) uint8_t snapshot[QUEUE_LENGTH(uint8_t, OUTPUT_QUEUE) + 1]; QUEUE_SNAPSHOT(uint8_t, OUTPUT_QUEUE, snapshot, sizeof(snapshot)); snapshot[sizeof(snapshot) - 1] = NULL; - ck_assert_str_eq((char*)snapshot, "{\"timestamp\":0,\"name\":\"mypid\",\"value\":138}\0"); + ck_assert_str_eq((char*)snapshot, "{\"name\":\"mypid\",\"value\":138}\0"); } END_TEST diff --git a/src/tests/messagepack_payload_tests.cpp b/src/tests/messagepack_payload_tests.cpp deleted file mode 100644 index 1aff7022e..000000000 --- a/src/tests/messagepack_payload_tests.cpp +++ /dev/null @@ -1,187 +0,0 @@ -#include -#include -#include - -#include "commands/commands.h" -#include "payload/messagepack.h" - -namespace messagepack = openxc::payload::messagepack; - -using openxc::commands::validate; - -void setup() { -} - -START_TEST (test_passthrough_request) -{ - openxc_VehicleMessage message = openxc_VehicleMessage(); // Zero Fill - message.type = openxc_VehicleMessage_Type_COMMAND_RESPONSE; - message.command_response.type = openxc_ControlCommand_Type_PASSTHROUGH; - message.command_response.status = true; - uint8_t payload[256] = {0}; - ck_assert(messagepack::serialize(&message, payload, sizeof(payload)) > 0); -} -END_TEST - -START_TEST (test_passthrough_response) -{ - openxc_VehicleMessage message = openxc_VehicleMessage(); // Zero Fill - message.type = openxc_VehicleMessage_Type_COMMAND_RESPONSE; - message.command_response.type = openxc_ControlCommand_Type_PASSTHROUGH; - message.command_response.status = true; - uint8_t payload[256] = {0}; - ck_assert(messagepack::serialize(&message, payload, sizeof(payload)) > 0); -} -END_TEST - - -START_TEST (test_af_bypass_response) -{ - openxc_VehicleMessage message = openxc_VehicleMessage(); // Zero Fill - message.type = openxc_VehicleMessage_Type_COMMAND_RESPONSE; - message.command_response.type = openxc_ControlCommand_Type_ACCEPTANCE_FILTER_BYPASS; - message.command_response.status = true; - uint8_t payload[256] = {0}; - ck_assert(messagepack::serialize(&message, payload, sizeof(payload)) > 0); -} -END_TEST - -START_TEST (test_af_bypass_request) -{ - openxc_VehicleMessage message = openxc_VehicleMessage(); // Zero Fill - message.type = openxc_VehicleMessage_Type_CONTROL_COMMAND; - message.control_command.type = openxc_ControlCommand_Type_ACCEPTANCE_FILTER_BYPASS; - message.control_command.acceptance_filter_bypass_command.bus = 1; - message.control_command.acceptance_filter_bypass_command.bypass = true; - uint8_t payload[256] = {0}; - ck_assert(messagepack::serialize(&message, payload, sizeof(payload)) > 0); -} -END_TEST - -START_TEST (test_payload_format_response) -{ - openxc_VehicleMessage message = openxc_VehicleMessage(); // Zero Fill - message.type = openxc_VehicleMessage_Type_COMMAND_RESPONSE; - message.command_response.type = openxc_ControlCommand_Type_PAYLOAD_FORMAT; - message.command_response.status = true; - uint8_t payload[256] = {0}; - ck_assert(messagepack::serialize(&message, payload, sizeof(payload)) > 0); -} -END_TEST - -START_TEST (test_payload_format_request) -{ - openxc_VehicleMessage message = openxc_VehicleMessage(); // Zero Fill - message.type = openxc_VehicleMessage_Type_CONTROL_COMMAND; - message.control_command.type = openxc_ControlCommand_Type_PAYLOAD_FORMAT; - message.control_command.payload_format_command.format = openxc_PayloadFormatCommand_PayloadFormat_MESSAGEPACK; - uint8_t payload[256] = {0}; - ck_assert(messagepack::serialize(&message, payload, sizeof(payload)) > 0); - message.control_command.payload_format_command.format = openxc_PayloadFormatCommand_PayloadFormat_MESSAGEPACK; - ck_assert(messagepack::serialize(&message, payload, sizeof(payload)) > 0); -} -END_TEST - -START_TEST (test_predefined_obd2_requests_response) -{ - openxc_VehicleMessage message = openxc_VehicleMessage(); // Zero Fill - message.type = openxc_VehicleMessage_Type_COMMAND_RESPONSE; - message.command_response.type = openxc_ControlCommand_Type_PREDEFINED_OBD2_REQUESTS; - message.command_response.status = true; - uint8_t payload[256] = {0}; - ck_assert(messagepack::serialize(&message, payload, sizeof(payload)) > 0); -} -END_TEST - -START_TEST (test_predefined_obd2_requests_request) -{ - openxc_VehicleMessage message = openxc_VehicleMessage(); // Zero Fill - message.type = openxc_VehicleMessage_Type_CONTROL_COMMAND; - message.control_command.type = openxc_ControlCommand_Type_PREDEFINED_OBD2_REQUESTS; - message.control_command.predefined_obd2_requests_command.enabled = true; - uint8_t payload[256] = {0}; - ck_assert(messagepack::serialize(&message, payload, sizeof(payload)) > 0); -} -END_TEST - -START_TEST (test_deserialize_can_message_write) -{ - //{"bus": 1,"id": 42,"data":"0x1234"}; - uint8_t rawRequest[21] = { - 0x83, 0xA3, 0x62, 0x75, 0x73, 0xCC, 0x01, 0xA2, - 0x69, 0x64, 0xCC, 0x2A, 0xA4, 0x64, 0x61, 0x74, - 0x61, 0xC4, 0x02, 0x12, 0x34 - }; - openxc_VehicleMessage deserialized = openxc_VehicleMessage(); // Zero Fill - messagepack::deserialize(rawRequest, sizeof(rawRequest), &deserialized); - ck_assert(validate(&deserialized)); -} -END_TEST - -START_TEST (test_deserialize_can_message_write_with_format) -{ - //{"bus": 1,"id": 42,"data":"0x1234","frame_format":"standard"} - uint8_t rawRequest[43] = { - 0x84, 0xA3, 0x62, 0x75, 0x73, 0xCC, 0x01, 0xA2, - 0x69, 0x64, 0xCC, 0x2A, 0xA4, 0x64, 0x61, 0x74, - 0x61, 0xC4, 0x02, 0x12, 0x34, 0xAC, 0x66, 0x72, - 0x61, 0x6D, 0x65, 0x5F, 0x66, 0x6F, 0x72, 0x6D, - 0x61, 0x74, 0xA8, 0x73, 0x74, 0x61, 0x6E, 0x64, - 0x61, 0x72, 0x64 - }; - openxc_VehicleMessage deserialized = openxc_VehicleMessage(); // Zero Fill - messagepack::deserialize(rawRequest, sizeof(rawRequest), &deserialized); - ck_assert(validate(&deserialized)); - ck_assert_int_eq(openxc_CanMessage_FrameFormat_STANDARD, - deserialized.can_message.frame_format); -} -END_TEST - -START_TEST (test_deserialize_message_after_junk) -{ - - //garbagebytes..{"bus": 1,"id": 42,"data":"0x1234"} - uint8_t rawRequest[25] = { - 0x01, 0x02, 0x03, 0x04, 0x83, 0xA3, 0x62, 0x75, 0x73, 0xCC, 0x01, 0xA2, - 0x69, 0x64, 0xCC, 0x2A, 0xA4, 0x64, 0x61, 0x74, - 0x61, 0xC4, 0x02, 0x12, 0x34 - }; - //Message pack payload format will just read the junk bytes ahead of the message and ignore it - openxc_VehicleMessage deserialized = openxc_VehicleMessage(); // Zero Fill - ck_assert_int_eq(25, messagepack::deserialize(rawRequest, sizeof(rawRequest), &deserialized)); - ck_assert(validate(&deserialized)); -} -END_TEST - - -Suite* suite(void) { - Suite* s = suite_create("messagepack_payload"); - TCase *tc_msgpck_payload = tcase_create("messagepack_payload"); - tcase_add_checked_fixture(tc_msgpck_payload, setup, NULL); - tcase_add_test(tc_msgpck_payload, test_passthrough_request); - tcase_add_test(tc_msgpck_payload, test_passthrough_response); - tcase_add_test(tc_msgpck_payload, test_af_bypass_response); - tcase_add_test(tc_msgpck_payload, test_af_bypass_request); - tcase_add_test(tc_msgpck_payload, test_payload_format_response); - tcase_add_test(tc_msgpck_payload, test_payload_format_request); - tcase_add_test(tc_msgpck_payload, test_predefined_obd2_requests_response); - tcase_add_test(tc_msgpck_payload, test_predefined_obd2_requests_request); - tcase_add_test(tc_msgpck_payload, test_deserialize_can_message_write); - tcase_add_test(tc_msgpck_payload, test_deserialize_can_message_write_with_format); - tcase_add_test(tc_msgpck_payload, test_deserialize_message_after_junk); - suite_add_tcase(s, tc_msgpck_payload); - return s; -} - -int main(void) { - - int numberFailed; - Suite* s = suite(); - SRunner *sr = srunner_create(s); - // Don't fork so we can actually use gdb - srunner_set_fork_status(sr, CK_NOFORK); - srunner_run_all(sr, CK_NORMAL); - numberFailed = srunner_ntests_failed(sr); - srunner_free(sr); - return (numberFailed == 0) ? 0 : 1; -} diff --git a/src/tests/tests.mk b/src/tests/tests.mk index aa2ab99d7..4d7a0f56a 100644 --- a/src/tests/tests.mk +++ b/src/tests/tests.mk @@ -65,7 +65,6 @@ test_long: test_short @make usb_raw_write_compile_test @make bluetooth_raw_write_compile_test @make binary_output_compile_test - @make messagepack_output_compile_test @make emulator_compile_test @make msd_emulator_compile_test @make stats_compile_test @@ -139,7 +138,6 @@ $(eval $(call ALL_PLATFORMS_TEST_TEMPLATE, debug_stats_compile_test, DEBUG=1 DEF $(eval $(call ALL_PLATFORMS_TEST_TEMPLATE, usb_raw_write_compile_test, DEBUG=0 DEFAULT_ALLOW_RAW_WRITE_USB=0, code_generation_test)) $(eval $(call ALL_PLATFORMS_TEST_TEMPLATE, bluetooth_raw_write_compile_test, DEBUG=0 DEFAULT_ALLOW_RAW_WRITE_UART=1, code_generation_test)) $(eval $(call ALL_PLATFORMS_TEST_TEMPLATE, binary_output_compile_test, DEBUG=0 DEFAULT_OUTPUT_FORMAT=PROTOBUF, code_generation_test)) -$(eval $(call ALL_PLATFORMS_TEST_TEMPLATE, messagepack_output_compile_test, DEBUG=0 DEFAULT_OUTPUT_FORMAT=MESSAGEPACK, code_generation_test)) copy_passthrough_signals: @echo "Testing example passthrough config in repo for FORDBOARD..."