Skip to main content
Submitted by SteveG on Mon, 09/29/2008 - 21:16

I ran into an odd bug with Galil Tools, full version. I was unable to connect to a DMC2133 controller with either Smart Terminal or ActiveX. I got an error -29, unable to connect due to lack of handles. Handle A was TCP/IP,B,D,F unused and the other used by UDP. I don't use UDP at all.

Finally traced it down to Galil Tools. If you power cycle the controller, connect with Galil Tools and issue TH you see one TCP/IP handle. Starting a watch does not use a UDP handle. If you use the scope tool, it grabs a UDP handle. Not a problem, but it is not released when you exit or switch to another controller. Oops. To make things more complicated, I had been using several different Galil Tools instances over several days on two controllers. That's probably how a lot of UDP handles got grabbed and orphaned.

Comments 12

Galil_DJR on 09/30/2008 - 10:11

Hello,

You are right, GalilTools does not close UDP handles which it opens. This is an odd thing, but the reasoning is here:

1.) UDP is technically "connectionless". Unlike TCP, there is no protocol for opening and closing a connection. http://en.wikipedia.org/wiki/SYN_(TCP)#Connection_establishment

2.) GalilTools will use the same UDP port for scope on each connection. This means that the handle resource on the controller is reused.

Try this form power cycle:
Connect to controller, Type TH. Note Handle A is used, TCP
Start Scope, Type TH. Note A TCP, B UDP
Close GalilTools
Connect to controller, Type TH. Note A TCP, B UDP
Start Scope, Type TH. Note A TCP, B UDP

So the B handle is reused. Here's a terminal trace:

192.168.1.11, DMC4020 Rev 1.0a1, 457, IHA
TH
CONTROLLER IP ADDRESS 192,168,1,11 ETHERNET ADDRESS 00-50-4C-20-01-C9
IHA TCP PORT 23 TO IP ADDRESS 192,168,1,10 PORT 4198
IHB AVAILABLE
IHC AVAILABLE
IHD AVAILABLE
IHE AVAILABLE
IHF AVAILABLE
IHG AVAILABLE
IHH AVAILABLE
:TH
CONTROLLER IP ADDRESS 192,168,1,11 ETHERNET ADDRESS 00-50-4C-20-01-C9
IHA TCP PORT 23 TO IP ADDRESS 192,168,1,10 PORT 4198
IHB UDP PORT 60000 TO IP ADDRESS 192,168,1,10 PORT 4199 ***SCOPE ON UDP PORT 60000***
IHC AVAILABLE
IHD AVAILABLE
IHE AVAILABLE
IHF AVAILABLE
IHG AVAILABLE
IHH AVAILABLE
:192.168.1.100, RIO47100 Rev 1.0b, 279, IHC ***CONNECT TO SOMETHING ELSE, OR DISCONNECT ***
192.168.1.11, DMC4020 Rev 1.0a1, 457, IHA
TH
CONTROLLER IP ADDRESS 192,168,1,11 ETHERNET ADDRESS 00-50-4C-20-01-C9
IHA TCP PORT 23 TO IP ADDRESS 192,168,1,10 PORT 4203
IHB UDP PORT 60000 TO IP ADDRESS 192,168,1,10 PORT 4199 ***B IS STILL TAKEN ALTHOUGH NOT BEING USED***
IHC AVAILABLE
IHD AVAILABLE
IHE AVAILABLE
IHF AVAILABLE
IHG AVAILABLE
IHH AVAILABLE
:TH
CONTROLLER IP ADDRESS 192,168,1,11 ETHERNET ADDRESS 00-50-4C-20-01-C9
IHA TCP PORT 23 TO IP ADDRESS 192,168,1,10 PORT 4203
IHB UDP PORT 60000 TO IP ADDRESS 192,168,1,10 PORT 4204 ***SCOPE NOW BEING USED, SAME PORT, SAME HANDLE***
IHC AVAILABLE
IHD AVAILABLE
IHE AVAILABLE
IHF AVAILABLE
IHG AVAILABLE
IHH AVAILABLE
:

