次の方法で共有


TranCreate (Compact 2013)

3/26/2014

This function creates a transport connection with a device.

Syntax

TRANSPORTID TranCreate(
  LPCWSTR pszDeviceName
);

Parameters

  • pszDeviceName
    [in] Pointer to the string that contains the name of the device to connect to.

Return Value

A valid transport identifier is returned on success; otherwise, INVALID_TRANSPORTID is returned.

Remarks

Use this function to create a named connection to a particular device using the COM ports selected by the user. Because you are developing a serial transport, which is a direct connection, you do not need the input parameter, which is the device name. Instead, you can use the input parameter to index between the known serial connections.

To implement this method:

  1. Search for existing connections based on the device name. If a connection is already present, return the corresponding transport identifier. This transport identifier will be used in subsequent calls to transport functions like TranRecv, TranSend, and so on.
  2. Open the COM port.
  3. Set the settings based on the user input using the TranGetXMLParams and TranSetParam functions.
  4. Create any synchronization objects that you might need to prevent data access by multiple threads and to receive notifications when a packet arrives.
  5. Start the receive thread.

This function should return a unique identifier, which is passed in by the user in subsequent TranSend and TranRecv function calls to send and receive data.

Requirements

Header

kitltran.h

Library

Developer Implemented

See Also

Reference

KITL Transport Functions
TranGetXMLParams
TranSetParam
TranSend
TranRecv