#include #include #include "../common/comm.h" #include "PCANBasic.h" #include "../common/iobuffer.h" #include "../common/sensor_socket.h" #include "radar_sensor.h" #include "message_queue.h" //#define make_int16(h,l) (((int16_t)h)<<8)|l CRadarSensor::CRadarSensor(CMessageQueue* q):_message(q) { _channelReady=false; } inline int16_t make_int16(int8_t h, int8_t l) { int16_t hi = (int16_t)(h & 0x00FF); int16_t low = (int16_t)(l & 0x00FF); return (hi << 8) | low; } void CRadarSensor::Notify(int8_t * buffer,int32_t size) { // std::vector _node; int32_t receivedCnt = size/CAN_MSG_LEN; cannet_frame* p = (cannet_frame*)buffer; auto tick=std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); for(int32_t i=0;i>=8; // radar_info info; //radar_node n; int32_t rid=(id_normal&0x0F0)/0x10; rid-=1; bool bset=(mask&(0x1<range||!bset) { _node[rid].range = range; mask|=(0x1<(std::chrono::system_clock::now().time_since_epoch()).count();; if(tick-_tick>200) if(tick-_tick>200/*&&((mask&0x1F)==0x1F)*/) { _message->WriteSensor(_node,5); mask=0; _tick=tick; } // memset(_info,-1,sizeof(_info)); } //std::cout<(std::chrono::system_clock::now().time_since_epoch()).count();; /* CIOBuffer pBuffer; cannet_frame* frame=reinterpret_cast(pBuffer.Buffer); memset(frame->data,0,sizeof(frame->data)); frame->dlc=2; frame->canid=0x0000; frame->data[0]=0x01; frame->data[1]=0x00; _socket->Write(pBuffer.Buffer,sizeof(cannet_frame)); */ } void CRadarSensor::SetSensorSocket(SensorSocket* can) { _socket=can; } void CRadarSensor::Stop() { _channelReady=false; }