gclib 2.4.0
Galil Communications Library
Loading...
Searching...
No Matches
Connection

Discover available controllers and open connections More...

Topics

 Galil Connect
 Connect to or host a remote gcaps server.

Typedefs

typedef enum gclib_connection_t gclib_connection_t
 Connection type, as returned by gclib_connection_type().

Enumerations

enum  gclib_connection_t { GCLIB_ETHERNET = 1 , GCLIB_SERIAL , GCLIB_PCI }
 Connection type, as returned by gclib_connection_type(). More...

Functions

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.

Detailed Description

Discover available controllers and open connections

Typedef Documentation

◆ gclib_connection_t

Connection type, as returned by gclib_connection_type().

Enumeration Type Documentation

◆ gclib_connection_t

Connection type, as returned by gclib_connection_type().

Enumerator
GCLIB_ETHERNET 
GCLIB_SERIAL 
GCLIB_PCI 

Definition at line 276 of file gclib.h.

Function Documentation

◆ 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
addressesOutput buffer
lenLength 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_requestsOutput buffer. Example output:
lenLength 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
macThe MAC address of the controller requesting an IP. Provided by gclib_ip_requests().
ipThe 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
onIf 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()

gclib_result gclib_open ( gclib_handle * h,
const char * address )

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
hHandle that will be needed for future gclib calls operating on this controller.
addressAddress of controller, obtained from gclib_addresses().
Returns
GCLIB_NOT_CONNECTED if unable to open connection.

◆ gclib_set_baud_rate()

gclib_result gclib_set_baud_rate ( gclib_handle h,
size_t baud_rate )

Set baud rate of serial connection.

Parameters
hHandle to an open connection.
baud_rateBaud rate to use for serial connection.
Returns
GCLIB_NOT_CONNECTED if unable to communicate with controller after setting baud rate.

◆ gclib_close()

gclib_result gclib_close ( gclib_handle * h)

Close connection to controller.

Parameters
hHandle 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()

const char * gclib_error ( gclib_handle h)

Get library error string.

Warning
The string returned is an internal error string, which may change between releases.
Parameters
hHandle to an open connection.
Returns
The last error string generated by the library.

◆ gclib_address()

gclib_result gclib_address ( gclib_handle h,
char * address,
size_t len )

Get connection address.

Parameters
hHandle to an open connection.
addressOutput buffer for connection address.
lenSize of output buffer.
Returns
GCLIB_BUFFER_TOO_SMALL if output does not fit in buffer.

◆ gclib_connection_type()

gclib_result gclib_connection_type ( gclib_handle h,
gclib_connection_t * type )

Get connection type.

Parameters
hHandle to an open connection.
typeWill be set to the type of the connection.
Returns
GCLIB_INVALID_ARGUMENT if h does not refer to an open connection.