2 Public Function IP_Assigner(
gclib As Gclib, serial_num As String, address As Byte) As Integer
3 Dim controller_found As Boolean = False
4 Dim requests() As String
6 Do 'Loop while no requests are found.
7 Console.WriteLine("Searching...")
9 'Listen for ~5 secods for controllers requesting IP addresses.
12 For Each request In requests
13 Console.WriteLine(request)
15 Loop While (requests.Count() < 1)
17 For Each request In requests
18 Dim controller_params() As String = request.Split({
", "}, StringSplitOptions.None)
20 'Parameters are ordered as
21 '[Model #], [Serial #], [MAC Address], [Connection Name], [IP Address]
23 If (controller_params.Count() < 5) Then
24 Console.WriteLine(
"Unexpected controller format")
25 Return GALIL_EXAMPLE_ERROR
28 Dim mac As String = controller_params(2)
29 Dim ip As String = controller_params(4)
31 'If controller contains the user entered serial number
32 If (serial_num = controller_params(1)) Then
33 Console.WriteLine("Controller Match Found")
34 controller_found = True
36 'Splits the found ip address into individual bytes
37 Dim ip_bytes() As String = ip.Split(".")
39 'Rebuild the ip address using the user provided address as the last
byte
40 Dim new_ip = $"{ip_bytes(0)}.{ip_bytes(1)}.{ip_bytes(2)}.{address}
"
42 'Assign the New ip address to the controller
43 gclib.GAssign(new_ip, mac)
45 'Open a connection at the New ip address
48 'Burns the newly assigned ip address to non-volatile EEPROM memory
51 Console.WriteLine("IP Address assigned
")
53 'Write the connection string to the console
54 Console.WriteLine(gclib.GInfo())
60 If Not controller_found Then
61 Console.Write("No controller matched the entered serial number
")
64 Return GALIL_EXAMPLE_OK
Provides a class that binds to gclib's unmanaged dll. Wraps each call and provides a more user-friend...
GCLIB_DLL_EXPORTED GReturn GCALL GIpRequests(GCStringOut requests, GSize requests_len)
Uses GUtility(), G_UTIL_GCAPS_IPREQUEST or G_UTIL_IPREQUEST to provide a list of all Galil controller...