Giter Club home page Giter Club logo

canmsg_pack_unpack_by_given_dbc's Introduction

CANMSG PACK AND UNPACK BY DBC

Description

This package is used to transform the values to can messages or reverse by the dbc added.

Project Structure

dbc_file_analysis.cpp & dbc_file_analysis.h

IT has a singleton class named DbcAnalysis which used to analysis the DBC files to the info needed.

/**
* Singleton interface.
* @return [DbcAnalysis]
*/
static DbcAnalysis *getInstance();
/**
* Print the information of all the messages and the signals found from the DBC files.
*/
void printMessages();
/**
* This method is used to execute the analysis action.
*/
void analysisFiles();
/**
* And one DBC file.
*/
void addOneDbcFile(const std::string &filePath);
/**
* Get the map of the can message list.
* @return [map<id, message>] the map of the messages.
*/
std::map<long, Message>& getMessages();

dbc_canmsg_unpack.cpp & dbc_canmsg_unpack.h

Unpack the can message to values.

/** the dbc unpack used to transform the can msg to value
* @param in_ [struct Message] the message that you want to unpack
* @param in_ [struct Canmsg] the canmsg
* @param in_ [unsigned int] the size of the value list
* @param out [double array] the array of the values
*/
void unpackCanmsg (const Message &m, const Canmsg &msg, const size_t valueSize, double *value);
/**
* pack one Signal
* @param in_ [struct Signal] the Signal that you want to unpack
* @param in_ [unsigned char array] the data array of the can msg
* @return [double] the value that you unpack from the Signal
*/
real64_T unpackSignal (const Signal &s, const uint8_T *data);

dbc_canmsg_pack.cpp & dbc_canmsg_pack.h

Pack the value to can message.

/** the dbc pack used to transform the value to can msg
* @param in_ [struct Message] the message that you want to pack
* @param in_ [unsigned int] the size of the value list
* @param in_ [float array] the array of the values
* @param out [struct Canmsg] the canmsg
*/
void packCanmsg (const Message &m, const size_t &valueSize, const double *value, Canmsg *msg);
/**
* pack one Signal
* @param in_ [struct Signal] the Signal that you want to pack
* @param in_ [double] the value that you want to pack in_ the Signal
* @param out [unsigned char array] the data array of the can msg
*/
void packSignal (const Signal &s, const double &value, uint8_T *data);

canmsg_define.h

struct define. util.h Tool box.

HOW TO USE

// the more than one dbc files
dbc_analysis::DbcAnalysis::getInstance()->addOneDbcFile(filePaath);
// Analysis the files.
dbc_analysis::DbcAnalysis::getInstance()->analysisFiles();
// Check the analysis result. If need.
dbc_analysis::DbcAnalysis::getInstance()->printMessages();
// get one message by id
Message canMsgStruct = dbc_analysis::DbcAnalysis::getInstance()->getMessages()[id];
// pack
double valueIn[4] = {10, 200, 19, 37};
Canmsg msg = {0};
can_util::packCanmsg(canMsgStruct, 4, valueIn, msg);
// pack end
// unpack
double valueOut[4];
msg = {0};
msg.id = 1280;
msg.length = 8;
msg.data[0] = 136;
msg.data[1] = 19;
can_util::unpackCanmsg(canMsgStruct, msg, 4, valueOut);
// unpack end

canmsg_pack_unpack_by_given_dbc's People

Contributors

fengd avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.