Discover available controllers and open connections
More...
|
| gclib_result | gclib_addresses (char *addresses, size_t len) |
| | Show address, model, and serial of detected controllers, where available.
|
| gclib_result | gclib_ip_requests (char *ip_requests, size_t len) |
| | Show MAC address, model, and serial of all controllers requesting IP addresses, comma-separated.
|
| gclib_result | gclib_assign_ip (const char *mac, const char *ip) |
| | Assign IP to a controller.
|
| void | gclib_force_gcaps (bool on) |
| | Force future library calls to use either gcaps or direct connections.
|
| gclib_result | gclib_open (gclib_handle *h, const char *address) |
| | Open a connection to a controller.
|
| gclib_result | gclib_set_baud_rate (gclib_handle h, size_t baud_rate) |
| | Set baud rate of serial connection.
|
| gclib_result | gclib_close (gclib_handle *h) |
| | Close connection to controller.
|
| const char * | gclib_error (gclib_handle h) |
| | Get library error string.
|
| gclib_result | gclib_address (gclib_handle h, char *address, size_t len) |
| | Get connection address.
|
| gclib_result | gclib_connection_type (gclib_handle h, gclib_connection_t *type) |
| | Get connection type.
|
Discover available controllers and open connections
◆ gclib_connection_t
◆ gclib_connection_t
◆ gclib_addresses()
| gclib_result gclib_addresses |
( |
char * | addresses, |
|
|
size_t | len ) |
Show address, model, and serial of detected controllers, where available.
Detected controllers are newline-separated. Each line is comma-separated.
Available information by connection type:
- Ethernet connections show address, model, and serial.
- USB connections show address and model.
- Serial and PCI connections show address only.
Example output:
192.168.0.40, DMC4040 Rev 1.3i, 10601
COM5, DMC-41x3
GALILPCI0
- Parameters
-
| addresses | Output buffer |
| len | Length of output buffer |
- Returns
- GCLIB_BUFFER_TOO_SMALL if output does not fit in buffer.
◆ gclib_ip_requests()
| gclib_result gclib_ip_requests |
( |
char * | ip_requests, |
|
|
size_t | len ) |
Show MAC address, model, and serial of all controllers requesting IP addresses, comma-separated.
Use gclib_assign_ip() to assign an IP address to controllers returned by this method.
Example output:
00:50:4c:20:29:69, DMC4000, 10601
00:50:4c:58:12:34, DMC2105, 4660
- Parameters
-
| ip_requests | Output buffer. Example output:
|
| len | Length of output buffer |
- Returns
- GCLIB_BUFFER_TOO_SMALL if output does not fit in buffer.
◆ gclib_assign_ip()
| gclib_result gclib_assign_ip |
( |
const char * | mac, |
|
|
const char * | ip ) |
Assign IP to a controller.
- Parameters
-
| mac | The MAC address of the controller requesting an IP. Provided by gclib_ip_requests(). |
| ip | The IP address to assign. Pass NULL to assign a random IP. |
- Returns
- GCLIB_INVALID_ARGUMENT if MAC or IP is invalid, or if assigned IP puts controller in an unreachable subnet.
◆ gclib_force_gcaps()
| void gclib_force_gcaps |
( |
bool | on | ) |
|
Force future library calls to use either gcaps or direct connections.
The default behavior of gclib is to prefer gcaps, but fall back to direct operations when gcaps is not running. This method allows disabling the default behavior process-wide, but cannot be undone.
- Parameters
-
| on | If true, all future gclib calls will fail if gcaps not found, rather than falling back to direct operations. If false, gcaps will not be used for any future gclib calls. |
◆ gclib_open()
Open a connection to a controller.
Opens a connection through gcaps, if available. Otherwise, a direct connection will be opened. If fallback is not desirable, see gclib_force_gcaps().
If opening a serial connection, the baud rate will default to 115200. Call gclib_set_baud_rate() if necessary before attempting communications.
- Parameters
-
| h | Handle that will be needed for future gclib calls operating on this controller. |
| address | Address of controller, obtained from gclib_addresses(). |
- Returns
- GCLIB_NOT_CONNECTED if unable to open connection.
◆ gclib_set_baud_rate()
Set baud rate of serial connection.
- Parameters
-
| h | Handle to an open connection. |
| baud_rate | Baud rate to use for serial connection. |
- Returns
- GCLIB_NOT_CONNECTED if unable to communicate with controller after setting baud rate.
◆ gclib_close()
Close connection to controller.
- Parameters
-
| h | Handle to an open connection. Will be set to NULL on success. |
- Returns
- GCLIB_INVALID_ARGUMENT if h does not appear to be a valid handle to an open connection.
◆ gclib_error()
Get library error string.
- Warning
- The string returned is an internal error string, which may change between releases.
- Parameters
-
| h | Handle to an open connection. |
- Returns
- The last error string generated by the library.
◆ gclib_address()
Get connection address.
- Parameters
-
| h | Handle to an open connection. |
| address | Output buffer for connection address. |
| len | Size of output buffer. |
- Returns
- GCLIB_BUFFER_TOO_SMALL if output does not fit in buffer.
◆ gclib_connection_type()
Get connection type.
- Parameters
-
| h | Handle to an open connection. |
| type | Will be set to the type of the connection. |
- Returns
- GCLIB_INVALID_ARGUMENT if h does not refer to an open connection.