We have done extensive testing with GalilTools and have not run into full handles issues. Perhaps SmartTerminal, ActiveX, AND GalilTools in concert could have some issues, though I can't think of a scenario offhand.

If you can reproduce the issue, please share the procedure. We can actively close the UDP handle by Galil proprietary measures (IH command), but the UDP standard should not require this.

SteveG on 10/01/2008 - 11:47

Yes, the issue is ActiveX and Galil Tools. When ActiveX connects to a controller using DMCShell1.DMCController = does it use a UDP handle? Since I'm debugging a VB.NET app that still uses ActiveX (for odd, old reasons), there are times when I simply terminate the debugging session rather than using DMCShell1.DMCConnect = False. Would that cause this problem? If so, then it's my own fault.

BTW: I'm not using the .NET API's because I could not find a way to programmatically connect to a controller with a specific IP address. With ActiveX I programmatically find the controller by searching DMCRegister1.IPAddress = . Then I know the controller number to use with the DMCSHell. This is done because only the IP address is unique. The controller number in the registry and even the controller name (using registry or Galil Tools) are not guaranteed to be the same for all PC's that might run the application. If ther is a way to do it with .NET API's that would help in the future.

Thanks

SteveG on 10/01/2008 - 11:54

I just did a test by issuing the command IHT=>-1 to close UDP handles. It worked, but I had to use Galil Tools because Smart Terminal would not connect (full handles). This is rather odd because TH (Galil Tools) showed B handle wasn't being used. Maybe Smart Terminal needs several handles?

Unfortunately, I forgot to capture the Galil Tools log. When this happens again I'll do that and send it to you

Galil_AndyH on 10/01/2008 - 12:05

Check you Ethernet Parameters setup in the Controller Registry.

In SmartTerminal
Tools/Controller Registration/Edit Controller Properties (button)/Ethernet Parameters (tab)

Under the Unsolicited Messages drop-down, you probably have "Open 2nd Handle". If this is the case, Smart Terminal (as well as Active X, .Net, WSDK etc) will open a second handle for unsolicited messages, and therefore requires 2 handles to connect.

Galil_DJR on 10/01/2008 - 12:51

Also, the older drivers require a
DMCShell1.DMCConnect = False
on exit.
Otherwise the handles will fill. This is probably the source of your full handles.

Galil_DJR on 10/01/2008 - 13:11

All of the older stuff (non-GalilTools) uses the windows registry to get connection info. There is no simple way to connect to a generic IP address, in general.

You can set up a "controller 1" with the desired IP address and always connect to that. This would not span various PCs, however, as the windows registry entry would have to be present on all PCs. You can also edit the registry programatically, adding the registry when needed.

With the GalilTools api, of course, this is trivial.

Galil g("192.168.1.1");
g.command("XQ");
//...

SteveG on 10/08/2008 - 11:58

Based on your last response, it looks like there are three ways for a program to interact:

1. ActiveX API's
2. .NET API's
3. GalilTools API

They are not the same (at the program level at least)

Is that correct?

Galil_DJR on 10/08/2008 - 13:11

To add one to your list:
1. ActiveX API's
2. .NET API's
3. GalilTools API
4. DMCwin32.dll (native C library)

1 and 2 are built atop 4. 3 is a brand new API written in C++ using Qt crossplatform libraries. All 4 interfaces have varying syntax.

3 is recommended for all new applications.

SteveG on 10/23/2008 - 14:35

Thanks. I surmised the relationship too. I'll look into the GalilTools API's.

ErikT on 01/23/2009 - 12:07

[quote=DJ]To add one to your list:
1. ActiveX API's
2. .NET API's
3. GalilTools API
4. DMCwin32.dll (native C library)

1 and 2 are built atop 4. 3 is a brand new API written in C++ using Qt crossplatform libraries. All 4 interfaces have varying syntax.

3 is recommended for all new applications.[/quote]

This should be posted front-and-centre on any web pages pertaining to development on the PC for your products - I know it would've saved me a lot of confusion six months ago!

Galil_DJR on 01/23/2009 - 13:06

Note:
"Current Software Package for New Applications"
and
"Other Software Utilities For Windows 98SE / ME / 2000 / XP / Vista"