gclib 2.0.9
Communications API for Galil controllers and PLCs
 
Loading...
Searching...
No Matches

◆ GOpen()

GCLIB_DLL_EXPORTED GReturn GCALL GOpen ( GCStringIn  address,
GCon g 
)

Open a connection to a Galil Controller.

Parameters
addressNull-terminated address string. See table below.
gPointer to user's GCon variable. On success, the library will fill the user's variable with the handle to use for the rest of the connection. A valid g value is nonzero.
Returns
The success status or error code of the function. See gclib_errors.h for possible values.
address switch Meaning Arguments (default), other options Examples
--address Simple address to hardware IP address, PCI, COM port --address COM1
-a shorthand for --address See Address Ranges below -a GALILPCI1
{no switch} --address is implicit for any lone token 192.168.0.42
--baud Baud rate (115200), valid baud... COM2 --baud 19200
-b shorthand for --baud COM3 -b 38400
--command Command-and-response socket protocol (TCP), UDP 192.168.0.42 --command TCP
-c shorthand for --command 192.168.0.42 -c UDP
--direct Connect directly to hardware instead of via gcaps -a GALILPCI2 --direct
-d shorthand for --direct GALILPCI2 -d
--subscribe Subscribe to messages, data records, and/or interrupts (NONE), MG, DR, EI, ALL 192.168.0.42 --subscribe MG
-s shorthand for --subscribe 192.168.0.42 -s DR -s EI
--timeout timeout in ms (5000), 0-65535 192.168.0.42 --timeout 5000
-t shorthand for --timeout GALILPCI2 -t 500
--unsolicited Unsolicited socket protocol (UDP), NONE 192.168.0.42 --unsolicited NONE
-u shorthand for --unsolicited 192.168.1.42 -u UDP
The following address switches are deprecated and will be unavailable starting July 1st, 2020.
--p1 Primary port for command-and-response traffic (23), valid port number 192.168.0.42 --p1 5000
--p2 Secondary port for unsolicited traffic (60007), valid port number 192.168.0.42 --p2 5000


Operating System Address Range Notes
Windows COM1 - COM256 RS232 and USB-to-serial
Linux /dev/ttyS0 - /dev/ttyS255 RS232
Linux /dev/ttyUSB0 - /dev/ttyUSB255 USB-to-serial, e.g. DMC-4103
Windows GALILPCI1 - GALILPCI8 PCI
Linux /dev/galilpci0 - /dev/galilpci7 PCI

See x_examples.cpp for an example.

When connecting to a network device, if the command-and-response socket is opened successfully but the unsolicited socket fails, GOpen() will still complete successfully. This allows connection to a Galil controller when only one Ethernet handle is available. Unsolicited traffic will not be accessible in this case.

Referenced by ip_assigner(), and main().