#include "serial.h" #include "message_queue.h" CSerialSensor::CSerialSensor(CMessageQueue* q) :_message(q) { _run = false; } void CSerialSensor::SetSerialSensor(SensorSerial* serial) { _serial = serial; } void CSerialSensor::Start() { if(!_run) { //_thread = std::thread(&CSerialSensor::Run, this); _run = true; } } void CSerialSensor::Run() { uint8_t comment[] = "#01\r"; while (_run) { _serial->Write(comment,4); std::this_thread::sleep_for(std::chrono::milliseconds(1000)); } } void CSerialSensor::Stop() { if (_run) { _run = false; //_thread.join(); } } void CSerialSensor::Notify(uint8_t * buffer,int32_t size) { //+0000000012↙,车辆姿态编码器 u_char Temp = '+'; u_char *p = nullptr; if(_run) { p = (u_char *)strchr((const char *)buffer,Temp); //_message->_Feeddata.steer_angle = strtol((const char *)p + 1,NULL,10); } }