Skip to main content

For most applications, the standard GalilTools communication libray or API (Application Programming Interface) provides the best method of communicating from either a Windows or Linux computer to a Galil controller.  The GalilTools communication library provides calls such as  "Command()" and "ProgramDownload()" that provide a wrapper to make it easier for a programmer to get up and running in their language of choice (C#, C++, VB, LabVIEW, etc...).  The GalilTools communication library handles the lower level driver functions and communication protocols so that the programmer doesn't have to.  However, there are some situations in which it is necessary or required to communicate to a Galil controller without using the GalilTools communication library.  This article will discuss what a user should be aware of when creating their own communication interface.

Part I - Standard Communication

1) Opening a Socket

Most programming languages that have an Ethernet interface have an "OpenSocket" type of function that will handle establishing the UDP or TCP/IP connection.  The arguments will usually be the IP address of the device you are connecting to as well as a port number.  For a standard connection to a Galil controller, the user should connect on port number 23 (Telnet).  Other port numbers are allowed such as those above port 1000 when needed for special applications.  See the IK command for more info.

2) Sending a Command

Once a socket is established, the user will need to send a Galil command as a string to the controller (via the opened socket) followed by a Carriage return (0x0D).

3) Receiving a Response

The controller will respond to that command with a string.  The response of the command depends on which command was sent.  In general, if there is a response expected such as the "TP" Tell Position command.  The response will be in the form of the expected value(s) followed by a Carriage return (0x0D), Line Feed (0x0A), and a Colon (:).  If the command was rejected, the response will be just a question mark (?) and nothing else.  If the command is not expected to return a value, the response will be just the Colon (:).

4) Closing the Socket

The socket should be left open during general operation to send/receive commands.  In order to close the connection, the programming language should have a "CloseSocket" that will close the TCP/IP connection to the controller.

Notes:

1) A single command should not exceed 80 characters, however multiple commands can be grouped together in a single packet by separating them with semicolons.

2) Packet size should not exceed 450bytes

3) See the Appendix of the Application Note to see example packets of sending commands and receiving responses

For the complete Application Note including part 2 on Advanced Communication, go here:

/download/application-note/note4434.pdf