diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2019-11-26 16:19:35 +0100 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2019-11-28 16:11:47 +0100 |
commit | fee3b49099fb39731e15f9e26ad5a873bc109f59 (patch) | |
tree | f925b8b2a744d9e94cedbd460e47ba533717c36c | |
parent | a8d5f5d3018da0b051dad4c143c6257b2fba9fac (diff) |
Replace all enum types with masks
This commit allows to change all enum types by masks.
Now to implement new protocol you don't need to add
more attribute in class. All can be contained in
the flags field.
Bug-AGL : SPEC-2779
Bug-AGL: SPEC-2976
Change-Id: I814d0052139be5d5efefc9ff1b4b558f46b85e90
Signed-off-by: Arthur Guyader <arthur.guyader@iot.bzh>
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
20 files changed, 1315 insertions, 354 deletions
diff --git a/examples/agl-vcar/application-generated.cpp b/examples/agl-vcar/application-generated.cpp index 35d847b7..bfe3d861 100644 --- a/examples/agl-vcar/application-generated.cpp +++ b/examples/agl-vcar/application-generated.cpp @@ -7,7 +7,7 @@ application_t::application_t() , message_set_{ {std::make_shared<message_set_t>(message_set_t{0,"AGL Virtual Car", { // beginning message_definition_ vector - {std::make_shared<message_definition_t>(message_definition_t{"ls",0x30,"",0,false,message_format_t::EXTENDED,frequency_clock_t(5.00000f),true, + {std::make_shared<message_definition_t>(message_definition_t{"ls",0x30,"",8,4,frequency_clock_t(5.00000f),true, { // beginning signals vector {std::make_shared<signal_t> (signal_t{ "hvac.fan.speed",// generic_name @@ -22,7 +22,7 @@ application_t::application_t() false,// force_send_changed { },// states - false,// writable + true,// writable nullptr,// decoder nullptr,// encoder false,// received @@ -99,7 +99,7 @@ application_t::application_t() })} } // end signals vector })} // end message_definition entry -, {std::make_shared<message_definition_t>(message_definition_t{"hs",0x3D9,"",0,true,message_format_t::STANDARD,frequency_clock_t(5.00000f),true, +, {std::make_shared<message_definition_t>(message_definition_t{"hs",0x3D9,"",8,2050,frequency_clock_t(5.00000f),true, { // beginning signals vector {std::make_shared<signal_t> (signal_t{ "engine.speed",// generic_name @@ -114,7 +114,7 @@ application_t::application_t() false,// force_send_changed { },// states - false,// writable + true,// writable nullptr,// decoder nullptr,// encoder false,// received @@ -136,7 +136,7 @@ application_t::application_t() false,// force_send_changed { },// states - false,// writable + true,// writable decoder_t::decode_boolean,// decoder nullptr,// encoder false,// received @@ -158,7 +158,7 @@ application_t::application_t() false,// force_send_changed { },// states - false,// writable + true,// writable nullptr,// decoder nullptr,// encoder false,// received @@ -169,7 +169,7 @@ application_t::application_t() })} } // end signals vector })} // end message_definition entry -, {std::make_shared<message_definition_t>(message_definition_t{"hs",0x3E9,"",0,false,message_format_t::STANDARD,frequency_clock_t(5.00000f),true, +, {std::make_shared<message_definition_t>(message_definition_t{"hs",0x3E9,"",8,2,frequency_clock_t(5.00000f),true, { // beginning signals vector {std::make_shared<signal_t> (signal_t{ "vehicle.average.speed",// generic_name @@ -195,7 +195,7 @@ application_t::application_t() })} } // end signals vector })} // end message_definition entry -, {std::make_shared<message_definition_t>(message_definition_t{"hs",0x4D1,"",0,false,message_format_t::STANDARD,frequency_clock_t(5.00000f),true, +, {std::make_shared<message_definition_t>(message_definition_t{"hs",0x4D1,"",8,2,frequency_clock_t(5.00000f),true, { // beginning signals vector {std::make_shared<signal_t> (signal_t{ "engine.oil.temp",// generic_name @@ -210,7 +210,7 @@ application_t::application_t() false,// force_send_changed { },// states - false,// writable + true,// writable nullptr,// decoder nullptr,// encoder false,// received @@ -232,7 +232,7 @@ application_t::application_t() false,// force_send_changed { },// states - false,// writable + true,// writable decoder_t::decode_boolean,// decoder nullptr,// encoder false,// received @@ -243,7 +243,7 @@ application_t::application_t() })} } // end signals vector })} // end message_definition entry -, {std::make_shared<message_definition_t>(message_definition_t{"hs",0x620,"",0,false,message_format_t::STANDARD,frequency_clock_t(5.00000f),true, +, {std::make_shared<message_definition_t>(message_definition_t{"hs",0x620,"",8,2,frequency_clock_t(5.00000f),true, { // beginning signals vector {std::make_shared<signal_t> (signal_t{ "doors.boot.open",// generic_name @@ -258,7 +258,7 @@ application_t::application_t() false,// force_send_changed { },// states - false,// writable + true,// writable decoder_t::decode_boolean,// decoder nullptr,// encoder false,// received @@ -280,7 +280,7 @@ application_t::application_t() false,// force_send_changed { },// states - false,// writable + true,// writable decoder_t::decode_boolean,// decoder nullptr,// encoder false,// received @@ -302,7 +302,7 @@ application_t::application_t() false,// force_send_changed { },// states - false,// writable + true,// writable decoder_t::decode_boolean,// decoder nullptr,// encoder false,// received @@ -324,7 +324,7 @@ application_t::application_t() false,// force_send_changed { },// states - false,// writable + true,// writable decoder_t::decode_boolean,// decoder nullptr,// encoder false,// received @@ -346,7 +346,7 @@ application_t::application_t() false,// force_send_changed { },// states - false,// writable + true,// writable decoder_t::decode_boolean,// decoder nullptr,// encoder false,// received @@ -357,7 +357,7 @@ application_t::application_t() })} } // end signals vector })} // end message_definition entry -, {std::make_shared<message_definition_t>(message_definition_t{"hs",0x799,"",0,false,message_format_t::STANDARD,frequency_clock_t(5.00000f),true, +, {std::make_shared<message_definition_t>(message_definition_t{"hs",0x799,"",8,2,frequency_clock_t(5.00000f),true, { // beginning signals vector {std::make_shared<signal_t> (signal_t{ "windows.front_left.open",// generic_name @@ -372,7 +372,7 @@ application_t::application_t() false,// force_send_changed { },// states - false,// writable + true,// writable decoder_t::decode_boolean,// decoder nullptr,// encoder false,// received @@ -394,7 +394,7 @@ application_t::application_t() false,// force_send_changed { },// states - false,// writable + true,// writable decoder_t::decode_boolean,// decoder nullptr,// encoder false,// received @@ -416,7 +416,7 @@ application_t::application_t() false,// force_send_changed { },// states - false,// writable + true,// writable decoder_t::decode_boolean,// decoder nullptr,// encoder false,// received @@ -438,7 +438,7 @@ application_t::application_t() false,// force_send_changed { },// states - false,// writable + true,// writable decoder_t::decode_boolean,// decoder nullptr,// encoder false,// received diff --git a/examples/agl-vcar/signals.json b/examples/agl-vcar/signals.json index 679ab68e..ecf635ca 100644 --- a/examples/agl-vcar/signals.json +++ b/examples/agl-vcar/signals.json @@ -10,6 +10,7 @@ "is_fd" : false, "is_extended": false, "is_j1939" : false, + "length" : 8, "signals": { "doors.driver.open": { "generic_name": "doors.front_left.open", @@ -17,6 +18,7 @@ "bit_size": 1, "factor": 1.0, "offset": 0, + "writable": true, "decoder": "decoder_t::decode_boolean"}, "doors.passenger.open": { "generic_name": "doors.front_right.open", @@ -24,6 +26,7 @@ "bit_size": 1, "factor": 1.0, "offset": 0, + "writable": true, "decoder": "decoder_t::decode_boolean"}, "doors.rearleft.open": { "generic_name": "doors.rear_left.open", @@ -31,6 +34,7 @@ "bit_size": 1, "factor": 1.0, "offset": 0, + "writable": true, "decoder": "decoder_t::decode_boolean"}, "doors.rearright.open": { "generic_name": "doors.rear_right.open", @@ -38,6 +42,7 @@ "bit_size": 4, "factor": 1.0, "offset": 0, + "writable": true, "decoder": "decoder_t::decode_boolean"}, "doors.coffer.open": { "generic_name": "doors.boot.open", @@ -45,6 +50,7 @@ "bit_size": 1, "factor": 1.0, "offset": 0, + "writable": true, "decoder": "decoder_t::decode_boolean"} } }, @@ -53,6 +59,7 @@ "is_fd" : false, "is_extended": false, "is_j1939" : false, + "length" : 8, "signals": { "windows.driver.open": { "generic_name": "windows.front_left.open", @@ -60,6 +67,7 @@ "bit_size": 1, "factor": 1.0, "offset": 0, + "writable": true, "decoder": "decoder_t::decode_boolean"}, "windows.passenger.open": { "generic_name": "windows.front_right.open", @@ -67,6 +75,7 @@ "bit_size": 1, "factor": 1.0, "offset": 0, + "writable": true, "decoder": "decoder_t::decode_boolean"}, "windows.rearleft.open": { "generic_name": "windows.rear_left.open", @@ -74,6 +83,7 @@ "bit_size": 1, "factor": 1.0, "offset": 0, + "writable": true, "decoder": "decoder_t::decode_boolean"}, "windows.rearright.open": { "generic_name": "windows.rear_right.open", @@ -81,6 +91,7 @@ "bit_size": 4, "factor": 1.0, "offset": 0, + "writable": true, "decoder": "decoder_t::decode_boolean"} } }, @@ -89,20 +100,23 @@ "is_fd" : true, "is_extended": false, "is_j1939" : false, + "length" : 8, "signals": { "PT_FuelLevelPct": { "generic_name": "fuel.level", "bit_position": 8, "bit_size": 8, "factor": 0.392157, - "offset": 0 + "offset": 0, + "writable": true }, "PT_EngineSpeed": { "generic_name": "engine.speed", "bit_position": 16, "bit_size": 16, "factor": 0.25, - "offset": 0 + "offset": 0, + "writable": true }, "PT_FuelLevelLow": { "generic_name": "fuel.level.low", @@ -110,6 +124,7 @@ "bit_size": 1, "factor": 1, "offset": 0, + "writable": true, "decoder": "decoder_t::decode_boolean" } } @@ -119,6 +134,7 @@ "is_fd" : false, "is_extended": false, "is_j1939" : false, + "length" : 8, "signals": { "PT_EngineOilTempHigh": { "generic_name": "engine.oil.temp.high", @@ -126,6 +142,7 @@ "bit_size": 1, "factor": 1, "offset": 0, + "writable": true, "decoder": "decoder_t::decode_boolean" }, "PT_EngineOilTemp": { @@ -133,7 +150,8 @@ "bit_position": 16, "bit_size": 8, "factor": 1, - "offset": 0 + "offset": 0, + "writable": true } } }, @@ -142,13 +160,15 @@ "is_fd" : false, "is_extended": false, "is_j1939" : false, + "length" : 8, "signals": { "PT_VehicleAvgSpeed": { "generic_name": "vehicle.average.speed", "bit_position": 0, "bit_size": 15, "factor": 0.015625, - "offset": 0 + "offset": 0, + "writable": false } } }, @@ -157,6 +177,7 @@ "is_fd" : false, "is_extended": true, "is_j1939" : false, + "length" : 8, "signals": { "LeftTemperature": { "generic_name": "hvac.temperature.left", @@ -187,7 +208,8 @@ "bit_position": 32, "bit_size": 8, "factor": 23.529411765, - "offset": 0 + "offset": 0, + "writable": true } } } diff --git a/examples/tests/application-generated.cpp b/examples/tests/application-generated.cpp index 6abb4851..06ee30e4 100644 --- a/examples/tests/application-generated.cpp +++ b/examples/tests/application-generated.cpp @@ -7,7 +7,8 @@ application_t::application_t() , message_set_{ {std::make_shared<message_set_t>(message_set_t{0,"AGL Virtual Car", { // beginning message_definition_ vector - {std::make_shared<message_definition_t>(message_definition_t{"ls",0x30,"",0,false,message_format_t::EXTENDED,frequency_clock_t(5.00000f),true, { // beginning signals vector + {std::make_shared<message_definition_t>(message_definition_t{"ls",0x30,"",8,4,frequency_clock_t(5.00000f),true, + { // beginning signals vector {std::make_shared<signal_t> (signal_t{ "hvac.fan.speed",// generic_name 32,// bit_position @@ -21,14 +22,14 @@ application_t::application_t() false,// force_send_changed { },// states - false,// writable + true,// writable nullptr,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "",// unit + ""// unit })}, {std::make_shared<signal_t> (signal_t{ "hvac.temperature.left",// generic_name @@ -47,10 +48,10 @@ application_t::application_t() nullptr,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "",// unit + ""// unit })}, {std::make_shared<signal_t> (signal_t{ "hvac.temperature.right",// generic_name @@ -69,10 +70,10 @@ application_t::application_t() nullptr,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "",// unit + ""// unit })}, {std::make_shared<signal_t> (signal_t{ "hvac.temperature.average",// generic_name @@ -91,14 +92,15 @@ application_t::application_t() nullptr,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "",// unit + ""// unit })} } // end signals vector })} // end message_definition entry -, {std::make_shared<message_definition_t>(message_definition_t{"hs",0x3D9,"",0,true,message_format_t::STANDARD,frequency_clock_t(5.00000f),true, { // beginning signals vector +, {std::make_shared<message_definition_t>(message_definition_t{"hs",0x3D9,"",8,2050,frequency_clock_t(5.00000f),true, + { // beginning signals vector {std::make_shared<signal_t> (signal_t{ "engine.speed",// generic_name 16,// bit_position @@ -112,14 +114,14 @@ application_t::application_t() false,// force_send_changed { },// states - false,// writable + true,// writable nullptr,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "",// unit + ""// unit })}, {std::make_shared<signal_t> (signal_t{ "fuel.level.low",// generic_name @@ -134,14 +136,14 @@ application_t::application_t() false,// force_send_changed { },// states - false,// writable + true,// writable decoder_t::decode_boolean,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "",// unit + ""// unit })}, {std::make_shared<signal_t> (signal_t{ "fuel.level",// generic_name @@ -156,18 +158,19 @@ application_t::application_t() false,// force_send_changed { },// states - false,// writable + true,// writable nullptr,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "",// unit + ""// unit })} } // end signals vector })} // end message_definition entry -, {std::make_shared<message_definition_t>(message_definition_t{"hs",0x3E9,"",0,false,message_format_t::STANDARD,frequency_clock_t(5.00000f),true, { // beginning signals vector +, {std::make_shared<message_definition_t>(message_definition_t{"hs",0x3E9,"",8,2,frequency_clock_t(5.00000f),true, + { // beginning signals vector {std::make_shared<signal_t> (signal_t{ "vehicle.average.speed",// generic_name 0,// bit_position @@ -185,14 +188,15 @@ application_t::application_t() nullptr,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "",// unit + ""// unit })} } // end signals vector })} // end message_definition entry -, {std::make_shared<message_definition_t>(message_definition_t{"hs",0x4D1,"",0,false,message_format_t::STANDARD,frequency_clock_t(5.00000f),true, { // beginning signals vector +, {std::make_shared<message_definition_t>(message_definition_t{"hs",0x4D1,"",8,2,frequency_clock_t(5.00000f),true, + { // beginning signals vector {std::make_shared<signal_t> (signal_t{ "engine.oil.temp",// generic_name 16,// bit_position @@ -206,14 +210,14 @@ application_t::application_t() false,// force_send_changed { },// states - false,// writable + true,// writable nullptr,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "",// unit + ""// unit })}, {std::make_shared<signal_t> (signal_t{ "engine.oil.temp.high",// generic_name @@ -228,18 +232,19 @@ application_t::application_t() false,// force_send_changed { },// states - false,// writable + true,// writable decoder_t::decode_boolean,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "",// unit + ""// unit })} } // end signals vector })} // end message_definition entry -, {std::make_shared<message_definition_t>(message_definition_t{"hs",0x620,"",0,false,message_format_t::STANDARD,frequency_clock_t(5.00000f),true, { // beginning signals vector +, {std::make_shared<message_definition_t>(message_definition_t{"hs",0x620,"",8,2,frequency_clock_t(5.00000f),true, + { // beginning signals vector {std::make_shared<signal_t> (signal_t{ "doors.boot.open",// generic_name 47,// bit_position @@ -253,14 +258,14 @@ application_t::application_t() false,// force_send_changed { },// states - false,// writable + true,// writable decoder_t::decode_boolean,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "",// unit + ""// unit })}, {std::make_shared<signal_t> (signal_t{ "doors.front_left.open",// generic_name @@ -275,14 +280,14 @@ application_t::application_t() false,// force_send_changed { },// states - false,// writable + true,// writable decoder_t::decode_boolean,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "",// unit + ""// unit })}, {std::make_shared<signal_t> (signal_t{ "doors.front_right.open",// generic_name @@ -297,14 +302,14 @@ application_t::application_t() false,// force_send_changed { },// states - false,// writable + true,// writable decoder_t::decode_boolean,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "",// unit + ""// unit })}, {std::make_shared<signal_t> (signal_t{ "doors.rear_left.open",// generic_name @@ -319,14 +324,14 @@ application_t::application_t() false,// force_send_changed { },// states - false,// writable + true,// writable decoder_t::decode_boolean,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "",// unit + ""// unit })}, {std::make_shared<signal_t> (signal_t{ "doors.rear_right.open",// generic_name @@ -341,18 +346,19 @@ application_t::application_t() false,// force_send_changed { },// states - false,// writable + true,// writable decoder_t::decode_boolean,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "",// unit + ""// unit })} } // end signals vector })} // end message_definition entry -, {std::make_shared<message_definition_t>(message_definition_t{"hs",0x799,"",0,false,message_format_t::STANDARD,frequency_clock_t(5.00000f),true, { // beginning signals vector +, {std::make_shared<message_definition_t>(message_definition_t{"hs",0x799,"",8,2,frequency_clock_t(5.00000f),true, + { // beginning signals vector {std::make_shared<signal_t> (signal_t{ "windows.front_left.open",// generic_name 43,// bit_position @@ -366,14 +372,14 @@ application_t::application_t() false,// force_send_changed { },// states - false,// writable + true,// writable decoder_t::decode_boolean,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "",// unit + ""// unit })}, {std::make_shared<signal_t> (signal_t{ "windows.front_right.open",// generic_name @@ -388,14 +394,14 @@ application_t::application_t() false,// force_send_changed { },// states - false,// writable + true,// writable decoder_t::decode_boolean,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "",// unit + ""// unit })}, {std::make_shared<signal_t> (signal_t{ "windows.rear_left.open",// generic_name @@ -410,14 +416,14 @@ application_t::application_t() false,// force_send_changed { },// states - false,// writable + true,// writable decoder_t::decode_boolean,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "",// unit + ""// unit })}, {std::make_shared<signal_t> (signal_t{ "windows.rear_right.open",// generic_name @@ -432,18 +438,19 @@ application_t::application_t() false,// force_send_changed { },// states - false,// writable + true,// writable decoder_t::decode_boolean,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "",// unit + ""// unit })} } // end signals vector })} // end message_definition entry -, {std::make_shared<message_definition_t>(message_definition_t{"j1939",61442,"ETC1",8,false,message_format_t::J1939,frequency_clock_t(5.00000f),true, { // beginning signals vector +, {std::make_shared<message_definition_t>(message_definition_t{"j1939",61442,"ETC1",8,18,frequency_clock_t(5.00000f),true, + { // beginning signals vector {std::make_shared<signal_t> (signal_t{ "Eng.Momentary.Overspeed.Enable",// generic_name 32,// bit_position @@ -462,13 +469,13 @@ application_t::application_t() {3,"TakeNoAction"} },// states true,// writable - nullptr,// decoder + decoder_t::decode_state,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "",// unit + ""// unit })}, {std::make_shared<signal_t> (signal_t{ "Momentary.Eng.Max.Power.Enable",// generic_name @@ -488,13 +495,13 @@ application_t::application_t() {0,"notRqingMaxPowerAvailable"} },// states true,// writable - nullptr,// decoder + decoder_t::decode_state,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "",// unit + ""// unit })}, {std::make_shared<signal_t> (signal_t{ "Percent.Clutch.Slip",// generic_name @@ -513,10 +520,10 @@ application_t::application_t() nullptr,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "%",// unit + "%"// unit })}, {std::make_shared<signal_t> (signal_t{ "Progressive.Shift.Disable",// generic_name @@ -536,13 +543,13 @@ application_t::application_t() {3,"TakeNoAction"} },// states true,// writable - nullptr,// decoder + decoder_t::decode_state,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "",// unit + ""// unit })}, {std::make_shared<signal_t> (signal_t{ "Src.Addrss.Of.Ctrllng.Dvc.Fr.Trns.Cntrl",// generic_name @@ -561,10 +568,10 @@ application_t::application_t() nullptr,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "",// unit + ""// unit })}, {std::make_shared<signal_t> (signal_t{ "Trans.Driveline.Engaged",// generic_name @@ -584,13 +591,13 @@ application_t::application_t() {3,"NotAvailable"} },// states true,// writable - nullptr,// decoder + decoder_t::decode_state,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "",// unit + ""// unit })}, {std::make_shared<signal_t> (signal_t{ "Trans.Input.Shaft.Speed",// generic_name @@ -609,10 +616,10 @@ application_t::application_t() nullptr,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "rpm",// unit + "rpm"// unit })}, {std::make_shared<signal_t> (signal_t{ "Trans.Output.Shaft.Speed",// generic_name @@ -631,10 +638,10 @@ application_t::application_t() nullptr,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "rpm",// unit + "rpm"// unit })}, {std::make_shared<signal_t> (signal_t{ "Trans.Shift.In.Process",// generic_name @@ -654,13 +661,13 @@ application_t::application_t() {0,"ShiftIsNotInProcess"} },// states true,// writable - nullptr,// decoder + decoder_t::decode_state,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "",// unit + ""// unit })}, {std::make_shared<signal_t> (signal_t{ "Trns.Trq.Cnvrtr.Lckp.Trnstn.In.Prcess",// generic_name @@ -680,13 +687,13 @@ application_t::application_t() {0,"TransitionIsNotInProcess"} },// states true,// writable - nullptr,// decoder + decoder_t::decode_state,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "",// unit + ""// unit })}, {std::make_shared<signal_t> (signal_t{ "Trns.Trque.Converter.Lockup.Engaged",// generic_name @@ -706,17 +713,18 @@ application_t::application_t() {1,"TorqueConverterLockupEngaged"} },// states true,// writable - nullptr,// decoder + decoder_t::decode_state,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "",// unit + ""// unit })} } // end signals vector })} // end message_definition entry -, {std::make_shared<message_definition_t>(message_definition_t{"j1939",61444,"EEC1",8,false,message_format_t::J1939,frequency_clock_t(5.00000f),true, { // beginning signals vector +, {std::make_shared<message_definition_t>(message_definition_t{"j1939",61444,"EEC1",8,18,frequency_clock_t(5.00000f),true, + { // beginning signals vector {std::make_shared<signal_t> (signal_t{ "Actl.Eng.Prcnt.Trque.High.Resolution",// generic_name 4,// bit_position @@ -735,13 +743,13 @@ application_t::application_t() {8,"1111NotAvailable"} },// states false,// writable - nullptr,// decoder + decoder_t::decode_state,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "%",// unit + "%"// unit })}, {std::make_shared<signal_t> (signal_t{ "Actual.Eng.Percent.Torque",// generic_name @@ -760,10 +768,10 @@ application_t::application_t() nullptr,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "%",// unit + "%"// unit })}, {std::make_shared<signal_t> (signal_t{ "Drivers.Demand.Eng.Percent.Torque",// generic_name @@ -782,10 +790,10 @@ application_t::application_t() nullptr,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "%",// unit + "%"// unit })}, {std::make_shared<signal_t> (signal_t{ "Eng.Demand.Percent.Torque",// generic_name @@ -804,10 +812,10 @@ application_t::application_t() nullptr,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "%",// unit + "%"// unit })}, {std::make_shared<signal_t> (signal_t{ "Eng.Speed",// generic_name @@ -826,10 +834,10 @@ application_t::application_t() nullptr,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "rpm",// unit + "rpm"// unit })}, {std::make_shared<signal_t> (signal_t{ "Eng.Starter.Mode",// generic_name @@ -858,13 +866,13 @@ application_t::application_t() {8,"strtrInhbtdDueToStarterOvertemp"} },// states false,// writable - nullptr,// decoder + decoder_t::decode_state,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "",// unit + ""// unit })}, {std::make_shared<signal_t> (signal_t{ "Eng.Torque.Mode",// generic_name @@ -893,13 +901,13 @@ application_t::application_t() {6,"Transmission control"} },// states false,// writable - nullptr,// decoder + decoder_t::decode_state,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "",// unit + ""// unit })}, {std::make_shared<signal_t> (signal_t{ "Src.AddrssOf.Ctrllng.Dvc.Fr.Eng.Cntrl",// generic_name @@ -918,14 +926,15 @@ application_t::application_t() nullptr,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "",// unit + ""// unit })} } // end signals vector })} // end message_definition entry -, {std::make_shared<message_definition_t>(message_definition_t{"j1939",61449,"VDC2",8,false,message_format_t::J1939,frequency_clock_t(5.00000f),true, { // beginning signals vector +, {std::make_shared<message_definition_t>(message_definition_t{"j1939",61449,"VDC2",8,18,frequency_clock_t(5.00000f),true, + { // beginning signals vector {std::make_shared<signal_t> (signal_t{ "Lateral.Acceleration",// generic_name 40,// bit_position @@ -943,10 +952,10 @@ application_t::application_t() nullptr,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "m/s/s",// unit + "m/s/s"// unit })}, {std::make_shared<signal_t> (signal_t{ "Longitudinal.Acceleration",// generic_name @@ -965,10 +974,10 @@ application_t::application_t() nullptr,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "m/s/s",// unit + "m/s/s"// unit })}, {std::make_shared<signal_t> (signal_t{ "Steer.Wheel.Angle",// generic_name @@ -987,10 +996,10 @@ application_t::application_t() nullptr,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "rad",// unit + "rad"// unit })}, {std::make_shared<signal_t> (signal_t{ "Steer.Wheel.Angle.Sensor.Type",// generic_name @@ -1010,13 +1019,13 @@ application_t::application_t() {2,"Reserved"} },// states false,// writable - nullptr,// decoder + decoder_t::decode_state,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "",// unit + ""// unit })}, {std::make_shared<signal_t> (signal_t{ "Steer.Wheel.Turn.Counter",// generic_name @@ -1035,10 +1044,10 @@ application_t::application_t() nullptr,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "turns",// unit + "turns"// unit })}, {std::make_shared<signal_t> (signal_t{ "Yaw.Rate",// generic_name @@ -1057,14 +1066,15 @@ application_t::application_t() nullptr,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "rad/s",// unit + "rad/s"// unit })} } // end signals vector })} // end message_definition entry -, {std::make_shared<message_definition_t>(message_definition_t{"j1939",65215,"EBC2",8,false,message_format_t::J1939,frequency_clock_t(5.00000f),true, { // beginning signals vector +, {std::make_shared<message_definition_t>(message_definition_t{"j1939",65215,"EBC2",8,18,frequency_clock_t(5.00000f),true, + { // beginning signals vector {std::make_shared<signal_t> (signal_t{ "Front.Axle.Speed",// generic_name 0,// bit_position @@ -1082,10 +1092,10 @@ application_t::application_t() nullptr,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "km/h",// unit + "km/h"// unit })}, {std::make_shared<signal_t> (signal_t{ "Relative.Speed.Front.Axle.Left.Wheel",// generic_name @@ -1104,10 +1114,10 @@ application_t::application_t() nullptr,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "km/h",// unit + "km/h"// unit })}, {std::make_shared<signal_t> (signal_t{ "Relative.Speed.Rear.Axle1.Left.Wheel",// generic_name @@ -1126,10 +1136,10 @@ application_t::application_t() nullptr,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "km/h",// unit + "km/h"// unit })}, {std::make_shared<signal_t> (signal_t{ "Relative.Speed.Rear.Axle2.Left.Wheel",// generic_name @@ -1148,10 +1158,10 @@ application_t::application_t() nullptr,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "km/h",// unit + "km/h"// unit })}, {std::make_shared<signal_t> (signal_t{ "Rlative.Speed.Front.Axle.Right.Wheel",// generic_name @@ -1170,10 +1180,10 @@ application_t::application_t() nullptr,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "km/h",// unit + "km/h"// unit })}, {std::make_shared<signal_t> (signal_t{ "Rlative.Speed.Rear.Axle1.Right.Wheel",// generic_name @@ -1192,10 +1202,10 @@ application_t::application_t() nullptr,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "km/h",// unit + "km/h"// unit })}, {std::make_shared<signal_t> (signal_t{ "Rlative.Speed.Rear.Axle2.Right.Wheel",// generic_name @@ -1214,14 +1224,15 @@ application_t::application_t() nullptr,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "km/h",// unit + "km/h"// unit })} } // end signals vector })} // end message_definition entry -, {std::make_shared<message_definition_t>(message_definition_t{"j1939",65253,"HOURS",8,false,message_format_t::J1939,frequency_clock_t(5.00000f),true, { // beginning signals vector +, {std::make_shared<message_definition_t>(message_definition_t{"j1939",65253,"HOURS",8,18,frequency_clock_t(5.00000f),true, + { // beginning signals vector {std::make_shared<signal_t> (signal_t{ "Eng.Total.Hours.Of.Operation",// generic_name 0,// bit_position @@ -1239,10 +1250,10 @@ application_t::application_t() nullptr,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "hr",// unit + "hr"// unit })}, {std::make_shared<signal_t> (signal_t{ "Eng.Total.Revolutions",// generic_name @@ -1261,14 +1272,15 @@ application_t::application_t() nullptr,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "r",// unit + "r"// unit })} } // end signals vector })} // end message_definition entry -, {std::make_shared<message_definition_t>(message_definition_t{"j1939",65262,"ET1",8,false,message_format_t::J1939,frequency_clock_t(5.00000f),true, { // beginning signals vector +, {std::make_shared<message_definition_t>(message_definition_t{"j1939",65262,"ET1",8,18,frequency_clock_t(5.00000f),true, + { // beginning signals vector {std::make_shared<signal_t> (signal_t{ "Eng.Coolant.Temp",// generic_name 0,// bit_position @@ -1286,10 +1298,10 @@ application_t::application_t() nullptr,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "deg C",// unit + "deg C"// unit })}, {std::make_shared<signal_t> (signal_t{ "Eng.Fuel.Temp1",// generic_name @@ -1308,10 +1320,10 @@ application_t::application_t() nullptr,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "deg C",// unit + "deg C"// unit })}, {std::make_shared<signal_t> (signal_t{ "Eng.Intercooler.Temp",// generic_name @@ -1330,10 +1342,10 @@ application_t::application_t() nullptr,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "deg C",// unit + "deg C"// unit })}, {std::make_shared<signal_t> (signal_t{ "Eng.Intercooler.Thermostat.Opening",// generic_name @@ -1352,10 +1364,10 @@ application_t::application_t() nullptr,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "%",// unit + "%"// unit })}, {std::make_shared<signal_t> (signal_t{ "Eng.Oil.Temp1",// generic_name @@ -1374,10 +1386,10 @@ application_t::application_t() nullptr,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "deg C",// unit + "deg C"// unit })}, {std::make_shared<signal_t> (signal_t{ "Eng.Turbo.Oil.Temp",// generic_name @@ -1396,13 +1408,14 @@ application_t::application_t() nullptr,// decoder nullptr,// encoder false,// received - std::make_pair<bool, int>(false,0),// multiplex + std::make_pair<bool, int>(false, 0),// multiplex 0,// is_big_endian 0,// is_signed - "deg C",// unit + "deg C"// unit })} } // end signals vector })} // end message_definition entry + }, // end message_definition vector { // beginning diagnostic_messages_ vector {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ diff --git a/examples/tests/signal.json b/examples/tests/signal.json new file mode 100644 index 00000000..1478caf8 --- /dev/null +++ b/examples/tests/signal.json @@ -0,0 +1,955 @@ +{ "name": "AGL Virtual Car", + "extra_sources": [], + "initializers": [], + "loopers": [], + "buses": {}, + "commands": [], + "messages": { + "0x620": { + "bus": "hs", + "is_fd" : false, + "is_extended": false, + "is_j1939" : false, + "length" : 8, + "signals": { + "doors.driver.open": { + "generic_name": "doors.front_left.open", + "bit_position": 43, + "bit_size": 1, + "factor": 1.0, + "offset": 0, + "writable": true, + "decoder": "decoder_t::decode_boolean"}, + "doors.passenger.open": { + "generic_name": "doors.front_right.open", + "bit_position": 44, + "bit_size": 1, + "factor": 1.0, + "offset": 0, + "writable": true, + "decoder": "decoder_t::decode_boolean"}, + "doors.rearleft.open": { + "generic_name": "doors.rear_left.open", + "bit_position": 46, + "bit_size": 1, + "factor": 1.0, + "offset": 0, + "writable": true, + "decoder": "decoder_t::decode_boolean"}, + "doors.rearright.open": { + "generic_name": "doors.rear_right.open", + "bit_position": 45, + "bit_size": 4, + "factor": 1.0, + "offset": 0, + "writable": true, + "decoder": "decoder_t::decode_boolean"}, + "doors.coffer.open": { + "generic_name": "doors.boot.open", + "bit_position": 47, + "bit_size": 1, + "factor": 1.0, + "offset": 0, + "writable": true, + "decoder": "decoder_t::decode_boolean"} + } + }, + "0x799": { + "bus": "hs", + "is_fd" : false, + "is_extended": false, + "is_j1939" : false, + "length" : 8, + "signals": { + "windows.driver.open": { + "generic_name": "windows.front_left.open", + "bit_position": 43, + "bit_size": 1, + "factor": 1.0, + "offset": 0, + "writable": true, + "decoder": "decoder_t::decode_boolean"}, + "windows.passenger.open": { + "generic_name": "windows.front_right.open", + "bit_position": 44, + "bit_size": 1, + "factor": 1.0, + "offset": 0, + "writable": true, + "decoder": "decoder_t::decode_boolean"}, + "windows.rearleft.open": { + "generic_name": "windows.rear_left.open", + "bit_position": 46, + "bit_size": 1, + "factor": 1.0, + "offset": 0, + "writable": true, + "decoder": "decoder_t::decode_boolean"}, + "windows.rearright.open": { + "generic_name": "windows.rear_right.open", + "bit_position": 45, + "bit_size": 4, + "factor": 1.0, + "offset": 0, + "writable": true, + "decoder": "decoder_t::decode_boolean"} + } + }, + "0x3D9": { + "bus": "hs", + "is_fd" : true, + "is_extended": false, + "is_j1939" : false, + "length" : 8, + "signals": { + "PT_FuelLevelPct": { + "generic_name": "fuel.level", + "bit_position": 8, + "bit_size": 8, + "factor": 0.392157, + "offset": 0, + "writable": true + }, + "PT_EngineSpeed": { + "generic_name": "engine.speed", + "bit_position": 16, + "bit_size": 16, + "factor": 0.25, + "offset": 0, + "writable": true + }, + "PT_FuelLevelLow": { + "generic_name": "fuel.level.low", + "bit_position": 55, + "bit_size": 1, + "factor": 1, + "offset": 0, + "writable": true, + "decoder": "decoder_t::decode_boolean" + } + } + }, + "0x4D1": { + "bus": "hs", + "is_fd" : false, + "is_extended": false, + "is_j1939" : false, + "length" : 8, + "signals": { + "PT_EngineOilTempHigh": { + "generic_name": "engine.oil.temp.high", + "bit_position": 7, + "bit_size": 1, + "factor": 1, + "offset": 0, + "writable": true, + "decoder": "decoder_t::decode_boolean" + }, + "PT_EngineOilTemp": { + "generic_name": "engine.oil.temp", + "bit_position": 16, + "bit_size": 8, + "factor": 1, + "offset": 0, + "writable": true + } + } + }, + "0x3E9": { + "bus": "hs", + "is_fd" : false, + "is_extended": false, + "is_j1939" : false, + "length" : 8, + "signals": { + "PT_VehicleAvgSpeed": { + "generic_name": "vehicle.average.speed", + "bit_position": 0, + "bit_size": 15, + "factor": 0.015625, + "offset": 0, + "writable": false + } + } + }, + "0x30": { + "bus": "ls", + "is_fd" : false, + "is_extended": true, + "is_j1939" : false, + "length" : 8, + "signals": { + "LeftTemperature": { + "generic_name": "hvac.temperature.left", + "bit_position": 0, + "bit_size": 8, + "factor": 1, + "offset": 0, + "writable": true + }, + "RightTemperature": { + "generic_name": "hvac.temperature.right", + "bit_position": 8, + "bit_size": 8, + "factor": 1, + "offset": 0, + "writable": true + }, + "Temperature": { + "generic_name": "hvac.temperature.average", + "bit_position": 16, + "bit_size": 8, + "factor": 1, + "offset": 0, + "writable": true + }, + "FanSpeed": { + "generic_name": "hvac.fan.speed", + "bit_position": 32, + "bit_size": 8, + "factor": 23.529411765, + "offset": 0, + "writable": true + } + } + }, + "61442": { + "comment": "Electronic Transmission Controller 1", + "length": 8, + "name": "ETC1", + "bus" : "j1939", + "is_fd" : false, + "is_extended": false, + "is_j1939" : true, + "signals" : { + "Trns.Trque.Converter.Lockup.Engaged" : { + "generic_name": "Trns.Trque.Converter.Lockup.Engaged", + "bit_position": 2, + "bit_size": 2, + "factor": 1, + "offset": 0, + "comment": "State signal which indicates whether the torque converter lockup is engaged.", + "is_big_endian": false, + "is_signed": false, + "writable" : true, + "states": { + "TorqueConverterLockupDisengaged": [0], + "TorqueConverterLockupEngaged": [1], + "Error": [2], + "NotAvailable": [3] + } + }, + "Trns.Trq.Cnvrtr.Lckp.Trnstn.In.Prcess" : { + "generic_name": "Trns.Trq.Cnvrtr.Lckp.Trnstn.In.Prcess", + "bit_position": 6, + "bit_size": 2, + "factor": 1, + "offset": 0, + "comment": "State signal indicating whether or not the transmission torque converter lock up clutch is transitioning between being", + "is_big_endian": false, + "is_signed": false, + "writable" : true, + "states": { + "TransitionIsNotInProcess": [0], + "TransitionIsInProcess": [1], + "Error": [2], + "NotAvailable": [3] + } + }, + "Src.Addrss.Of.Ctrllng.Dvc.Fr.Trns.Cntrl" : { + "generic_name": "Src.Addrss.Of.Ctrllng.Dvc.Fr.Trns.Cntrl", + "bit_position": 56, + "bit_size": 8, + "factor": 1, + "offset": 0, + "comment": "The source address of the SAE J1939 device currently controlling the transmission.", + "is_big_endian": false, + "is_signed": false, + "writable" : true + }, + "Momentary.Eng.Max.Power.Enable" : { + "generic_name": "Momentary.Eng.Max.Power.Enable", + "bit_position": 36, + "bit_size": 2, + "factor": 1, + "offset": 0, + "comment": "Momentarily Requesting highest torque map from the engine control", + "is_big_endian": false, + "is_signed": false, + "writable" : true, + "states": { + "notRqingMaxPowerAvailable": [0], + "mmntarilyRqingMaxPowerAvailable": [1], + "fault": [2], + "notAvailable": [3] + } + }, + "Trans.Input.Shaft.Speed" : { + "generic_name": "Trans.Input.Shaft.Speed", + "bit_position": 40, + "bit_size": 16, + "factor": 0.125, + "offset": 0, + "comment": "Rotational velocity of the primary shaft transferring power into the transmission.", + "unit": "rpm", + "is_big_endian": false, + "is_signed": false, + "writable" : true + }, + "Progressive.Shift.Disable" : { + "generic_name": "Progressive.Shift.Disable", + "bit_position": 34, + "bit_size": 2, + "factor": 1, + "offset": 0, + "comment": "Command signal used to indicate that progressive shifting by the engine should be disallowed.", + "is_big_endian": false, + "is_signed": false, + "writable" : true, + "states": { + "ProgressiveShiftIsNotDisabled": [0], + "ProgressiveShiftIsDisabled": [1], + "Reserved": [2], + "TakeNoAction": [3] + } + }, + "Eng.Momentary.Overspeed.Enable" : { + "generic_name": "Eng.Momentary.Overspeed.Enable", + "bit_position": 32, + "bit_size": 2, + "factor": 1, + "offset": 0, + "comment": "Command signal used to indicate that the engine speed may be boosted up to the maximum engine overspeed value to", + "is_big_endian": false, + "is_signed": false, + "writable" : true, + "states": { + "MomentaryEngOverspeedIsDisabled": [0], + "MomentaryEngOverspeedIsEnabled": [1], + "Reserved": [2], + "TakeNoAction": [3] + } + }, + "Percent.Clutch.Slip" : { + "generic_name": "Percent.Clutch.Slip", + "bit_position": 24, + "bit_size": 8, + "factor": 0.4, + "offset": 0, + "comment": "Parameter which represents the ratio of input shaft speed to current engine speed (in percent).", + "unit": "%", + "is_big_endian": false, + "is_signed": false, + "writable" : true + }, + "Trans.Output.Shaft.Speed" : { + "generic_name": "Trans.Output.Shaft.Speed", + "bit_position": 8, + "bit_size": 16, + "factor": 0.125, + "offset": 0, + "comment": "Calculated speed of the transmission output shaft.", + "unit": "rpm", + "is_big_endian": false, + "is_signed": false, + "writable" : true + }, + "Trans.Shift.In.Process" : { + "generic_name": "Trans.Shift.In.Process", + "bit_position": 4, + "bit_size": 2, + "factor": 1, + "offset": 0, + "comment": "Indicates that the transmission is in process of shifting from the current gear to the selected gear.", + "is_big_endian": false, + "is_signed": false, + "writable" : true, + "states": { + "ShiftIsNotInProcess": [0], + "ShiftInProcess": [1], + "Error": [2], + "NotAvailable": [3] + } + }, + "Trans.Driveline.Engaged" : { + "generic_name": "Trans.Driveline.Engaged", + "bit_position": 0, + "bit_size": 2, + "factor": 1, + "offset": 0, + "comment": "Driveline engaged indicates the transmission controlled portion of the driveline is engaged sufficiently to allow a transfer", + "is_big_endian": false, + "is_signed": false, + "writable" : true, + "states": { + "DrivelineDisengaged": [0], + "DrivelineEngaged": [1], + "Error": [2], + "NotAvailable": [3] + } + } + } + }, + "61444": { + "comment": "Electronic Engine Controller 1", + "length": 8, + "name": "EEC1", + "bus" : "j1939", + "is_fd" : false, + "is_extended": false, + "is_j1939" : true, + "signals" : { + "Src.AddrssOf.Ctrllng.Dvc.Fr.Eng.Cntrl" : { + "generic_name": "Src.AddrssOf.Ctrllng.Dvc.Fr.Eng.Cntrl", + "bit_position": 40, + "bit_size": 8, + "factor": 1, + "offset": 0, + "comment": "The source address of the SAE J1939 device currently controlling the engine.", + "is_big_endian": false, + "is_signed": false + }, + "Actl.Eng.Prcnt.Trque.High.Resolution" : { + "generic_name": "Actl.Eng.Prcnt.Trque.High.Resolution", + "bit_position": 4, + "bit_size": 4, + "factor": 0.125, + "offset": 0, + "comment": "This parameter displays an additional torque in percent of the reference engine torque.", + "unit": "%", + "is_big_endian": false, + "is_signed": false, + "states": { + "0000": [0], + "0125": [1], + "0875": [7], + "1111NotAvailable": [8] + } + }, + "Eng.Demand.Percent.Torque" : { + "generic_name": "Eng.Demand.Percent.Torque", + "bit_position": 56, + "bit_size": 8, + "factor": 1, + "offset": -125, + "comment": "The requested torque output of the engine by all dynamic internal inputs, including smoke control, noise control and low", + "unit": "%", + "is_big_endian": false, + "is_signed": false + }, + "Eng.Starter.Mode" : { + "generic_name": "Eng.Starter.Mode", + "bit_position": 48, + "bit_size": 4, + "factor": 1, + "offset": 0, + "comment": "There are several phases in a starting action and different reasons why a start cannot take place.", + "is_big_endian": false, + "is_signed": false, + "states": { + "startNotRqed": [0], + "starterActiveGearNotEngaged": [1], + "starterActiveGearEngaged": [2], + "strtFnshdStrtrNtActvAftrHvngBnA": [3], + "strtrInhbtdDToEngAlreadyRunning": [4], + "strtrInhbtdDTEngNtReadyForStart": [5], + "strtrInhbtdDTDrvlnEnggdOthrTrns": [6], + "strtrInhbtdDToActiveImmobilizer": [7], + "strtrInhbtdDueToStarterOvertemp": [8], + "1011Reserved": [9], + "starterInhibitedReasonUnknown": [12], + "error": [14], + "notAvailable": [15] + } + }, + "Eng.Speed" : { + "generic_name": "Eng.Speed", + "bit_position": 24, + "bit_size": 16, + "factor": 0.125, + "offset": 0, + "comment": "Actual engine speed which is calculated over a minimum crankshaft angle of 720 degrees divided by the number of cylinders.", + "unit": "rpm", + "is_big_endian": false, + "is_signed": false + }, + "Actual.Eng.Percent.Torque" : { + "generic_name": "Actual.Eng.Percent.Torque", + "bit_position": 16, + "bit_size": 8, + "factor": 1, + "offset": -125, + "comment": "The calculated output torque of the engine.", + "unit": "%", + "is_big_endian": false, + "is_signed": false + }, + "Drivers.Demand.Eng.Percent.Torque" : { + "generic_name": "Drivers.Demand.Eng.Percent.Torque", + "bit_position": 8, + "bit_size": 8, + "factor": 1, + "offset": -125, + "comment": "The requested torque output of the engine by the driver.", + "unit": "%", + "is_big_endian": false, + "is_signed": false + }, + "Eng.Torque.Mode" : { + "generic_name": "Eng.Torque.Mode", + "bit_position": 0, + "bit_size": 4, + "factor": 1, + "offset": 0, + "comment": "State signal which indicates which engine torque mode is currently generating, limiting, or controlling the torque.", + "is_big_endian": false, + "is_signed": false, + "states": { + "Low idle governor/no request (de": [0], + "Accelerator pedal/operator selec": [1], + "Cruise control": [2], + "PTO governor": [3], + "Road speed governor": [4], + "ASR control": [5], + "Transmission control": [6], + "ABS control": [7], + "Torque limiting": [8], + "High speed governor": [9], + "Braking system": [10], + "Remote accelerator": [11], + "Not available": [15] + } + } + } + }, + "65253": { + "comment": "Engine Hours, Revolutions", + "length": 8, + "name": "HOURS", + "bus" : "j1939", + "is_fd" : false, + "is_extended": false, + "is_j1939" : true, + "signals" : { + "Eng.Total.Revolutions" : { + "generic_name": "Eng.Total.Revolutions", + "bit_position": 32, + "bit_size": 32, + "factor": 1000, + "offset": 0, + "comment": "Accumulated number of revolutions of engine crankshaft during its operation.", + "unit": "r", + "is_big_endian": false, + "is_signed": false + }, + "Eng.Total.Hours.Of.Operation" : { + "generic_name": "Eng.Total.Hours.Of.Operation", + "bit_position": 0, + "bit_size": 32, + "factor": 0.05, + "offset": 0, + "comment": "Accumulated time of operation of engine.", + "unit": "hr", + "is_big_endian": false, + "is_signed": false + } + } + }, + "61449": { + "comment": "Vehicle Dynamic Stability Control 2", + "length": 8, + "name": "VDC2", + "bus" : "j1939", + "is_fd" : false, + "is_extended": false, + "is_j1939" : true, + "signals" : { + "Steer.Wheel.Angle" : { + "generic_name": "Steer.Wheel.Angle", + "bit_position": 0, + "bit_size": 16, + "factor": 0.0009765625, + "offset": -31.374, + "comment": "The main operator`s steering wheel angle (on the steering column, not the actual wheel angle).", + "unit": "rad", + "is_big_endian": false, + "is_signed": false + }, + "Longitudinal.Acceleration" : { + "generic_name": "Longitudinal.Acceleration", + "bit_position": 56, + "bit_size": 8, + "factor": 0.1, + "offset": -12.5, + "comment": "Indicates the longitudinal acceleration of the vehicle.", + "unit": "m/s/s", + "is_big_endian": false, + "is_signed": false + }, + "Lateral.Acceleration" : { + "generic_name": "Lateral.Acceleration", + "bit_position": 40, + "bit_size": 16, + "factor": 0.00048828125, + "offset": -15.687, + "comment": "Indicates a lateral acceleration of the vehicle.", + "unit": "m/s/s", + "is_big_endian": false, + "is_signed": false + }, + "Yaw.Rate" : { + "generic_name": "Yaw.Rate", + "bit_position": 24, + "bit_size": 16, + "factor": 0.0001220703125, + "offset": -3.92, + "comment": "Indicates the rotation about the vertical axis.", + "unit": "rad/s", + "is_big_endian": false, + "is_signed": false + }, + "Steer.Wheel.Angle.Sensor.Type" : { + "generic_name": "Steer.Wheel.Angle.Sensor.Type", + "bit_position": 22, + "bit_size": 2, + "factor": 1, + "offset": 0, + "comment": "Indicates whether the steering wheel angle sensor is capable of absolute measuring of the number of steering wheel", + "is_big_endian": false, + "is_signed": false, + "states": { + "RelativeMeasuringPrinciple": [0], + "AbsMeasuringPrinciple": [1], + "Reserved": [2], + "NotAvailable": [3] + } + }, + "Steer.Wheel.Turn.Counter" : { + "generic_name": "Steer.Wheel.Turn.Counter", + "bit_position": 16, + "bit_size": 6, + "factor": 1, + "offset": -32, + "comment": "Indicates number of steering wheel turns, absolute position or relative position at ignition on.", + "unit": "turns", + "is_big_endian": false, + "is_signed": false + } + } + }, + "65215": { + "comment": "Wheel Speed Information", + "length": 8, + "name": "EBC2", + "bus" : "j1939", + "is_fd" : false, + "is_extended": false, + "is_j1939" : true, + "signals" : { + "Rlative.Speed.Rear.Axle2.Right.Wheel" : { + "generic_name": "Rlative.Speed.Rear.Axle2.Right.Wheel", + "bit_position": 56, + "bit_size": 8, + "factor": 0.0625, + "offset": -7.8125, + "comment": "The speed of the rear axle #2, right wheel relative to the front axle speed, SPN 904.", + "unit": "km/h", + "is_big_endian": false, + "is_signed": false + }, + "Relative.Speed.Rear.Axle2.Left.Wheel" : { + "generic_name": "Relative.Speed.Rear.Axle2.Left.Wheel", + "bit_position": 48, + "bit_size": 8, + "factor": 0.0625, + "offset": -7.8125, + "comment": "The speed of the rear axle #2, left wheel relative to the front axle speed, SPN 904.", + "unit": "km/h", + "is_big_endian": false, + "is_signed": false + }, + "Rlative.Speed.Rear.Axle1.Right.Wheel" : { + "generic_name": "Rlative.Speed.Rear.Axle1.Right.Wheel", + "bit_position": 40, + "bit_size": 8, + "factor": 0.0625, + "offset": -7.8125, + "comment": "The speed of the rear axle #1, right wheel relative to the front axle speed, SPN 904.", + "unit": "km/h", + "is_big_endian": false, + "is_signed": false + }, + "Relative.Speed.Rear.Axle1.Left.Wheel" : { + "generic_name": "Relative.Speed.Rear.Axle1.Left.Wheel", + "bit_position": 32, + "bit_size": 8, + "factor": 0.0625, + "offset": -7.8125, + "comment": "The speed of the rear axle #1, left wheel relative to the front axle speed, SPN 904.", + "unit": "km/h", + "is_big_endian": false, + "is_signed": false + }, + "Rlative.Speed.Front.Axle.Right.Wheel" : { + "generic_name": "Rlative.Speed.Front.Axle.Right.Wheel", + "bit_position": 24, + "bit_size": 8, + "factor": 0.0625, + "offset": -7.8125, + "comment": "The speed of the front axle, right wheel relative to the front axle speed, SPN 904.", + "unit": "km/h", + "is_big_endian": false, + "is_signed": false + }, + "Relative.Speed.Front.Axle.Left.Wheel" : { + "generic_name": "Relative.Speed.Front.Axle.Left.Wheel", + "bit_position": 16, + "bit_size": 8, + "factor": 0.0625, + "offset": -7.8125, + "comment": "The speed of the front axle, left wheel relative to the front axle speed, SPN 904.", + "unit": "km/h", + "is_big_endian": false, + "is_signed": false + }, + "Front.Axle.Speed" : { + "generic_name": "Front.Axle.Speed", + "bit_position": 0, + "bit_size": 16, + "factor": 0.00390625, + "offset": 0, + "comment": "The average speed of the two front wheels.", + "unit": "km/h", + "is_big_endian": false, + "is_signed": false + } + } + }, + "65262": { + "comment": "Engine Temperature 1", + "length": 8, + "name": "ET1", + "bus" : "j1939", + "is_fd" : false, + "is_extended": false, + "is_j1939" : true, + "signals" : { + "Eng.Fuel.Temp1" : { + "generic_name": "Eng.Fuel.Temp1", + "bit_position": 8, + "bit_size": 8, + "factor": 1, + "offset": -40, + "comment": "Temperature of fuel (or gas) passing through the first fuel control system.", + "unit": "deg C", + "is_big_endian": false, + "is_signed": false + }, + "Eng.Intercooler.Thermostat.Opening" : { + "generic_name": "Eng.Intercooler.Thermostat.Opening", + "bit_position": 56, + "bit_size": 8, + "factor": 0.4, + "offset": 0, + "comment": "The current position of the thermostat used to regulate the temperature of the engine intercooler.", + "unit": "%", + "is_big_endian": false, + "is_signed": false + }, + "Eng.Intercooler.Temp" : { + "generic_name": "Eng.Intercooler.Temp", + "bit_position": 48, + "bit_size": 8, + "factor": 1, + "offset": -40, + "comment": "Temperature of liquid found in the intercooler located after the turbocharger.", + "unit": "deg C", + "is_big_endian": false, + "is_signed": false + }, + "Eng.Turbo.Oil.Temp" : { + "generic_name": "Eng.Turbo.Oil.Temp", + "bit_position": 32, + "bit_size": 16, + "factor": 0.03125, + "offset": -273, + "comment": "Temperature of the turbocharger lubricant.", + "unit": "deg C", + "is_big_endian": false, + "is_signed": false + }, + "Eng.Oil.Temp1" : { + "generic_name": "Eng.Oil.Temp1", + "bit_position": 16, + "bit_size": 16, + "factor": 0.03125, + "offset": -273, + "comment": "Temperature of the engine lubricant.", + "unit": "deg C", + "is_big_endian": false, + "is_signed": false + }, + "Eng.Coolant.Temp" : { + "generic_name": "Eng.Coolant.Temp", + "bit_position": 0, + "bit_size": 8, + "factor": 0.03125, + "offset": -273, + "comment": "Temperature of liquid found in engine cooling system.", + "unit": "deg C", + "is_big_endian": false, + "is_signed": false + } + } + } +}, +"diagnostic_messages": [ + { + "bus": "hs", + "pid": 4, + "name": "engine.load", + "frequency": 5, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 5, + "name": "engine.coolant.temperature", + "frequency": 1, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 10, + "name": "fuel.pressure", + "frequency": 1, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 11, + "name": "intake.manifold.pressure", + "frequency": 1, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 12, + "name": "engine.speed", + "frequency": 5, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 13, + "name": "vehicle.speed", + "frequency": 5, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 15, + "name": "intake.air.temperature", + "frequency": 1, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 16, + "name": "mass.airflow", + "frequency": 5, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 17, + "name": "throttle.position", + "frequency": 5, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 31, + "name": "running.time", + "frequency": 1, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 45, + "name": "EGR.error", + "frequency": 0, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 47, + "name": "fuel.level", + "frequency": 1, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 51, + "name": "barometric.pressure", + "frequency": 1, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 70, + "name": "ambient.air.temperature", + "frequency": 1, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 76, + "name": "commanded.throttle.position", + "frequency": 1, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 82, + "name": "ethanol.fuel.percentage", + "frequency": 1, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 90, + "name": "accelerator.pedal.position", + "frequency": 5, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 91, + "name": "hybrid.battery-pack.remaining.life", + "frequency": 5, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 92, + "name": "engine.oil.temperature", + "frequency": 1, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 94, + "name": "engine.fuel.rate", + "frequency": 1, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 99, + "name": "engine.torque", + "frequency": 1, + "decoder": "decoder_t::decode_obd2_response" + } + ] +} diff --git a/low-can-binding/binding/application-generated.cpp b/low-can-binding/binding/application-generated.cpp index 65f72cdf..47fdafa5 100644 --- a/low-can-binding/binding/application-generated.cpp +++ b/low-can-binding/binding/application-generated.cpp @@ -7,7 +7,7 @@ application_t::application_t() , message_set_{ {std::make_shared<message_set_t>(message_set_t{0,"AGL Virtual Car", { // beginning message_definition_ vector - {std::make_shared<message_definition_t>(message_definition_t{"ls",0x30,"",0,false,message_format_t::EXTENDED,frequency_clock_t(5.00000f),true, + {std::make_shared<message_definition_t>(message_definition_t{"ls",0x30,"",8,4,frequency_clock_t(5.00000f),true, { // beginning signals vector {std::make_shared<signal_t> (signal_t{ "hvac.fan.speed",// generic_name @@ -22,7 +22,7 @@ application_t::application_t() false,// force_send_changed { },// states - false,// writable + true,// writable nullptr,// decoder nullptr,// encoder false,// received @@ -99,7 +99,7 @@ application_t::application_t() })} } // end signals vector })} // end message_definition entry -, {std::make_shared<message_definition_t>(message_definition_t{"hs",0x3D9,"",0,true,message_format_t::STANDARD,frequency_clock_t(5.00000f),true, +, {std::make_shared<message_definition_t>(message_definition_t{"hs",0x3D9,"",8,2050,frequency_clock_t(5.00000f),true, { // beginning signals vector {std::make_shared<signal_t> (signal_t{ "engine.speed",// generic_name @@ -169,7 +169,7 @@ application_t::application_t() })} } // end signals vector })} // end message_definition entry -, {std::make_shared<message_definition_t>(message_definition_t{"hs",0x3E9,"",0,false,message_format_t::STANDARD,frequency_clock_t(5.00000f),true, +, {std::make_shared<message_definition_t>(message_definition_t{"hs",0x3E9,"",8,2,frequency_clock_t(5.00000f),true, { // beginning signals vector {std::make_shared<signal_t> (signal_t{ "vehicle.average.speed",// generic_name @@ -195,7 +195,7 @@ application_t::application_t() })} } // end signals vector })} // end message_definition entry -, {std::make_shared<message_definition_t>(message_definition_t{"hs",0x4D1,"",0,false,message_format_t::STANDARD,frequency_clock_t(5.00000f),true, +, {std::make_shared<message_definition_t>(message_definition_t{"hs",0x4D1,"",8,2,frequency_clock_t(5.00000f),true, { // beginning signals vector {std::make_shared<signal_t> (signal_t{ "engine.oil.temp",// generic_name @@ -210,7 +210,7 @@ application_t::application_t() false,// force_send_changed { },// states - false,// writable + true,// writable nullptr,// decoder nullptr,// encoder false,// received @@ -232,7 +232,7 @@ application_t::application_t() false,// force_send_changed { },// states - false,// writable + true,// writable decoder_t::decode_boolean,// decoder nullptr,// encoder false,// received @@ -243,7 +243,7 @@ application_t::application_t() })} } // end signals vector })} // end message_definition entry -, {std::make_shared<message_definition_t>(message_definition_t{"hs",0x620,"",0,false,message_format_t::STANDARD,frequency_clock_t(5.00000f),true, +, {std::make_shared<message_definition_t>(message_definition_t{"hs",0x620,"",8,2,frequency_clock_t(5.00000f),true, { // beginning signals vector {std::make_shared<signal_t> (signal_t{ "doors.boot.open",// generic_name @@ -258,7 +258,7 @@ application_t::application_t() false,// force_send_changed { },// states - false,// writable + true,// writable decoder_t::decode_boolean,// decoder nullptr,// encoder false,// received @@ -280,7 +280,7 @@ application_t::application_t() false,// force_send_changed { },// states - false,// writable + true,// writable decoder_t::decode_boolean,// decoder nullptr,// encoder false,// received @@ -302,7 +302,7 @@ application_t::application_t() false,// force_send_changed { },// states - false,// writable + true,// writable decoder_t::decode_boolean,// decoder nullptr,// encoder false,// received @@ -324,7 +324,7 @@ application_t::application_t() false,// force_send_changed { },// states - false,// writable + true,// writable decoder_t::decode_boolean,// decoder nullptr,// encoder false,// received @@ -346,7 +346,7 @@ application_t::application_t() false,// force_send_changed { },// states - false,// writable + true,// writable decoder_t::decode_boolean,// decoder nullptr,// encoder false,// received @@ -357,7 +357,7 @@ application_t::application_t() })} } // end signals vector })} // end message_definition entry -, {std::make_shared<message_definition_t>(message_definition_t{"hs",0x799,"",0,false,message_format_t::STANDARD,frequency_clock_t(5.00000f),true, +, {std::make_shared<message_definition_t>(message_definition_t{"hs",0x799,"",8,2,frequency_clock_t(5.00000f),true, { // beginning signals vector {std::make_shared<signal_t> (signal_t{ "windows.front_left.open",// generic_name @@ -372,7 +372,7 @@ application_t::application_t() false,// force_send_changed { },// states - false,// writable + true,// writable decoder_t::decode_boolean,// decoder nullptr,// encoder false,// received @@ -394,7 +394,7 @@ application_t::application_t() false,// force_send_changed { },// states - false,// writable + true,// writable decoder_t::decode_boolean,// decoder nullptr,// encoder false,// received @@ -416,7 +416,7 @@ application_t::application_t() false,// force_send_changed { },// states - false,// writable + true,// writable decoder_t::decode_boolean,// decoder nullptr,// encoder false,// received @@ -438,7 +438,7 @@ application_t::application_t() false,// force_send_changed { },// states - false,// writable + true,// writable decoder_t::decode_boolean,// decoder nullptr,// encoder false,// received @@ -450,7 +450,7 @@ application_t::application_t() } // end signals vector })} // end message_definition entry #ifdef USE_FEATURE_J1939 -, {std::make_shared<message_definition_t>(message_definition_t{"j1939",61442,"ETC1",8,false,message_format_t::J1939,frequency_clock_t(5.00000f),true, +, {std::make_shared<message_definition_t>(message_definition_t{"j1939",61442,"ETC1",8,18,frequency_clock_t(5.00000f),true, { // beginning signals vector {std::make_shared<signal_t> (signal_t{ "Eng.Momentary.Overspeed.Enable",// generic_name @@ -724,7 +724,7 @@ application_t::application_t() })} } // end signals vector })} // end message_definition entry -, {std::make_shared<message_definition_t>(message_definition_t{"j1939",61444,"EEC1",8,false,message_format_t::J1939,frequency_clock_t(5.00000f),true, +, {std::make_shared<message_definition_t>(message_definition_t{"j1939",61444,"EEC1",8,18,frequency_clock_t(5.00000f),true, { // beginning signals vector {std::make_shared<signal_t> (signal_t{ "Actl.Eng.Prcnt.Trque.High.Resolution",// generic_name @@ -934,7 +934,7 @@ application_t::application_t() })} } // end signals vector })} // end message_definition entry -, {std::make_shared<message_definition_t>(message_definition_t{"j1939",61449,"VDC2",8,false,message_format_t::J1939,frequency_clock_t(5.00000f),true, +, {std::make_shared<message_definition_t>(message_definition_t{"j1939",61449,"VDC2",8,18,frequency_clock_t(5.00000f),true, { // beginning signals vector {std::make_shared<signal_t> (signal_t{ "Lateral.Acceleration",// generic_name @@ -1074,7 +1074,7 @@ application_t::application_t() })} } // end signals vector })} // end message_definition entry -, {std::make_shared<message_definition_t>(message_definition_t{"j1939",65215,"EBC2",8,false,message_format_t::J1939,frequency_clock_t(5.00000f),true, +, {std::make_shared<message_definition_t>(message_definition_t{"j1939",65215,"EBC2",8,18,frequency_clock_t(5.00000f),true, { // beginning signals vector {std::make_shared<signal_t> (signal_t{ "Front.Axle.Speed",// generic_name @@ -1232,7 +1232,7 @@ application_t::application_t() })} } // end signals vector })} // end message_definition entry -, {std::make_shared<message_definition_t>(message_definition_t{"j1939",65253,"HOURS",8,false,message_format_t::J1939,frequency_clock_t(5.00000f),true, +, {std::make_shared<message_definition_t>(message_definition_t{"j1939",65253,"HOURS",8,18,frequency_clock_t(5.00000f),true, { // beginning signals vector {std::make_shared<signal_t> (signal_t{ "Eng.Total.Hours.Of.Operation",// generic_name @@ -1280,7 +1280,7 @@ application_t::application_t() })} } // end signals vector })} // end message_definition entry -, {std::make_shared<message_definition_t>(message_definition_t{"j1939",65262,"ET1",8,false,message_format_t::J1939,frequency_clock_t(5.00000f),true, +, {std::make_shared<message_definition_t>(message_definition_t{"j1939",65262,"ET1",8,18,frequency_clock_t(5.00000f),true, { // beginning signals vector {std::make_shared<signal_t> (signal_t{ "Eng.Coolant.Temp",// generic_name @@ -1701,5 +1701,3 @@ const std::string application_t::get_diagnostic_bus() const { return "hs"; } - - diff --git a/low-can-binding/binding/low-can-cb.cpp b/low-can-binding/binding/low-can-cb.cpp index 32fc83d2..c677b172 100644 --- a/low-can-binding/binding/low-can-cb.cpp +++ b/low-can-binding/binding/low-can-cb.cpp @@ -102,7 +102,7 @@ int read_message(sd_event_source *event_source, int fd, uint32_t revents, void * std::shared_ptr<message_t> message = s->read_message(); // Sure we got a valid CAN message ? - if (! message->get_id() == 0 && ! message->get_length() == 0 && message->get_msg_format() != message_format_t::INVALID) + if (! message->get_id() == 0 && ! message->get_length() == 0 && !(message->get_flags()&INVALID_FLAG)) { push_n_notify(message); } @@ -515,7 +515,7 @@ static int send_frame(struct canfd_frame& cfd, const std::string& bus_name, sock } } */ -static int send_message(message_t *message, const std::string& bus_name, socket_type type) +static int send_message(message_t *message, const std::string& bus_name, uint32_t flags) { if(bus_name.empty()) { @@ -530,12 +530,12 @@ static int send_message(message_t *message, const std::string& bus_name, socket_ } - if(type == socket_type::BCM) + if(flags&BCM_PROTOCOL) { return low_can_subscription_t::tx_send(*cd[bus_name], message, bus_name); } #ifdef USE_FEATURE_J1939 - else if(type == socket_type::J1939) + else if(flags&J1939_PROTOCOL) { return low_can_subscription_t::j1939_send(*cd[bus_name], message, bus_name); } @@ -547,7 +547,7 @@ static int send_message(message_t *message, const std::string& bus_name, socket_ } -static void write_raw_frame(afb_req_t request, const std::string& bus_name, message_t *message, struct json_object *can_data, socket_type type) +static void write_raw_frame(afb_req_t request, const std::string& bus_name, message_t *message, struct json_object *can_data, uint32_t flags) { struct utils::signals_found sf; @@ -557,7 +557,7 @@ static void write_raw_frame(afb_req_t request, const std::string& bus_name, mess if( !sf.signals.empty() ) { AFB_DEBUG("ID WRITE RAW : %d",sf.signals[0]->get_message()->get_id()); - if(type == socket_type::BCM) + if(flags&BCM_PROTOCOL) { if(sf.signals[0]->get_message()->is_fd()) { @@ -573,12 +573,12 @@ static void write_raw_frame(afb_req_t request, const std::string& bus_name, mess } if((message->get_length()> 0 && ( - ((type == socket_type::BCM) && ( + ((flags&BCM_PROTOCOL) && ( (message->get_length() <= CANFD_MAX_DLEN * MAX_BCM_CAN_FRAMES && message->get_flags() & CAN_FD_FRAME) || (message->get_length() <= CAN_MAX_DLEN * MAX_BCM_CAN_FRAMES && !(message->get_flags() & CAN_FD_FRAME)) )) #ifdef USE_FEATURE_J1939 - || (message->get_length() <= J1939_MAX_DLEN && type == socket_type::J1939) + || (message->get_length() <= J1939_MAX_DLEN && flags&J1939_PROTOCOL) #endif ))) { @@ -593,11 +593,11 @@ static void write_raw_frame(afb_req_t request, const std::string& bus_name, mess } else { - if(type == socket_type::BCM) + if(flags&BCM_PROTOCOL) { afb_req_fail(request, "Invalid", "Frame BCM"); } - else if(type == socket_type::J1939) + else if(flags&J1939_PROTOCOL) { afb_req_fail(request, "Invalid", "Frame J1939"); } @@ -608,7 +608,7 @@ static void write_raw_frame(afb_req_t request, const std::string& bus_name, mess return; } - if(! send_message(message, application_t::instance().get_can_bus_manager().get_can_device_name(bus_name),type)) + if(! send_message(message, application_t::instance().get_can_bus_manager().get_can_device_name(bus_name),flags)) { afb_req_success(request, nullptr, "Message correctly sent"); } @@ -639,8 +639,8 @@ static void write_frame(afb_req_t request, const std::string& bus_name, json_obj "can_dlc", &length, "can_data", &can_data)) { - message = new can_message_t(0,(uint32_t)id,(uint32_t)length,message_format_t::STANDARD,false,0,data,0); - write_raw_frame(request,bus_name,message,can_data,socket_type::BCM); + message = new can_message_t(0,(uint32_t)id,(uint32_t)length,false,0,data,0); + write_raw_frame(request,bus_name,message,can_data,BCM_PROTOCOL); } #ifdef USE_FEATURE_J1939 else if(!wrap_json_unpack(json_value, "{si, si, so !}", @@ -648,8 +648,8 @@ static void write_frame(afb_req_t request, const std::string& bus_name, json_obj "length", &length, "data", &can_data)) { - message = new j1939_message_t(J1939_MAX_DLEN,(uint32_t)length,message_format_t::J1939,data,0,J1939_NO_NAME,(pgn_t)id,J1939_NO_ADDR); - write_raw_frame(request,bus_name,message,can_data,socket_type::J1939); + message = new j1939_message_t((uint32_t)length,data,0,J1939_NO_NAME,(pgn_t)id,J1939_NO_ADDR); + write_raw_frame(request,bus_name,message,can_data,J1939_PROTOCOL); } #endif else @@ -690,21 +690,21 @@ static void write_signal(afb_req_t request, const std::string& name, json_object encoder(*sig, dynafield_value, &send) : encoder_t::encode_DynamicField(*sig, dynafield_value, &send); - socket_type type = socket_type::INVALID; + uint32_t flags = INVALID_FLAG; if(sig->get_message()->is_j1939()) { - type = socket_type::J1939; + flags = J1939_PROTOCOL; } else { - type = socket_type::BCM; + flags = BCM_PROTOCOL; } // cfd = encoder_t::build_frame(sig, value); message_t *message = encoder_t::build_message(sig,value,false,false); - if(! send_message(message, sig->get_message()->get_bus_device_name(), type) && send) + if(! send_message(message, sig->get_message()->get_bus_device_name(), flags) && send) { afb_req_success(request, nullptr, "Message correctly sent"); } @@ -912,7 +912,7 @@ int init_binding(afb_api_t api) ret = low_can_subscription_t::open_socket(*low_can_j1939, message_definition->get_bus_device_name(), - socket_type::J1939_ADDR_CLAIM); + J1939_ADDR_CLAIM_PROTOCOL); if(ret < 0) { AFB_ERROR("Error open socket address claiming for j1939 protocol"); diff --git a/low-can-binding/binding/low-can-subscription.cpp b/low-can-binding/binding/low-can-subscription.cpp index edc0a0b4..0f4bf0c9 100644 --- a/low-can-binding/binding/low-can-subscription.cpp +++ b/low-can-binding/binding/low-can-subscription.cpp @@ -241,14 +241,12 @@ void low_can_subscription_t::set_index(int index) /// it will open the socket with the required CAN bus device name. /// /// @return INVALID_SOCKET on failure, else positive integer -int low_can_subscription_t::open_socket(low_can_subscription_t &subscription, const std::string& bus_name, socket_type type) +int low_can_subscription_t::open_socket(low_can_subscription_t &subscription, const std::string& bus_name, uint32_t flags) { int ret = -1; if(! subscription.socket_) { - switch (type) - { - case socket_type::BCM: + if(flags&BCM_PROTOCOL) { if( subscription.signal_ != nullptr) { @@ -266,10 +264,9 @@ int low_can_subscription_t::open_socket(low_can_subscription_t &subscription, co ret = subscription.socket_->open(bus_name); } subscription.index_ = (int)subscription.socket_->socket(); - break; } #ifdef USE_FEATURE_J1939 - case socket_type::J1939_ADDR_CLAIM: + else if(flags&J1939_ADDR_CLAIM_PROTOCOL) { pgn_t pgn = J1939_NO_PGN; if(!bus_name.empty()) @@ -279,9 +276,8 @@ int low_can_subscription_t::open_socket(low_can_subscription_t &subscription, co subscription.socket_ = socket; } subscription.index_ = (int)subscription.socket_->socket(); - break; } - case socket_type::J1939: + else if(flags&J1939_PROTOCOL) { pgn_t pgn = J1939_NO_PGN; if(subscription.signal_ != nullptr) @@ -298,15 +294,12 @@ int low_can_subscription_t::open_socket(low_can_subscription_t &subscription, co subscription.socket_ = socket; } subscription.index_ = (int)subscription.socket_->socket(); - break; } #endif - default: + else { AFB_ERROR("Socket format not supported"); return INVALID_SOCKET; - break; - } } } else{ @@ -373,7 +366,7 @@ int low_can_subscription_t::create_rx_filter_j1939(low_can_subscription_t &subsc subscription.signal_= sig; // Make sure that socket is opened. - if(open_socket(subscription,"",socket_type::J1939) < 0) + if(open_socket(subscription,"",J1939_PROTOCOL) < 0) { return -1; } @@ -387,7 +380,7 @@ int low_can_subscription_t::create_rx_filter_j1939(low_can_subscription_t &subsc /// @return 0 if ok else -1 int low_can_subscription_t::create_rx_filter_can(low_can_subscription_t &subscription, std::shared_ptr<signal_t> sig) { - uint32_t flags; + uint32_t flags_bcm; float val; struct timeval freq, timeout = {0, 0}; struct canfd_frame cfd; @@ -414,21 +407,33 @@ int low_can_subscription_t::create_rx_filter_can(low_can_subscription_t &subscri if (is_fd) { - flags = SETTIMER|RX_NO_AUTOTIMER|CAN_FD_FRAME; + flags_bcm = SETTIMER|RX_NO_AUTOTIMER|CAN_FD_FRAME; cfd.len = CANFD_MAX_DLEN; - cm = can_message_t(CANFD_MAX_DLEN,sig->get_message()->get_id(),length_msg,sig->get_message()->get_format(),false,CAN_FD_FRAME,data,0); + cm = can_message_t( CANFD_MAX_DLEN, + sig->get_message()->get_id(), + length_msg, + false, + sig->get_message()->get_flags(), + data, + 0); } else { - flags = SETTIMER|RX_NO_AUTOTIMER; + flags_bcm = SETTIMER|RX_NO_AUTOTIMER; cfd.len = CAN_MAX_DLEN; - cm = can_message_t(CAN_MAX_DLEN,sig->get_message()->get_id(),length_msg,sig->get_message()->get_format(),false,0,data,0); + cm = can_message_t( CAN_MAX_DLEN, + sig->get_message()->get_id(), + length_msg, + false, + sig->get_message()->get_flags(), + data, + 0); } frequency_clock_t f = subscription.event_filter_.frequency == 0 ? subscription.signal_->get_frequency() : frequency_clock_t(subscription.event_filter_.frequency); freq = f.get_timeval_from_period(); - struct bcm_msg bcm_msg = subscription.make_bcm_head(RX_SETUP, subscription.signal_->get_message()->get_id(), flags, timeout, freq); + struct bcm_msg bcm_msg = subscription.make_bcm_head(RX_SETUP, subscription.signal_->get_message()->get_id(), flags_bcm, timeout, freq); std::vector<canfd_frame> cfd_vect = cm.convert_to_canfd_frame_vector(); @@ -499,7 +504,7 @@ int low_can_subscription_t::create_rx_filter(std::shared_ptr<diagnostic_message_ int low_can_subscription_t::create_rx_filter_bcm(low_can_subscription_t &subscription, struct bcm_msg& bcm_msg) { // Make sure that socket is opened. - if(subscription.open_socket(subscription,"",socket_type::BCM) < 0) + if(subscription.open_socket(subscription,"",BCM_PROTOCOL) < 0) {return -1;} // If it's not an OBD2 CAN ID then just add a simple RX_SETUP job @@ -542,7 +547,7 @@ int low_can_subscription_t::tx_send(low_can_subscription_t &subscription, messag std::vector<canfd_frame> cfd_vect = cm->convert_to_canfd_frame_vector(); - if(subscription.open_socket(subscription, bus_name,socket_type::BCM) < 0) + if(subscription.open_socket(subscription, bus_name, BCM_PROTOCOL) < 0) { return -1; } @@ -586,7 +591,7 @@ int low_can_subscription_t::j1939_send(low_can_subscription_t &subscription, mes //struct bcm_msg bcm_msg = subscription.make_bcm_head(TX_SEND, cfd.can_id); //subscription.add_one_bcm_frame(cfd, bcm_msg); - if(subscription.open_socket(subscription, bus_name, socket_type::J1939) < 0) + if(subscription.open_socket(subscription, bus_name, J1939_PROTOCOL) < 0) { return -1; } diff --git a/low-can-binding/binding/low-can-subscription.hpp b/low-can-binding/binding/low-can-subscription.hpp index b5d4f7aa..b152e4b2 100644 --- a/low-can-binding/binding/low-can-subscription.hpp +++ b/low-can-binding/binding/low-can-subscription.hpp @@ -95,7 +95,7 @@ public: static void add_one_bcm_frame(struct canfd_frame& cfd, struct bcm_msg& bcm_msg); static void remove_last_bcm_frame(struct bcm_msg& bcm_msg); - static int open_socket(low_can_subscription_t &subscription, const std::string& bus_name = "", socket_type type = socket_type::INVALID); + static int open_socket(low_can_subscription_t &subscription, const std::string& bus_name = "", uint32_t flags = INVALID_FLAG); int create_rx_filter(std::shared_ptr<signal_t> sig); int create_rx_filter(std::shared_ptr<diagnostic_message_t> sig); diff --git a/low-can-binding/can/can-encoder.cpp b/low-can-binding/can/can-encoder.cpp index 44b5d9b2..37a7b246 100644 --- a/low-can-binding/can/can-encoder.cpp +++ b/low-can-binding/can/can-encoder.cpp @@ -174,20 +174,37 @@ message_t* encoder_t::build_message(const std::shared_ptr<signal_t>& signal, uin std::vector<uint8_t> data; if(signal->get_message()->is_fd()) { - message = new can_message_t(CANFD_MAX_DLEN,signal->get_message()->get_id(),CANFD_MAX_DLEN,signal->get_message()->get_format(),false,CAN_FD_FRAME,data,0); + message = new can_message_t( CANFD_MAX_DLEN, + signal->get_message()->get_id(), + CANFD_MAX_DLEN, + false, + signal->get_message()->get_flags(), + data, + 0); return build_frame(signal,value,message, factor, offset); } #ifdef USE_FEATURE_J1939 else if(signal->get_message()->is_j1939()) { - message = new j1939_message_t(J1939_MAX_DLEN,signal->get_message()->get_length(),signal->get_message()->get_format(),data,0,J1939_NO_NAME,signal->get_message()->get_id(),J1939_NO_ADDR); + message = new j1939_message_t( signal->get_message()->get_length(), + data, + 0, + J1939_NO_NAME, + signal->get_message()->get_id(), + J1939_NO_ADDR); return build_frame(signal,value,message, factor, offset); } #endif else { - message = new can_message_t(CAN_MAX_DLEN,signal->get_message()->get_id(),CAN_MAX_DLEN,signal->get_message()->get_format(),false,0,data,0); + message = new can_message_t(CAN_MAX_DLEN, + signal->get_message()->get_id(), + CAN_MAX_DLEN, + false, + signal->get_message()->get_flags(), + data, + 0); return build_frame(signal,value,message, factor, offset); } } diff --git a/low-can-binding/can/message-definition.cpp b/low-can-binding/can/message-definition.cpp index 064b2c17..407ad750 100644 --- a/low-can-binding/can/message-definition.cpp +++ b/low-can-binding/can/message-definition.cpp @@ -22,16 +22,14 @@ message_definition_t::message_definition_t( const std::string bus, uint32_t id, - bool is_fd, - message_format_t format, + uint32_t flags, frequency_clock_t frequency_clock, bool force_send_changed, const std::vector<std::shared_ptr<signal_t> >& signals) : parent_{nullptr}, bus_{bus}, id_{id}, - is_fd_(is_fd), - format_{format}, + flags_{flags}, frequency_clock_{frequency_clock}, force_send_changed_{force_send_changed}, last_value_{CAN_MESSAGE_SIZE}, @@ -42,8 +40,7 @@ message_definition_t::message_definition_t(const std::string bus, uint32_t id, const std::string name, uint32_t length, - bool is_fd, - message_format_t format, + uint32_t flags, frequency_clock_t frequency_clock, bool force_send_changed, const std::vector<std::shared_ptr<signal_t> >& signals) @@ -52,8 +49,7 @@ message_definition_t::message_definition_t(const std::string bus, id_{id}, name_{name}, length_{length}, - is_fd_(is_fd), - format_{format}, + flags_{flags}, frequency_clock_{frequency_clock}, force_send_changed_{force_send_changed}, last_value_{CAN_MESSAGE_SIZE}, @@ -73,19 +69,12 @@ uint32_t message_definition_t::get_id() const bool message_definition_t::is_fd() const { - return is_fd_; + return (flags_&FD_FRAME); } bool message_definition_t::is_j1939() const { - if(format_ == message_format_t::J1939) - { - return true; - } - else - { - return false; - } + return (flags_&J1939_PROTOCOL); } std::vector<std::shared_ptr<signal_t>>& message_definition_t::get_signals() @@ -108,7 +97,7 @@ uint32_t message_definition_t::get_length() const return length_; } -message_format_t message_definition_t::get_format() const +uint32_t message_definition_t::get_flags() const { - return format_; + return flags_; }
\ No newline at end of file diff --git a/low-can-binding/can/message-definition.hpp b/low-can-binding/can/message-definition.hpp index f39bb71e..13ae2289 100644 --- a/low-can-binding/can/message-definition.hpp +++ b/low-can-binding/can/message-definition.hpp @@ -45,8 +45,7 @@ private: uint32_t id_; ///< id_ - The ID or the PGN (if j1939) of the message.*/ std::string name_; ///< name_ - J1939 PGN name uint32_t length_; ///< length_ - Message data length in bytes. For J1939 message, this is the expected data size - bool is_fd_; /*!< uses_fd_ - Flags to enable an FD CAN message communication*/ - message_format_t format_; ///< format_ - the format of the message's ID.*/ + uint32_t flags_; ///< format_ - the format of the message's ID.*/ frequency_clock_t frequency_clock_; ///< clock_ - an optional frequency clock to control the output of this /// message, if sent raw, or simply to mark the max frequency for custom /// handlers to retrieve.*/ @@ -61,11 +60,10 @@ public: //message_definition_t(const message_definition_t& b); message_definition_t(const std::string bus); message_definition_t(const std::string bus, uint32_t id, frequency_clock_t frequency_clock, bool force_send_changed); - message_definition_t(const std::string bus, uint32_t id, message_format_t format, frequency_clock_t frequency_clock, bool force_send_changed); + message_definition_t(const std::string bus, uint32_t id, uint32_t flags, frequency_clock_t frequency_clock, bool force_send_changed); message_definition_t(const std::string bus, uint32_t id, - bool is_fd, - message_format_t format, + uint32_t flags, frequency_clock_t frequency_clock, bool force_send_changed, const std::vector<std::shared_ptr<signal_t> >& signals); @@ -73,8 +71,7 @@ public: uint32_t id, std::string name, uint32_t length, - bool is_fd, - message_format_t format, + uint32_t flags, frequency_clock_t frequency_clock, bool force_send_changed, const std::vector<std::shared_ptr<signal_t> >& signals); @@ -87,7 +84,7 @@ public: bool is_j1939() const; std::vector<std::shared_ptr<signal_t>>& get_signals(); uint32_t get_length() const; - message_format_t get_format() const; + uint32_t get_flags() const; void set_parent(std::shared_ptr<message_set_t> parent); void set_last_value(std::shared_ptr<message_t> m); diff --git a/low-can-binding/can/message/can-message.cpp b/low-can-binding/can/message/can-message.cpp index 8a04992e..0ef693c7 100644 --- a/low-can-binding/can/message/can-message.cpp +++ b/low-can-binding/can/message/can-message.cpp @@ -35,12 +35,11 @@ can_message_t::can_message_t() can_message_t::can_message_t(uint32_t maxdlen, uint32_t id, uint32_t length, - message_format_t format, bool rtr_flag, uint32_t flags, std::vector<uint8_t>& data, uint64_t timestamp) - : message_t(maxdlen, length, format, data, timestamp, flags), + : message_t(maxdlen, length, flags, data, timestamp), id_{id}, rtr_flag_{rtr_flag} {} @@ -62,7 +61,7 @@ uint32_t can_message_t::get_id() const /// @return True if object correctly initialized and false if not. bool can_message_t::is_correct_to_send() { - if (id_ != 0 && length_ != 0 && format_ != message_format_t::INVALID) + if (id_ != 0 && length_ != 0 && !(flags_&INVALID_FLAG)) { int i; for(i=0;i<length_;i++) @@ -83,9 +82,8 @@ bool can_message_t::is_correct_to_send() std::shared_ptr<can_message_t> can_message_t::convert_from_frame(const struct canfd_frame& frame, size_t nbytes, uint64_t timestamp) { uint32_t maxdlen = 0, length = 0; - uint8_t flags = 0; + uint32_t flags = 0; uint32_t id; - message_format_t format; bool rtr_flag; std::vector<uint8_t> data; @@ -106,17 +104,17 @@ std::shared_ptr<can_message_t> can_message_t::convert_from_frame(const struct ca if (frame.can_id & CAN_ERR_FLAG) { - format = message_format_t::INVALID; + flags = flags|INVALID_FLAG; id = frame.can_id & (CAN_ERR_MASK|CAN_ERR_FLAG); } else if (frame.can_id & CAN_EFF_FLAG) { - format = message_format_t::EXTENDED; + flags = flags|EXTENDED_ID; id = frame.can_id & CAN_EFF_MASK; } else { - format = message_format_t::STANDARD; + flags = flags|STANDARD_ID; id = frame.can_id & CAN_SFF_MASK; } @@ -140,8 +138,8 @@ std::shared_ptr<can_message_t> can_message_t::convert_from_frame(const struct ca length = (frame.len > maxdlen) ? maxdlen : frame.len; /* Flags field only present for CAN FD frames*/ - if(maxdlen == CANFD_MAX_DLEN) - flags = frame.flags & 0xF; + /*if(maxdlen == CANFD_MAX_DLEN) + flags = frame.flags & 0xF;*/ if (data.capacity() < maxdlen) data.reserve(maxdlen); @@ -155,10 +153,10 @@ std::shared_ptr<can_message_t> can_message_t::convert_from_frame(const struct ca }; AFB_DEBUG("Found id: %X, format: %X, length: %X, data %02X%02X%02X%02X%02X%02X%02X%02X", - id, (uint8_t)format, length, data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]); + id, (uint32_t)flags, length, data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]); } - return std::make_shared<can_message_t>(can_message_t(maxdlen, id, length, format, rtr_flag, flags, data, timestamp)); + return std::make_shared<can_message_t>(can_message_t(maxdlen, id, length, rtr_flag, flags, data, timestamp)); } /// @brief Take all initialized class members and build a diff --git a/low-can-binding/can/message/can-message.hpp b/low-can-binding/can/message/can-message.hpp index 75e65c67..769899ea 100644 --- a/low-can-binding/can/message/can-message.hpp +++ b/low-can-binding/can/message/can-message.hpp @@ -39,8 +39,7 @@ class can_message_t : public message_t { public: can_message_t(); - can_message_t(uint32_t maxdlen, uint32_t id, uint32_t length, message_format_t format, bool rtr_flag_, uint32_t flags, std::vector<uint8_t>& data, uint64_t timestamp); - + can_message_t(uint32_t maxdlen, uint32_t id, uint32_t length, bool rtr_flag_, uint32_t flags, std::vector<uint8_t>& data, uint64_t timestamp); uint32_t get_id() const; static std::shared_ptr<can_message_t> convert_from_frame(const canfd_frame& frame, size_t nbytes, uint64_t timestamp); diff --git a/low-can-binding/can/message/j1939-message.cpp b/low-can-binding/can/message/j1939-message.cpp index 2d600a1e..ec65cba4 100644 --- a/low-can-binding/can/message/j1939-message.cpp +++ b/low-can-binding/can/message/j1939-message.cpp @@ -45,13 +45,12 @@ j1939_message_t::j1939_message_t(): * @param addr The address of the message */ j1939_message_t::j1939_message_t(uint32_t length, - message_format_t format, std::vector<uint8_t>& data, uint64_t timestamp, name_t name, pgn_t pgn, uint8_t addr): - message_t(J1939_MAX_DLEN,length, format, data, timestamp, 0), + message_t(J1939_MAX_DLEN, length, J1939_PROTOCOL, data, timestamp), name_{name}, pgn_{pgn}, addr_{addr} @@ -99,18 +98,13 @@ std::shared_ptr<j1939_message_t> j1939_message_t::convert_from_addr(struct socka { int i; uint32_t length = 0; - message_format_t format; + uint32_t flags; std::vector<uint8_t> data_vector; if(nbytes > J1939_MAX_DLEN) { AFB_DEBUG("Unsupported j1939 frame"); - format = message_format_t::INVALID; - } - else - { - //AFB_DEBUG("Got a j1939 frame"); - format = message_format_t::J1939; + return std::make_shared<j1939_message_t>(j1939_message_t()); } length = (uint32_t) nbytes; @@ -126,10 +120,10 @@ std::shared_ptr<j1939_message_t> j1939_message_t::convert_from_addr(struct socka data_vector.push_back(data[i]); }; - AFB_DEBUG("Found pgn: %X, format: %X, length: %X, data %s", - addr.can_addr.j1939.pgn, (uint8_t)format, length, data_string.c_str()); + AFB_DEBUG("Found pgn: %X, length: %X, data %s", + addr.can_addr.j1939.pgn, length, data_string.c_str()); - return std::make_shared<j1939_message_t>(j1939_message_t(J1939_MAX_DLEN,length, format, data_vector, timestamp,addr.can_addr.j1939.name,addr.can_addr.j1939.pgn,addr.can_addr.j1939.addr)); + return std::make_shared<j1939_message_t>(j1939_message_t(length, data_vector, timestamp,addr.can_addr.j1939.name,addr.can_addr.j1939.pgn,addr.can_addr.j1939.addr)); } /// @brief Test if members pgn_ and length are set. diff --git a/low-can-binding/can/message/j1939-message.hpp b/low-can-binding/can/message/j1939-message.hpp index 0d3736f1..9e9cea4a 100644 --- a/low-can-binding/can/message/j1939-message.hpp +++ b/low-can-binding/can/message/j1939-message.hpp @@ -67,7 +67,7 @@ class j1939_message_t : public message_t public: j1939_message_t(); - j1939_message_t(uint32_t maxdlen, uint32_t length, message_format_t format, std::vector<uint8_t>& data, uint64_t timestamp, name_t name, pgn_t pgn, uint8_t addr); + j1939_message_t(uint32_t length, std::vector<uint8_t>& data, uint64_t timestamp, name_t name, pgn_t pgn, uint8_t addr); uint64_t get_name() const; uint32_t get_pgn() const; uint8_t get_addr() const; @@ -78,4 +78,4 @@ class j1939_message_t : public message_t struct sockaddr_can get_sockname(); void set_sockname(struct sockaddr_can sockname); void set_sockname(pgn_t pgn, name_t name, uint8_t addr); -}; +};
\ No newline at end of file diff --git a/low-can-binding/can/message/message.cpp b/low-can-binding/can/message/message.cpp index 497304de..aaab99f5 100644 --- a/low-can-binding/can/message/message.cpp +++ b/low-can-binding/can/message/message.cpp @@ -28,10 +28,9 @@ message_t::message_t() : maxdlen_{0}, length_{0}, - format_{message_format_t::INVALID}, + flags_{INVALID_FLAG}, timestamp_{0}, - sub_id_{-1}, - flags_{0} + sub_id_{-1} {} /** @@ -45,17 +44,15 @@ message_t::message_t() */ message_t::message_t(uint32_t maxdlen, uint32_t length, - message_format_t format, + uint32_t flags, std::vector<uint8_t>& data, - uint64_t timestamp, - uint32_t flags) + uint64_t timestamp) : maxdlen_{maxdlen}, length_{length}, - format_{format}, + flags_{flags}, data_{data}, timestamp_{timestamp}, - sub_id_{-1}, - flags_{flags} + sub_id_{-1} {} /** @@ -163,17 +160,6 @@ uint64_t message_t::get_timestamp() const return timestamp_; } -/** - * @brief Return the format of the message - * - * @return message_format_t The message format - */ -message_format_t message_t::get_msg_format() -{ - return format_; -} - - uint32_t message_t::get_flags() { return flags_; diff --git a/low-can-binding/can/message/message.hpp b/low-can-binding/can/message/message.hpp index 2182fe5b..6cef0185 100644 --- a/low-can-binding/can/message/message.hpp +++ b/low-can-binding/can/message/message.hpp @@ -32,16 +32,17 @@ /** - * @enum message_format_t - * @brief The ID format for a CAN message. + * FLAGS */ -enum class message_format_t { - STANDARD, ///< STANDARD - standard 11-bit CAN arbitration ID. */ - EXTENDED, ///< EXTENDED - an extended frame, with a 29-bit arbitration ID. */ - J1939, ///< J1939 - Format for j1939 messages - INVALID, ///< INVALID - INVALID code used at initialization to signify that it isn't usable'*/ -}; +#define INVALID_FLAG 0x0001 +#define STANDARD_ID 0x0002 +#define EXTENDED_ID 0x0004 +#define BCM_PROTOCOL 0x0008 +#define J1939_PROTOCOL 0x0010 +#define J1939_ADDR_CLAIM_PROTOCOL 0x0020 +#define ISOTP_PROTOCOL 0x0040 +#define FD_FRAME 0x0800 /// @class message_t /// @@ -51,15 +52,14 @@ class message_t { protected: uint32_t maxdlen_; ///< maxdlen_ - Max data length deduce from number of bytes read from the socket.*/ uint32_t length_; ///< length_ - the length of the data array. */ - message_format_t format_; ///< format_ - the format of the message's ID.*/ + uint32_t flags_; ///< format_ - the format mask of the message*/ std::vector<uint8_t> data_; ///< data_ - The message's data field with a size of 8 which is the standard about CAN bus messages.*/ uint64_t timestamp_; ///< timestamp_ - timestamp of the received message*/ int sub_id_; ///< sub_id_ - Subscription index. */ - uint32_t flags_; ///< flags_ - flags of a CAN FD frame. Needed if we catch FD frames.*/ public: message_t(); - message_t(uint32_t maxdlen, uint32_t length, message_format_t format, std::vector<uint8_t>& data, uint64_t timestamp, uint32_t flags); + message_t(uint32_t maxdlen, uint32_t length, uint32_t flags, std::vector<uint8_t>& data, uint64_t timestamp); virtual ~message_t() = default; int get_sub_id() const; @@ -72,7 +72,6 @@ public: void set_data(std::vector<uint8_t> &data); void set_sub_id(int sub_id); void set_timestamp(uint64_t timestamp); - message_format_t get_msg_format(); virtual bool is_set() = 0; virtual std::string get_debug_message() = 0; virtual uint32_t get_id() const = 0; diff --git a/low-can-binding/diagnostic/diagnostic-manager.cpp b/low-can-binding/diagnostic/diagnostic-manager.cpp index ad1f3a7f..5242c5bb 100644 --- a/low-can-binding/diagnostic/diagnostic-manager.cpp +++ b/low-can-binding/diagnostic/diagnostic-manager.cpp @@ -526,7 +526,7 @@ openxc_VehicleMessage diagnostic_manager_t::find_and_decode_adr(std::shared_ptr< /// @return True if the active diagnostic request match the response. bool diagnostic_manager_t::is_diagnostic_response(std::shared_ptr<message_t> m) { - if(m->get_msg_format() == message_format_t::STANDARD || m->get_msg_format() == message_format_t::EXTENDED) + if(m->get_flags()&STANDARD_ID || m->get_flags()&EXTENDED_ID) { if (m->get_id() >= 0x7e8 && m->get_id() <= 0x7ef) return true; diff --git a/low-can-binding/utils/socketcan-j1939/socketcan-j1939.cpp b/low-can-binding/utils/socketcan-j1939/socketcan-j1939.cpp index bb74c766..fdcfe3be 100644 --- a/low-can-binding/utils/socketcan-j1939/socketcan-j1939.cpp +++ b/low-can-binding/utils/socketcan-j1939/socketcan-j1939.cpp @@ -256,7 +256,7 @@ namespace utils */ int socketcan_j1939_t::write_j1939_message(pgn_t pgn, std::vector<uint8_t> &data, uint32_t len_data) { - j1939_message_t msg = j1939_message_t(J1939_MAX_DLEN, len_data, message_format_t::J1939, data, 0, 0, pgn, 0); + j1939_message_t msg = j1939_message_t(len_data, data, 0, 0, pgn, 0); msg.set_sockname(pgn,J1939_NO_NAME,J1939_NO_ADDR); return write_message(msg); } diff --git a/low-can-binding/utils/socketcan.hpp b/low-can-binding/utils/socketcan.hpp index 2a7077eb..6391d011 100644 --- a/low-can-binding/utils/socketcan.hpp +++ b/low-can-binding/utils/socketcan.hpp @@ -28,17 +28,6 @@ #define INVALID_SOCKET -1 -/** - * @enum socket_type - * @brief The type of socket - */ -enum class socket_type { - BCM, ///< BCM - Socket BCM - J1939_ADDR_CLAIM, ///< J1939 - Socket J1939 - J1939, ///< J1939 - Socket J1939 - INVALID -}; - namespace utils { |