EmSACAN_OpenChannel
Prototype
emsacan_result_t EmSACAN_OpenChannel(
emsacan_handle_t Handle,
uint8_t ChannelNumber,
emsacan_channel_connection_callback_fn ConnectionCallback,
void *UserContext );
Description
Opens the connection to a specific CAN port so traffic can flow.
Parameters
| Parameter | Direction | Type | Description |
|---|---|---|---|
Handle | in | emsacan_handle_t | Session handle from EmSACAN_Connect. |
ChannelNumber | in | uint8_t | Zero-based port index. |
ConnectionCallback | in | emsacan_channel_connection_callback_fn | Optional callback for USB disconnect/reconnect while this port stays open; pass NULL to disable notifications for this port. |
UserContext | in | void | Opaque pointer passed to ConnectionCallback. |
Return value
EMSACAN_OK on success, or another emsacan_result_t code on failure.
Example
void __cdecl OnConn(emsacan_handle_t h, uint8_t ch,
emsacan_channel_connection_event_t ev, void *ctx)
{
/* EMSACAN_CHANNEL_CONNECTION_DISCONNECTED or _RECONNECTED */
}
emsacan_result_t rc = EmSACAN_OpenChannel(handle, 0, OnConn, NULL);
if (rc != EMSACAN_OK) { /* failed to open port 0 */ }
