You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

62 lines
1.6 KiB

//
// Created by iflytop
//
#pragma once
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include "configs/gconfig.hpp"
#include "iflytopcpp/core/basic/nlohmann/json.hpp"
#include "iflytopcpp/core/driver/socketcan/socket_can.hpp"
#include "iflytopcpp/core/spdlogfactory/logger.hpp"
#include "zlinuxcomponents/iflytop_can_protocol_stack/iflytop_can_protocol_stack.hpp"
#include "zservice_container/zservice_container.hpp"
/**
* @brief
*
* service: CanService
*
* 1. 负责监听,分流IflytopSubDevice的CAN消息和哈美顿的CAN消息
* 2. 负责将CanFrame转换成IflytopCanPacket
*/
namespace iflytop {
using namespace std;
using namespace iflytop;
using namespace core;
using namespace nlohmann;
class CanService : public enable_shared_from_this<CanService> {
ENABLE_LOGGER(CanService);
shared_ptr<SocketCan> m_socketCan;
shared_ptr<GConfig> m_config;
shared_ptr<IflytopCanProtocolStack> m_iflytopCanProtocolStack;
public:
nod::signal<void(shared_ptr<icps::Packet> packet)> onIflytopCanSubDevicePacket;
void initialize();
void startListen();
SocketCan::SocketCanError_t sendPacketToIflytopCanSubDevice(shared_ptr<icps::Packet> icps_packet, int overtime_ms);
private:
void processRx(shared_ptr<SocketCanFrame> frame);
// 处理iflytop子设备的CAN消息
void processIflytopRxPacket(shared_ptr<SocketCanFrame> frame);
// 处理哈美顿的CAN消息
void processHamiltonCanRxPacket(shared_ptr<SocketCanFrame> frame);
private:
};
} // namespace iflytop