Hi there,
Tell us when you have it tested with two devices queried in parallel !
I have it working for a few days now (only in C# for the moment)
Let me try to trace de callstack when the '
Create devices' button is pressed :
btncreate_Click()
calls CreateDevice() for Device1
calls CreateDevice() for Device2
CreateDevice()
calls PrologixDevice()
PrologixDevice()
calls OpenComm()
Since both devices are connected to the same Prologix (like) adapter, they must share the same COM port.
If I run up the stack,
- From OpenComm() of Device 2 I could not acces the port already open by Device 1
If I create the commport (new SerialPort()) with the same name as Device 1, it fails when trying to open it.
If I Don't open it, it fails too!
I had the same problem of accessibility of the comport member of the PrologixDevice class all the way up the call stack.
(maybe due to my poor knowledge in OOP)
Here is the solution I came to (mainly suggested by
pwlps if I didn't misunderstand him...) :
- Add a static flag to the PrologixDevice class this will tell us when the port has been open (by Device1)
private static bool PortOpen = false; -> Accessible from both devices
- Change commport definition to static so that it is common to both devices
protected static SerialPort commport = null;
- Rearrange
OpenComm() to
Device 1 : Execute in full and set PortOpen flag
Device 2 : Get gpibaddr and return without opening the port (if PortOpen is true)
The drawback is that if one would like to use 2 separate Prologix adapters, it would'nt work, since the commport is now common to all Prologix instances!
Not sure I did it the right way
but it works.
P.S.Don't be ashamed, I am a beer (and Scotch Whisky) drinker too
Regards