07-18-2023 03:07 PM
Which is right back to my server/client suggestion. Since your Python application is the source of the data I would make that the server. I haven't really played around with creating asynchronous tasks in Python but I know it is possible. A basic TCP client in LabVIEW is very easy. If you don't use JSON for the data I would create a simple message header which would consist of Message Type, Data Length and Data. This allows you to add new messages easily if needed. The other solution would to have the Python application broadcast a UDP packet. Again use the basic message header or JSON. This way the application just broadcasts it and any number of applications can listen for the UDP. This will generally be limited to a single subnet since most switches will block UDP broadcast packets from being routed over different subnets. The nice thing about either of these approaches in that your application could have multiple UIs active at one time and also be on different machines.
07-18-2023 06:01 PM - edited 07-18-2023 06:05 PM
Shared memory is a system feature, also under Windows, implemented by the kernel. And the Python shared memory object simply is a means to access that functionality. Since it is a Windows API feature, there would be a way to access it in LabVIEW too, and there have been some libraries in the past that tried to do that. But shared memory is a tricky beast, the API can be taunting to interface too and there can many things go wrong before it works, so if you can find other options, such as network communications, you will yourself spare a lot of pain and trouble by using them and leaving the shared memory for the low level programmers who want to show off or have some really fancy high speed data transfer requirements between one or more processes.
As a little tidbit: if you use TCP/IP with localhost as address on both sides, the Windows socket library will actually use shared memory to connect the endpoints together rather than routing the data through the network adapter drivers down and back up.
07-18-2023 07:00 PM
thanks for your reply!
07-18-2023 07:02 PM
Thank you! I could have a try.
07-18-2023 07:07 PM
Thank you for your reply.But Python will be accepted later. In other words, the labview human-computer interaction interface sends commands or data to Python, and then Python sends it to the next computer for execution. This is equivalent to Python and labview both having to be servers and clients. What can be done about it?
07-18-2023 07:18 PM
Shared memory works not across computers (at least not without very special and expensive special purpose hardware). So if you want to do this between computers and not just on a single computer, you will have to find an IAC method that can go through the network! Anyone saying TCP/IP (or UDP) here?
07-18-2023 07:27 PM - edited 07-18-2023 08:20 PM
Thank you very much for your reply! I get it. Using shared memory can be a hassle. There will be many problems, I will try using TCP/IP now.
07-18-2023 07:38 PM
Also, it sounds like Python and labview can be implemented with shared memory. Could you please tell me how to achieve it in labview? Do you need to use shared variables? But how do you set it up? My attempts to interact with shared variable objects in Python still didn't quite work. Thank you very much indeed!
07-19-2023 09:54 AM
@hallo77 wrote:
Also, it sounds like Python and labview can be implemented with shared memory. Could you please tell me how to achieve it in labview? Do you need to use shared variables? But how do you set it up? My attempts to interact with shared variable objects in Python still didn't quite work. Thank you very much indeed!
No shared variables have nothing to do with Windows shared memory. To do it in LabVIEW you would need to call the Windows API functions CreateFileMapping or OpenFileMapping followed by MapViewOfFile and then direct pointer access to the created map pointer and eventually UnmapViewOfFile and CloseHandle.
But unless you have quite a bit experience in C programming, I would not really recommend you to try to do that.
07-19-2023 10:16 AM
Thank you so much for your generosity in answering my questions. It does seem complicated, and it would take a long time to study it. I'll consider other options now. But this idea, if there is more time and energy in the future, I still want to have a try to break through myself. Thank you very much for your reply!