markdown SocketCan-OpenXC.md

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown SocketCan-OpenXC.md相关的知识,希望对你有一定的参考价值。

This is my notes from reviewing the OpenXC and options to integrate support for SocketCAN.

The base idea is to adapt OpenXC platform layer to work with the socket CAN interface. The OpneXC platform layer implements the respective canread function to receive the can data and pack them in the can message format
The following link has the reference implementation to receive the data from socketcan https://github.com/yuichi-kusakabe/AGL-CAN-binder/blob/f2db2a9fe44ddde40b8c2ca30e7a93fdc667c897/src/socketcan_raw.c
The module expose the socketcan_read which reads the messages formats the message in can_frame format as specified by /linux/can.h
#1. Read the CAN message data int socketcan_read(int fd, struct can_frame frame, struct timeval tm)
/vi_firmware.cpp
Source : https://github.com/openxc/vi-firmware
The OpneXC platform layer implements the respective canread function to receive the can data and pack them in the can message format
The platform specific canread implementation to call the socket_canread and covert the message pack to the candata structure as defined by OpenXC and push the message pack to receiveQueue.
Ref : src/platform/pic32/canread.cp
  
    CanMessage message = receiveCanMessage(bus);  //need to perform socketcanread
    if(!QUEUE_PUSH(CanMessage, &bus->receiveQueue, message)) {
Now this function to be called periodically which will dequeue the messages from the receiveQueue and calls the decodeCanMessage in the signal.cpp file autogenerated.
   
    void receiveCan(Pipeline* pipeline, CanBus* bus) {
        if(!QUEUE_EMPTY(CanMessage, &bus->receiveQueue)) {
           CanMessage message = QUEUE_POP(CanMessage, &bus->receiveQueue);
           signals::decodeCanMessage(pipeline, bus, &message);
           if(bus->passthroughCanMessages) {
                 openxc::can::read::passthroughMessage(bus, &message, getMessages(),
                 getMessageCount(), pipeline);
    }

     bus->lastMessageReceived = time::systemTimeMs();
     ++bus->messagesReceived;

     diagnostics::receiveCanMessage(&getConfiguration()->diagnosticsManager,
             bus, &message, pipeline);
 }
}
If the message processing configuration is default pass through then the decoded message will be published using
   void openxc::can::read::passthroughMessage(CanBus* bus, CanMessage* message,
    {

      .....
       vehicleMessage.can_message.data.size = adjustedSize;
     memcpy(vehicleMessage.can_message.data.bytes, message->data,
             adjustedSize);

     pipeline::publish(&vehicleMessage, pipeline);
 }
}
Modify the pipleine to pass this message to applicaiton layers
 void openxc::pipeline::publish(openxc_VehicleMessage* message,
     Pipeline* pipeline) {
 ...
 ...

     switch(message->type) {
     case openxc_VehicleMessage_Type_SIMPLE:
         messageClass = MessageClass::SIMPLE;
         matched = true;
         break;
     case openxc_VehicleMessage_Type_CAN:
         messageClass = MessageClass::CAN;
         matched = true;
         break;
   ....
   ...

     case openxc_VehicleMessage_Type_CONTROL_COMMAND:
         break;
     }
      if(matched) {
         sendMessage(pipeline, payload, length, messageClass);
      } else {
         debug("Trying to serialize unrecognized type: %d", message->type);
     }
    }
The current implementation of OpenXC serialize the message structure to
string int openxc::payload::serialize(openxc_VehicleMessage* message,
•	and send the data using the BT /USB/Network etc....
•	In our usecases we will pass this data to the CDL.

    void openxc::pipeline::sendMessage(Pipeline* pipeline, uint8_t* message,
       int messageSize, MessageClass messageClass) {
       sendToUsb(pipeline, message, messageSize, messageClass);
       #ifdef TELIT_HE910_SUPPORT
       sendToTelit(pipeline, message, messageSize, messageClass);
       #elif defined BLE_SUPPORT

以上是关于markdown SocketCan-OpenXC.md的主要内容,如果未能解决你的问题,请参考以下文章

markdown转换为图片

转换rst到markdown总结

markdown [Markdown HowTo]作为Markdown语法的秘籍

python markdown干啥用的

markdown前端渲染

如何用markdown生成目录