Skip to content

Commit 16ae99e

Browse files
committed
remove inline from handle map, make error text function a member method
1 parent 8ae97c0 commit 16ae99e

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

src/include/CanVendorSystec.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ struct CanVendorSystec : CanDevice {
4545

4646
CanReturnCode init_can_port();
4747
static std::mutex m_handles_lock;
48+
static std::unordered_map<int, tUcanHandle> m_handle_map;
4849

4950
inline void map_module_to_handle(int module, tUcanHandle handle) { m_handle_map[module] = handle; }
5051
inline int erase_module_handle(int module) { return m_handle_map.erase(module); }
5152

52-
// TODO i don't like this too much
53-
inline static std::unordered_map<int, tUcanHandle> m_handle_map = {};
53+
std::string UsbCanGetErrorText( long err_code );
5454
};
5555

5656
#endif // SRC_INCLUDE_CANVENDORSYSTEC_H_

src/main/CanVendorSystec.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <string>
88

99
std::mutex CanVendorSystec::m_handles_lock;
10-
std::string UsbCanGetErrorText( long err_code ); // forward declaration
10+
std::unordered_map<int, tUcanHandle> CanVendorSystec::m_handle_map;
1111

1212
CanVendorSystec::CanVendorSystec(const CanDeviceArguments& args)
1313
: CanDevice("systec", args) {
@@ -64,7 +64,7 @@ CanReturnCode CanVendorSystec::init_can_port() {
6464
map_module_to_handle(m_module_number, can_module_handle);
6565
} else { // find existing handle of module
6666
can_module_handle = pos->second;
67-
LOG(Log::WRN, CanLogIt::h()) << "trying to open a can port which is in use, reuse handle, skipping UCanDeinitHardware";
67+
LOG(Log::WRN, CanLogIt::h()) << "trying to open a can port which is in use, reuse handle, skipping UCanDeinitHardware";
6868
}
6969

7070
systec_call_return = ::UcanInitCanEx2(can_module_handle, m_channel_number, &initialization_parameters);
@@ -224,9 +224,9 @@ int CanVendorSystec::SystecRxThread()
224224
{
225225
BYTE status;
226226
tCanMsgStruct read_can_message;
227-
LOG(Log::DBG, CanLogIt::h()) << "SystecRxThread Started. m_receive_thread_flag = [" << this->m_receive_thread_flag <<"]";
228-
while (this->m_receive_thread_flag) {
229-
status = UcanReadCanMsgEx(this->m_UcanHandle, (BYTE *)&this->m_channel_number, &read_can_message, NULL);
227+
LOG(Log::DBG, CanLogIt::h()) << "SystecRxThread Started. m_receive_thread_flag = [" << m_receive_thread_flag <<"]";
228+
while (m_receive_thread_flag) {
229+
status = UcanReadCanMsgEx(m_UcanHandle, (BYTE *)&m_channel_number, &read_can_message, NULL);
230230
switch (status) {
231231
case USBCAN_WARN_SYS_RXOVERRUN: [[ fallthrough ]];
232232
case USBCAN_WARN_DLL_RXOVERRUN: [[ fallthrough ]];
@@ -239,12 +239,12 @@ int CanVendorSystec::SystecRxThread()
239239
// id, data, flags
240240
CanFrame can_msg_copy(read_can_message.m_dwID, data, read_can_message.m_bFF);
241241
// TODO the read_can_message contains a DWORD m_dwTime "receipt time in ms"
242-
this->received(can_msg_copy);
243-
// this->m_statistics.onReceive( read_can_message.m_bDLC );
244-
// this->m_statistics.setTimeSinceReceived();
242+
received(can_msg_copy);
243+
// m_statistics.onReceive( read_can_message.m_bDLC );
244+
// m_statistics.setTimeSinceReceived();
245245

246246
// we can reset the reconnectionTimeout here, since we have received a message
247-
// this->resetTimeoutOnReception();
247+
// resetTimeoutOnReception();
248248
break;
249249
}
250250
case USBCAN_WARN_NODATA:
@@ -264,7 +264,7 @@ int CanVendorSystec::SystecRxThread()
264264
return 0;
265265
}
266266

267-
std::string UsbCanGetErrorText( long err_code ){
267+
std::string CanVendorSystec::UsbCanGetErrorText( long err_code ) {
268268
switch( err_code ){
269269
case USBCAN_SUCCESSFUL: return("success");
270270

0 commit comments

Comments
 (0)