COMOPEN


 

The COMOPEN instruction initializes a communications device. The communications device may be a local port, a Windows or Linux socket, or an RMS pipe. The instruction uses the following format:

 

 

[label]

COMOPEN

{comfile},{parameters}

 

Where:

label

Optional. A Program Execution Label.

comfile

Required. A previously defined COMFILE definition.

parameters

Required. A formatted Character String Variable or Literal that initializes the communications device.

Flags Affected: NONE

Note the following:

  1. If {comfile} is currently open, a COMCLOSE is performed prior to the COMOPEN.

  2. For local communication port, the {parameters} string is a comma-delimited list. The following format is required for proper initialization:

  3. Under PLBWIN and PLBCON, the {parameters} string parsing has been modified to allow fields that are omitted and default values used. At a minimum, the port number must be specified.

  4. The default {parameter} values when using the PLBCON runtime are as follows:
     

  5. Baud

    9600

    Data bits

    8

    Parity

    None

    Stop Bits

    1

     

  6. The PLBWIN runtime uses the current Windows configuration values as the default settings. The initial values are defined using the Control Panel. After a communications port is used by any application, the settings are left in the state applied by that application.

  7. Under Windows, an additional character may be added to the end of {parameters} for flow control. The flow control character may be an 'H' for hardware flow control or 'X' for XON/XOFF flow control.

  8. For sockets, the {parameters} string is a comma-delimited list. The following format is required for proper initialization:

  9. Socket communications do not support UDP.

  10. For Datapoint RMS pipes, the {parameters} string is a comma-delimited list. The following format is required for proper initialization:

  11. An I97 error is generated if the parameter list is not in the correct format or some other type of error occurs while trying to open the communications device. The extended error code is set to the parameter causing the problem. For example, if the baud rate specified is incorrect for a local communication port open, the extended error code is set to two (2).

  12. For a Linux runtime, the {parameters} can be a file or device name that is opened directly and used by COMREAD and COMWRITE instructions.

  13. Example:

         COMOPEN comfile, "/dev/ttyS10"

     

  14. If the first parameter value is "S6" (10.7), the following examples show allowed IPV6 URI formats.

  15.  

    COMOPEN comopen,"S6,O,::1,9999,R"

     

    Opens a socket connection to a local IPV6 address.

     

    COMOPEN comopen,"S6,O,localipv6-test.home,9999,R"

     

    Opens a socket connection to an IPV6 URL that resolves to an IPV6 address.

     

    COMOPEN comopen,"S6,C,::1,9999,R"

     

    Creates a listening socket for a local IPV6 address.

 

 

See Also: Example Code, Communication I/O Instructions

 



PL/B Language Reference COMCLR COMREAD