2 Public Function Message(
gclib As Gclib)
3 Console.WriteLine(
"***************************************************************")
4 Console.WriteLine(
"Example GMessage() usage")
5 Console.WriteLine(
"***************************************************************")
9 'This program will force one
message to appear as two separate packets.
11 "MG ""WORLD """ + vbCr +
14 gclib.
GCommand(
"XQ")
'Begins execution Of program On controller
19 'It Is important to note that a
message can be too large to read in one
20 'GMessage() call. Keep calling GMessage() while there are no errors to
23 'While still receiving messages
24 buf = gclib.GMessage()
26 For b = 0 To buf.Length - 1 'While
message characters are in the buffer
28 msg += buf(b)
'Copy chars from buffer To message
30 'If the
message ends in
"\r\n" it Is ready to be terminated
31 If (msg.Length > 2) AndAlso (msg(msg.Length - 1) = vbLf) AndAlso (msg(msg.Length - 2) = vbCr) Then
32 Console.WriteLine(msg)
41 'Downloads program to the controller
53 gclib.GCommand("XQ") 'Begins execution Of program On controller
55 'Lines returned by GMessage() can be one of three types
56 '1) Standard Lines begin with a space (" ")
57 '2) Crashed code begins with a question mark ("?")
58 '3) Trace Lines begin with a line number ("1,6,15...")
60 'While still receiving messages
61 buf = gclib.GMessage()
63 For b = 0 To buf.Length - 1 'While message characters are in the buffer
65 msg += buf(b) 'Copy chars from buffer To message
67 'If the message ends in "\r\n" its ready to be terminated
68 If (msg.Length > 2) AndAlso (msg(msg.Length - 1) = vbLf) AndAlso (msg(msg.Length - 2) = vbCr) Then
70 If (msg(0) = " ") Then 'Standard Lines begin with a space (" ")
71 Console.Write("Standard Line: ")
72 ElseIf (msg(0) = "?") Then 'Crashed code begins with a question mark ("?")
73 Console.Write("Crashed Code: ")
74 Else 'Trace Lines begin with a line number ("1,6,15...")
75 Console.Write("Trace Line: ")
77 Console.WriteLine(msg)
81 buf = gclib.GMessage()
84 Return Examples.GALIL_EXAMPLE_OK
string GCommand(string Command, bool Trim=true)
Used for command-and-response transactions.
void GProgramDownload(string program, string preprocessor="")
Allows downloading of a DMC program from a string buffer.
Provides a class that binds to gclib's unmanaged dll. Wraps each call and provides a more user-friend...
GCLIB_DLL_EXPORTED GReturn GCALL GCommand(GCon g, GCStringIn command, GBufOut buffer, GSize buffer_len, GSize *bytes_returned)
Performs a command-and-response transaction on the connection.
GCLIB_DLL_EXPORTED GReturn GCALL GMessage(GCon g, GCStringOut buffer, GSize buffer_len)
Provides access to unsolicited messages from the controller.
GCLIB_DLL_EXPORTED GReturn GCALL GProgramDownload(GCon g, GCStringIn program, GCStringIn preprocessor)
Downloads a program to the controller's program buffer.
GReturn message(GCon g)
Demonstrates how to receive messages from the controller and detect differences in Trace and crashed ...