TranCreate
This function creates a transport connection with a device.
TRANSPORTID TranCreate(
LPCWSTR pszDeviceName
);
Parameters
- pszDeviceName
[in] Pointer to the string that contains the name of the device to connect to.
Return Values
A valid transport identifier is returned on success; otherwise, INVALID_TRANSPORTID is returned.
Remarks
This function is called when KITLCreateServer is called. 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:
- 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.
- Open the COM port.
- Set the settings based on the user input using the TranGetXMLParams and TranSetParam functions.
- Create any synchronization objects that you might need to prevent data access by multiple threads and to receive notifications when a packet arrives.
- 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
OS Versions: Windows CE .NET 4.0 and later.
Header: Kitltran.h.
Link Library: Not applicable.
See Also
TranGetXMLParams | TranSetParam | TranSend | TranRecv
Last updated on Wednesday, April 13, 2005
© 2005 Microsoft Corporation. All rights reserved.