I am integrating gurux.dlms.cpp library into our application which will be simultaneously reading register values from multiple meters. Typically this application will be used for communication with 20 meters but it is possible that number of meters will be 40 or 60. We want meter readout to be as fast as possible therefore we use multiple threads, one thread for each meter / comport. In every thread I am creating separate instances of CGXDLMSClient & CGXCommunication classes. Is gurux library thread-safe ? While browsing through source codes & debugging I found that binary data are saved to "trace.txt" text file. This is done in following static function:
There is not any thread synchronization present (like mutex or critical section), I think this is mistake. I want to ask if there are another possible places of thread synchronization problems in gurux library that need to be taken in consideration ?
You need to create own instance from each CGXDLMSClient for each thread. CGXCommunication is only example to read one client. Gurux.DLMS.cpp don't write anything, so that does not cause any problems.
You need to check the communication part. I believe that you are using TCP/IP connection. If you are you need to create own session for each part.
Use gurux.dlms.cpp in multi-threaded environment
Hi Jan,
You need to create own instance from each CGXDLMSClient for each thread. CGXCommunication is only example to read one client. Gurux.DLMS.cpp don't write anything, so that does not cause any problems.
You need to check the communication part. I believe that you are using TCP/IP connection. If you are you need to create own session for each part.
BR,
Mikko