From 0b941f3f625ea24b63502540c27ee7ba748ab80a Mon Sep 17 00:00:00 2001 From: Anders Sandstrom Date: Thu, 4 Mar 2021 12:11:09 +0100 Subject: [PATCH] Cleanup --- .../src/ecmcCANOpenSDO.cpp | 4 -- .../src/ecmcPluginSocketCAN.c | 7 +--- .../src/ecmcSocketCAN.cpp | 18 +-------- .../src/ecmcSocketCAN.h | 1 - .../src/ecmcSocketCANWrap.cpp | 13 ------- .../src/ecmcSocketCANWrap.h | 8 ---- .../src/ecmcSocketCANWriteBuffer.cpp | 39 ------------------- .../src/ecmcSocketCANWriteBuffer.h | 13 ------- 8 files changed, 2 insertions(+), 101 deletions(-) diff --git a/ecmc_plugin_socketcan/ecmc_plugin_socketcanApp/src/ecmcCANOpenSDO.cpp b/ecmc_plugin_socketcan/ecmc_plugin_socketcanApp/src/ecmcCANOpenSDO.cpp index 6c8896b..abe4254 100644 --- a/ecmc_plugin_socketcan/ecmc_plugin_socketcanApp/src/ecmcCANOpenSDO.cpp +++ b/ecmc_plugin_socketcan/ecmc_plugin_socketcanApp/src/ecmcCANOpenSDO.cpp @@ -120,7 +120,6 @@ void ecmcCANOpenSDO::execute() { printf("readStates_ = WAIT_FOR_REQ_CONF!!!\n"); writeBuffer_->addWriteCAN(&reqDataFrame_); - //writeBuffer_->triggWrites(); } } } @@ -145,8 +144,6 @@ void ecmcCANOpenSDO::newRxFrame(can_frame *frame) { readStates_ = WAIT_FOR_DATA; //Next frame should be data! printf("readStates_ = WAIT_FOR_DATA!!!\n"); writeBuffer_->addWriteCAN(&confReqFrameTg0_); // Send tg0 frame and wait for data, also size must match to go ahead - //writeBuffer_->triggWrites(); - useTg1Frame_ = 1; break; @@ -167,7 +164,6 @@ void ecmcCANOpenSDO::newRxFrame(can_frame *frame) { writeBuffer_->addWriteCAN(&confReqFrameTg0_); useTg1Frame_ = 1; } - //writeBuffer_->triggWrites(); } printf("recivedBytes = %d!!!\n",recivedBytes_); diff --git a/ecmc_plugin_socketcan/ecmc_plugin_socketcanApp/src/ecmcPluginSocketCAN.c b/ecmc_plugin_socketcan/ecmc_plugin_socketcanApp/src/ecmcPluginSocketCAN.c index 444b268..4767b0f 100644 --- a/ecmc_plugin_socketcan/ecmc_plugin_socketcanApp/src/ecmcPluginSocketCAN.c +++ b/ecmc_plugin_socketcan/ecmc_plugin_socketcanApp/src/ecmcPluginSocketCAN.c @@ -164,12 +164,7 @@ double can_connected() { return (double)getSocketCANConnectd(); } -// trigger all writes added to buffer -//double can_trigg_writes() { -// return (double)triggWrites(); -//} - -// trigger all writes added to buffer +// Error during last writes double can_last_writes_error() { return (double)getlastWritesError(); } diff --git a/ecmc_plugin_socketcan/ecmc_plugin_socketcanApp/src/ecmcSocketCAN.cpp b/ecmc_plugin_socketcan/ecmc_plugin_socketcanApp/src/ecmcSocketCAN.cpp index 58ae602..4bd217e 100644 --- a/ecmc_plugin_socketcan/ecmc_plugin_socketcanApp/src/ecmcSocketCAN.cpp +++ b/ecmc_plugin_socketcan/ecmc_plugin_socketcanApp/src/ecmcSocketCAN.cpp @@ -237,22 +237,6 @@ void ecmcSocketCAN::doConnectWorker() { connectPrivate(); } } -// struct byte0 { -// char ccs : 3; -// char reserved : 1; -// char n : 2; -// char e : 1; -// char s : 1; -// } - -// int ecmcSocketCAN::triggWrites() { -// if(!writeBuffer_) { -// return ECMC_CAN_ERROR_WRITE_BUFFER_NULL; -// } - -// writeBuffer_->triggWrites(); -// return 0; -// } int ecmcSocketCAN::getlastWritesError() { if(!writeBuffer_) { @@ -275,7 +259,7 @@ int ecmcSocketCAN::addWriteCAN(uint32_t canId, if(!writeBuffer_) { return ECMC_CAN_ERROR_WRITE_BUFFER_NULL; } - + writeBuffer_->addWriteCAN(canId, len, data0, diff --git a/ecmc_plugin_socketcan/ecmc_plugin_socketcanApp/src/ecmcSocketCAN.h b/ecmc_plugin_socketcan/ecmc_plugin_socketcanApp/src/ecmcSocketCAN.h index b21c2e2..95c9ae5 100644 --- a/ecmc_plugin_socketcan/ecmc_plugin_socketcanApp/src/ecmcSocketCAN.h +++ b/ecmc_plugin_socketcan/ecmc_plugin_socketcanApp/src/ecmcSocketCAN.h @@ -77,7 +77,6 @@ class ecmcSocketCAN : public asynPortDriver { uint8_t data5, uint8_t data6, uint8_t data7); - //int triggWrites(); int getlastWritesError(); void execute(); // ecmc rt loop diff --git a/ecmc_plugin_socketcan/ecmc_plugin_socketcanApp/src/ecmcSocketCANWrap.cpp b/ecmc_plugin_socketcan/ecmc_plugin_socketcanApp/src/ecmcSocketCANWrap.cpp index 9ca116d..0ea1821 100644 --- a/ecmc_plugin_socketcan/ecmc_plugin_socketcanApp/src/ecmcSocketCANWrap.cpp +++ b/ecmc_plugin_socketcan/ecmc_plugin_socketcanApp/src/ecmcSocketCANWrap.cpp @@ -91,19 +91,6 @@ int getlastWritesError() { return 1; } -// int triggWrites() { -// if(can){ -// try { -// return can->triggWrites(); -// } -// catch(std::exception& e) { -// printf("Exception: %s.\n",e.what()); -// return ECMC_PLUGIN_SOCKETCAN_ERROR_CODE; -// } -// } -// return ECMC_PLUGIN_SOCKETCAN_ERROR_CODE; -// } - int execute() { if(can){ can->execute(); diff --git a/ecmc_plugin_socketcan/ecmc_plugin_socketcanApp/src/ecmcSocketCANWrap.h b/ecmc_plugin_socketcan/ecmc_plugin_socketcanApp/src/ecmcSocketCANWrap.h index 4ac3d0e..9456e40 100644 --- a/ecmc_plugin_socketcan/ecmc_plugin_socketcanApp/src/ecmcSocketCANWrap.h +++ b/ecmc_plugin_socketcan/ecmc_plugin_socketcanApp/src/ecmcSocketCANWrap.h @@ -38,14 +38,6 @@ int connectSocketCAN(); */ int getSocketCANConnectd(); -/** \brief Write all buffered writes to CAN - */ -//int triggWrites(); - -/** \brief Busy writing\n - */ -int getWriteBusy(); - /** \brief Get last error from writes\n */ int getlastWritesError(); diff --git a/ecmc_plugin_socketcan/ecmc_plugin_socketcanApp/src/ecmcSocketCANWriteBuffer.cpp b/ecmc_plugin_socketcan/ecmc_plugin_socketcanApp/src/ecmcSocketCANWriteBuffer.cpp index e48957f..2cca81e 100644 --- a/ecmc_plugin_socketcan/ecmc_plugin_socketcanApp/src/ecmcSocketCANWriteBuffer.cpp +++ b/ecmc_plugin_socketcan/ecmc_plugin_socketcanApp/src/ecmcSocketCANWriteBuffer.cpp @@ -31,16 +31,6 @@ void f_worker_write(void *obj) { canObj->doWriteWorker(); } -//void f_worker_trigger(void *obj) { -// if(!obj) { -// printf("%s/%s:%d: Error: Worker trigg thread ecmcSocketCANWriteBuffer object NULL..\n", -// __FILE__, __FUNCTION__, __LINE__); -// return; -// } -// ecmcSocketCANWriteBuffer * canObj = (ecmcSocketCANWriteBuffer*)obj; -// canObj->doTriggerWorker(); -//} - /** ecmc ecmcSocketCANWriteBuffer class */ ecmcSocketCANWriteBuffer::ecmcSocketCANWriteBuffer(int socketId, int cfgDbgMode) { @@ -67,29 +57,13 @@ ecmcSocketCANWriteBuffer::ecmcSocketCANWriteBuffer(int socketId, int cfgDbgMode) if(epicsThreadCreate(threadname.c_str(), 0, 32768, f_worker_write, this) == NULL) { throw std::runtime_error("Error: Failed create worker thread for write()."); } - - //threadname = "ecmc." ECMC_PLUGIN_ASYN_PREFIX".write_trigg"; - //if(epicsThreadCreate(threadname.c_str(), 0, 32768, f_worker_trigger, this) == NULL) { - // throw std::runtime_error("Error: Failed create worker thread for write trigger."); - //} } ecmcSocketCANWriteBuffer::~ecmcSocketCANWriteBuffer() { // kill worker destructs_ = 1; // maybe need todo in other way.. - //doWriteEvent_.signal(); } -//void ecmcSocketCANWriteBuffer::doTriggerWorker() { -// while(true) { -// if(destructs_) { -// return; -// } -// nanosleep(&writePauseTime_,NULL); -// triggWrites(); -// } -//} - // Write socket worker thread (switch between two buffers) void ecmcSocketCANWriteBuffer::doWriteWorker() { while(true) { @@ -253,19 +227,6 @@ int ecmcSocketCANWriteBuffer::switchBuffer() { return 0; } -// Trigger all writes -//int ecmcSocketCANWriteBuffer::triggWrites() { -// -// if(writeBusy_) { -// return ECMC_CAN_ERROR_WRITE_BUSY; -// } -// writeBusy_ = 1; -// switchBuffer(); -// lastWriteSumError_ = 0; -// doWriteEvent_.signal(); // let worker start -// return 0; -//} - // Write to socket int ecmcSocketCANWriteBuffer::writeCAN(can_frame *frame){ diff --git a/ecmc_plugin_socketcan/ecmc_plugin_socketcanApp/src/ecmcSocketCANWriteBuffer.h b/ecmc_plugin_socketcan/ecmc_plugin_socketcanApp/src/ecmcSocketCANWriteBuffer.h index d234845..3188e03 100644 --- a/ecmc_plugin_socketcan/ecmc_plugin_socketcanApp/src/ecmcSocketCANWriteBuffer.h +++ b/ecmc_plugin_socketcan/ecmc_plugin_socketcanApp/src/ecmcSocketCANWriteBuffer.h @@ -59,7 +59,6 @@ class ecmcSocketCANWriteBuffer { void doWriteWorker(); - //void doTriggerWorker(); int addWriteCAN(uint32_t canId, uint8_t len, @@ -75,26 +74,14 @@ class ecmcSocketCANWriteBuffer { int getlastWritesError(); private: - //int triggWrites(); static std::string to_string(int value); int writeCAN(can_frame *frame); int switchBuffer(); int addToBuffer(can_frame *frame); - //void addToBuffer1(can_frame *frame); - //void addToBuffer2(can_frame *frame); int writeBuffer(); - //void writeBuffer1(); - //void writeBuffer2(); int destructs_; int cfgDbgMode_; - //epicsEvent doWriteEvent_; int socketId_; -// struct can_frame txmsgBuffer1_[ECMC_CAN_MAX_WRITE_CMDS]; -// struct can_frame txmsgBuffer2_[ECMC_CAN_MAX_WRITE_CMDS]; -// int writeCmdCounter1_; -// int writeCmdCounter2_; -// epicsMutexId bufferMutex1_; -// epicsMutexId bufferMutex2_; epicsMutexId bufferSwitchMutex_; canWriteBuffer buffer1_; canWriteBuffer buffer2_;