|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- #include <iostream> /**< std::cout std::cerr std::endl */
- #include <string> /**< std::string */
- #include <memory> /**< std::shared_ptr */
-
- #include "dbcc/signal_delegate.h"
- #include "dbcc/dbc_iterator.h"
- #include "dbcc/signal_processor.h"
-
- const std::string usage = "This parser is meant to be used via CLi at the moment\n"
- "\t./parser <FILE>\n";
-
- class MyDelegate : public ad::dbcc::SignalDecodeDelegate
- {
- virtual void OnDecoded(uint32_t msg_id, const std::string &signal_name, const ad::dbcc::ParsedValue &pv)
- {
- std::cout << "msg: #0x" << std::hex << msg_id << std::dec << ", " << signal_name << " -> pv: " << pv << std::endl;
- }
- };
-
- int main(int argc, char *argv[])
- {
- if (argc < 2)
- {
- std::cout << usage << std::endl;
- return 0;
- }
-
- ad::dbcc::DbcIterator iter(argv[1]);
-
- for (auto msg : iter)
- {
- std::cout << "msg: " << msg.Name() << std::endl;
- }
-
- std::shared_ptr<ad::dbcc::SignalDecodeDelegate> delegate = std::make_shared<MyDelegate>();
-
- uint8_t data[8] = { 0 };
- data[0] = 0x01;
- data[1] = 0xA8;
-
- uint8_t data1[2] = { 0x40, 0x0 };
-
- ad::dbcc::SignalProcessor sp(iter);
-
- sp.RegisterDelegate(578, "ACCAccReqValHSC2", delegate);
- sp.RegisterDelegate(498, "SysBPMHSC2", delegate);
- sp.RegisterDelegate(498, "SysBPMEnbdHSC2", delegate);
-
- sp.DecodeMessage(578, data, 8);
- sp.DecodeMessage(498, data1, 2);
-
- std::cout << "Keep the order stable" << std::endl;
-
- for (auto msg : iter)
- {
- std::cout << "msg: " << msg.Name() << std::endl;
- }
-
- // Unpacked value: -5.1
-
- return 0;
- }
|