How to answer that? In principle, it is as thread safe as the underlying instructions are. So if you start multiple threads using libnodave to communicate on the same serial device it will surely fail. On the other hand, it will work over TCP/IP connections to the same PLC/IP address, as TCP/IP separates these connections on system level.
Next, you may want to ask "will multiple instances of programs using libnodave influence each other?" The answer is: "yes, they will in one point: daveDebug is a global variable, so that a program that changes debug level will set it for all programs using libnodave".
So, with respect to that, it is not strictly thread safe. On the other hand, if you leave daveDebug at 0, as is default, it is.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
As I've found out at the moment, this is not fully true.
I'm using libnodave 0.8.4.
I try to open three connections to the same plc over TCP. Therefore I use three instances of daveInterface. If I start three threads at the same time, then mostly ever one thread fails in the function call connectPLC. If I synchronize the call, so that only one call at a time is running, then all works well. Further data exchange works fully unsynchronized.
I've no explanation for this.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I make only a connection and I give the pointer to dc to all thread. Thii is because I can't do more than 2 connection to the PLC.
In any thread I read and write using the same dc pointer. I only must control with a mutex (or something else) that it's done an operation a time.
If u use Jabber or Msn tell me; I'd like to be in contact with someone witch has problem as mines.
(sorry for my english)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Is libnodave thread-safe?
How to answer that? In principle, it is as thread safe as the underlying instructions are. So if you start multiple threads using libnodave to communicate on the same serial device it will surely fail. On the other hand, it will work over TCP/IP connections to the same PLC/IP address, as TCP/IP separates these connections on system level.
Next, you may want to ask "will multiple instances of programs using libnodave influence each other?" The answer is: "yes, they will in one point: daveDebug is a global variable, so that a program that changes debug level will set it for all programs using libnodave".
So, with respect to that, it is not strictly thread safe. On the other hand, if you leave daveDebug at 0, as is default, it is.
As I've found out at the moment, this is not fully true.
I'm using libnodave 0.8.4.
I try to open three connections to the same plc over TCP. Therefore I use three instances of daveInterface. If I start three threads at the same time, then mostly ever one thread fails in the function call connectPLC. If I synchronize the call, so that only one call at a time is running, then all works well. Further data exchange works fully unsynchronized.
I've no explanation for this.
Luca_TGMX (luca_tgmx@jabber.org)
You can use the same connection for every thread. You only need to give them the dc pointer.
For me it work.
What do mean by "connection", a TCP/IP connection or a daveConnection structure?
Each thread MUST have it's own daveConnection.
Thomas
Luca_TGMX
Jabber: (luca_tgmx@jabber.org)
Msn: (luca_tgmx@hotmail.com)
I make only a connection and I give the pointer to dc to all thread. Thii is because I can't do more than 2 connection to the PLC.
In any thread I read and write using the same dc pointer. I only must control with a mutex (or something else) that it's done an operation a time.
If u use Jabber or Msn tell me; I'd like to be in contact with someone witch has problem as mines.
(sorry for my english)
Hello Luca,
Are you italian isn't it? Me too, but write in english for other users.
I tried to create the same behavior of your post but i got no result :(
I have the -5 error on the first thread and debug show:
"IF1 *** no DLE before send.
IF1 *** _daveSendMessageMPI error in _daveSendDialog.
"
Where could be the mistake?
Thanks for your time
Michele