![]() |
gclib 2.5.0
Galil Communications Library
|
A core feature of gclib is the ability to connect to a controller over ethernet, serial, or PCI, using a single connection API.
C Use gclib_addresses() to see the different addresses that are available.
If using an ethernet controller that doesn't have an IP address yet, it will show up in gclib_ip_requests(). Use gclib_assign_ip() to give the controller an IP. If successful, the controller will begin showing up in gclib_addresses() under the new address.
C++ Use gclib::addresses() to see the different addresses that are available.
If using an ethernet controller that doesn't have an IP address yet, it will show up in gclib::ip_requests(). Use gclib::assign_ip() to give the controller an IP. If successful, the controller will begin showing up in gclib::addresses() under the new address.
LabVIEW Use addresses to see the different addresses that are available.
If using an ethernet controller that doesn't have an IP address yet, it will show up in ip requests. Use assign ip to give the controller an IP. If successful, the controller will begin showing up in addresses under the new address.
> .\connection.exe 192.168.0.40 Address: 192.168.0.40 Revision: DMC4040 Rev 1.3i Serial: 10601
C++ To use a controller with gclib, pass the address and an optional baud rate (for serial connections) to gclib::Controller() to receive a controller object.
> .\connection.exe 192.168.0.40 Address: 192.168.0.40 Revision: DMC4040 Rev 1.3i Serial: 10601
LabVIEW To use a controller with gclib, first pass the address to open to receive a handle to the connection, which will be used in all gclib calls which operate on that connection. After you are done, close the connection with close.
C To issue commands, use gclib_command() with an open connection. The following example uses gclib_command() to implement a basic terminal.
C++ To issue commands, use gclib::Controller::command() with an open connection. The following example uses gclib::Controller::command() to demonstrate using templated return types.
LabVIEW To issue commands, use command with an open connection.
C All gclib functions provide a gclib_result value to indicate the error, with zero (GCLIB_SUCCESS) indicating success. Use gclib_error() to get a string description of the error.
C++ If the underlying C API returns an error, a gclib::error exception will be thrown with the error code in gclib::error::result(). Use gclib::error::what() to get an error string, if available.
C Use gclib_program() to get the controller's program, and use gclib_set_program() to set it.
Use gclib_array() to get an array from the controller, and use gclib_set_array() to set it. Use the start and end arguments to transfer only a subset of the array.
C++ Use gclib::Controller::program() to get the controller's program, and use gclib::Controller::set_program() to set it.
Use gclib::Controller::array() to get an array from the controller, and use gclib::Controller::set_array() to set it. Use the start and end arguments to transfer only a subset of the array.
LabVIEW Use program to get the controller's program, and use set program to set it.
Use array to get an array from the controller, and use set array to set it.
The unsolicited data API can be used in blocking mode or callback mode.
Blocking mode is simpler to use, but has tradeoffs. If you want unsolicited data as soon as it arrives, you must block the thread to wait for it, which may not be ideal. If you want to keep the thread running, then you must periodically check for queued unsolicited data, which can add unwanted latency.
Callback mode allows your thread to stay running while enabling immediate response to unsolicited data. When data arrives, your callback function will be invoked on a separate, dedicated thread. Due to this, callback mode can be more complicated to use if you are not familiar with thread synchronization.
C
For a full list of data record fields, see the Data Record API.
C++
For a full list of data record fields, see gclib::DataRecord.
LabVIEW To receive unsolicited data, you must first subscribe to the desired unsolicited data using subscribe messages, subscribe interrupts, or subscribe data records.
Once subscribed, use message, interrupt, and data record alongside an optional timeout to wait for unsolicited data.
Galil Connect allows gclib to issue commands through a remote gcaps server. This makes debugging closed or distant systems much easier.
C On the device hosting the remote gcaps server, use gclib_set_published().
On the client, use gclib_list_servers() to view all available gcaps servers. Pass a server name to gclib_set_server() for future gclib calls to be routed through that gcaps server. When done, pass NULL to gclib_set_server() to disconnect from the remote gcaps server.
C++ On the device hosting the remote gcaps server, use gclib::set_published().
On the client, use gclib::list_servers() to view all available gcaps servers. Pass a server name to gclib::set_server() for future gclib calls to be routed through that gcaps server. When done, call gclib::set_server() with no arguments to disconnect from the remote gcaps server.
LabVIEW On the device hosting the remote gcaps server (in this example a Raspberry Pi), use set published.
On the client, use list servers to view all available gcaps servers. Pass a server name to set server for future gclib calls to be routed through that gcaps server. When done, pass an empty string to set server to disconnect from the remote gcaps server.
This project contains two example programs.
C The 'Record' example uses RA in continuous mode along with gclib_array() to allow recording movement for an arbitrary amount of time. It produces a file with the recorded positions of Axis A.
The 'Replay' example uses the file produced by 'Record' along with CM to accurately reproduce the recorded movement. Note that axis A must be properly set up for motion.
C++ The 'Record' example uses RA in continuous mode along with gclib::Controller::array() to allow recording movement for an arbitrary amount of time. It produces a file with the recorded positions of Axis A.
The 'Replay' example uses the file produced by 'Record' along with CM to accurately reproduce the recorded movement. Note that axis A must be properly set up for motion.