05-28-2009 04:29 PM
To all,
Does multi threading needs to be implemented when running multiple ports?
I have created a simulator that sends serial data. I need to run at least 5 ports simultaneoulsy, but it seems not to be working.
I am using an event structurure, and as the device is being called to be sumulated in the event structure, then it opens the port and sends the data continuously.
There is an event for each device.
Thank you
Cosmica
05-28-2009 04:58 PM
05-28-2009 08:31 PM
If I understand you correctly, it won't work the way you are doing it.
If it's in an event structure, only one port can execute -- the one associated with the event.
05-29-2009 01:49 AM
Yes,
If you want to work on 5 ports simulataneously then it should have been executed parellely (well in the parellel while loops), so that events in all the 5 ports can be explored simulataneously.
MRK (CLAD)
05-29-2009 07:17 AM
Thank you all for your responses,
How can multithreading be implemented using event structures with parralel loops?
For instance I have 5 ports, and in each of them I do basic write and reading. Each of the ports are trigger when the user apply a START button(there is a start button for each port, therefore I have 5 events).
Is there any example code I could fine in the Find Examples feature?
Thank you,
Cosmica
05-29-2009 09:43 AM
If you want to start when a user presses a Start button, it is not neccessary to use an event structure.
Just make a while loop for each of the serial ports, with the Start button controling the boolean in the loop.
If the reading/writing is going to be very similar for each of the ports, you may want to look at making some subVIs as well.
05-29-2009 12:29 PM
I have 2 buttons that work with the port:
1. Enable- enable would allow the user to send values
2. Apply - this would update the value to be sent
So, multithreading could be implemented having a loop for each of the ports I need to open?
Thank you,
Cosmica
05-29-2009 06:36 PM
It would really be a good idea to post your code.
From what you have said so far, I don't think you should be using event structures at all. I could be wrong, but it would be easier to tell if we could see your code.