|
@@ -14,6 +14,8 @@
|
|
|
#include <linux/can.h>
|
|
|
#include <linux/can/raw.h>
|
|
|
|
|
|
+#define USE_SHM_SEND_CAN
|
|
|
+
|
|
|
extern setupConfig_t setupConfig;
|
|
|
extern iv::msgunit shmCANSend;
|
|
|
|
|
@@ -29,47 +31,48 @@ CANSend_Consumer::~CANSend_Consumer()
|
|
|
close(s);
|
|
|
}
|
|
|
|
|
|
-//void CANSend_Consumer::run()
|
|
|
-//{
|
|
|
-// uint64_t CANPackageIndex = 0;
|
|
|
-// uint8_t CANPackageChannel;
|
|
|
-// iv::can::canmsg xmsg;
|
|
|
-
|
|
|
-// if(setupConfig.strMemCANSend == "cansend0")
|
|
|
-// CANPackageChannel = 0;
|
|
|
-// else
|
|
|
-// CANPackageChannel = 1;
|
|
|
-
|
|
|
-// while (!QThread::isInterruptionRequested())
|
|
|
-// {
|
|
|
-// pBuffer->Consume_Element_To_CANMsg(xmsg);
|
|
|
-// if(xmsg.rawmsg_size()>0)
|
|
|
-// {
|
|
|
-// //pack
|
|
|
-// xmsg.set_index(CANPackageIndex);
|
|
|
-// xmsg.set_channel(CANPackageChannel);
|
|
|
-// xmsg.set_mstime(QDateTime::currentMSecsSinceEpoch());
|
|
|
-// //send
|
|
|
-// int ndatasize = xmsg.ByteSize();
|
|
|
-// char * strser = new char[ndatasize];
|
|
|
-// std::shared_ptr<char> pstrser;
|
|
|
-// pstrser.reset(strser);
|
|
|
-// if(xmsg.SerializePartialToArray(strser,ndatasize))
|
|
|
-// {
|
|
|
-// iv::modulecomm::ModuleSendMsg(shmCANSend.mpa,strser,ndatasize);
|
|
|
-// }
|
|
|
-// else
|
|
|
-// {
|
|
|
-// std::cout<<"CANSend_Consumer serialize error."<<std::endl;
|
|
|
-// }
|
|
|
-// //clear and update index
|
|
|
-// xmsg.clear_rawmsg();
|
|
|
-// CANPackageIndex++;
|
|
|
-// std::cout<<"send consumer time :"<<(QDateTime::currentMSecsSinceEpoch() - gTime_ms)<<std::endl;
|
|
|
-// }
|
|
|
-// }
|
|
|
-//}
|
|
|
+#ifdef USE_SHM_SEND_CAN
|
|
|
+void CANSend_Consumer::run()
|
|
|
+{
|
|
|
+ uint64_t CANPackageIndex = 0;
|
|
|
+ uint8_t CANPackageChannel;
|
|
|
+ iv::can::canmsg xmsg;
|
|
|
+
|
|
|
+ if(setupConfig.strMemCANSend == "cansend0")
|
|
|
+ CANPackageChannel = 0;
|
|
|
+ else
|
|
|
+ CANPackageChannel = 1;
|
|
|
|
|
|
+ while (!QThread::isInterruptionRequested())
|
|
|
+ {
|
|
|
+ pBuffer->Consume_Element_To_CANMsg(xmsg);
|
|
|
+ if(xmsg.rawmsg_size()>0)
|
|
|
+ {
|
|
|
+ //pack
|
|
|
+ xmsg.set_index(CANPackageIndex);
|
|
|
+ xmsg.set_channel(CANPackageChannel);
|
|
|
+ xmsg.set_mstime(QDateTime::currentMSecsSinceEpoch());
|
|
|
+ //send
|
|
|
+ int ndatasize = xmsg.ByteSize();
|
|
|
+ char * strser = new char[ndatasize];
|
|
|
+ std::shared_ptr<char> pstrser;
|
|
|
+ pstrser.reset(strser);
|
|
|
+ if(xmsg.SerializePartialToArray(strser,ndatasize))
|
|
|
+ {
|
|
|
+ iv::modulecomm::ModuleSendMsg(shmCANSend.mpa,strser,ndatasize);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ std::cout<<"CANSend_Consumer serialize error."<<std::endl;
|
|
|
+ }
|
|
|
+ //clear and update index
|
|
|
+ xmsg.clear_rawmsg();
|
|
|
+ CANPackageIndex++;
|
|
|
+// std::cout<<"send a msg:"<<QDateTime::currentMSecsSinceEpoch()<<std::endl;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+#else
|
|
|
void CANSend_Consumer::run()
|
|
|
{
|
|
|
iv::can::canraw xraw;
|
|
@@ -123,5 +126,7 @@ void CANSend_Consumer::run()
|
|
|
{
|
|
|
perror("write");
|
|
|
}
|
|
|
+// std::cout<<"send a msg:"<<(int)frame.data[2]<<" time:"<<QDateTime::currentMSecsSinceEpoch()<<std::endl;
|
|
|
}
|
|
|
}
|
|
|
+#endif
|