Skip to content

File syn_devicenet.c

FileList > proto > syn_devicenet.c

Go to the source code of this file

ODVA DeviceNet Protocol Stack Implementation.

  • #include "syn_devicenet.h"
  • #include "../util/syn_pack.h"
  • #include <string.h>

Public Functions

Type Name
bool syn_devicenet_init (SYN_DeviceNet_Node * node, uint8_t mac_id, SYN_DeviceNet_Baud baud)
Initialize DeviceNet node instance context.
bool syn_devicenet_on_can_rx (SYN_DeviceNet_Node * node, uint32_t can_id, const uint8_t * data, uint8_t len, uint32_t * tx_can_id, uint8_t * tx_data, uint8_t * tx_len)
Process incoming CAN message frame and generate optional response frame.
void syn_devicenet_poll (SYN_DeviceNet_Node * node, uint32_t dt_ms)
Periodic timer tick to service Duplicate MAC ID check & QuickConnect timers.
bool syn_devicenet_set_assembly (SYN_DeviceNet_Node * node, uint8_t * in_buf, uint8_t in_len, uint8_t * out_buf, uint8_t out_len)
Configure Assembly Object (Class 0x04) input/output I/O buffers.
bool syn_devicenet_set_quickconnect (SYN_DeviceNet_Node * node, bool enable)
Enable or disable QuickConnectâ„¢ fast startup mode.
void syn_devicenet_set_serial_number (SYN_DeviceNet_Node * node, uint32_t serial_number)
Set CIP Identity serial number for DeviceNet node.

Public Static Functions

Type Name
bool handle_explicit_message (SYN_DeviceNet_Node * node, const uint8_t * data, uint8_t len, uint8_t * tx_data, uint8_t * tx_len)
Process an explicit DeviceNet message payload.

Public Functions Documentation

function syn_devicenet_init

Initialize DeviceNet node instance context.

bool syn_devicenet_init (
    SYN_DeviceNet_Node * node,
    uint8_t mac_id,
    SYN_DeviceNet_Baud baud
) 

Parameters:

  • node Pointer to DeviceNet node context.
  • mac_id Initial Node Address (0..63).
  • baud Network baud rate setting.

Returns:

true on success, false if parameters invalid.


function syn_devicenet_on_can_rx

Process incoming CAN message frame and generate optional response frame.

bool syn_devicenet_on_can_rx (
    SYN_DeviceNet_Node * node,
    uint32_t can_id,
    const uint8_t * data,
    uint8_t len,
    uint32_t * tx_can_id,
    uint8_t * tx_data,
    uint8_t * tx_len
) 

Parameters:

  • node Pointer to DeviceNet node instance.
  • can_id Received 11-bit CAN Identifier.
  • data Received CAN payload bytes.
  • len Received CAN payload length (0..8).
  • tx_can_id Output pointer for response CAN ID.
  • tx_data Output buffer for response payload bytes (min 8 bytes capacity).
  • tx_len Output pointer for response payload length.

Returns:

true if response CAN frame generated, false if no response required.


function syn_devicenet_poll

Periodic timer tick to service Duplicate MAC ID check & QuickConnect timers.

void syn_devicenet_poll (
    SYN_DeviceNet_Node * node,
    uint32_t dt_ms
) 

Parameters:

  • node Pointer to DeviceNet node instance.
  • dt_ms Time elapsed in milliseconds since last poll call.

function syn_devicenet_set_assembly

Configure Assembly Object (Class 0x04) input/output I/O buffers.

bool syn_devicenet_set_assembly (
    SYN_DeviceNet_Node * node,
    uint8_t * in_buf,
    uint8_t in_len,
    uint8_t * out_buf,
    uint8_t out_len
) 

Parameters:

  • node Pointer to DeviceNet node instance.
  • in_buf Pointer to input data buffer (sensor/status data to Master).
  • in_len Length of input buffer (max 8 bytes).
  • out_buf Pointer to output data buffer (actuator/cmd data from Master).
  • out_len Length of output buffer (max 8 bytes).

Returns:

true on success, false if parameters invalid.


function syn_devicenet_set_quickconnect

Enable or disable QuickConnectâ„¢ fast startup mode.

bool syn_devicenet_set_quickconnect (
    SYN_DeviceNet_Node * node,
    bool enable
) 

Parameters:

  • node Pointer to DeviceNet node instance.
  • enable True to enable QuickConnect feature.

Returns:

true on success, false if node is NULL.


function syn_devicenet_set_serial_number

Set CIP Identity serial number for DeviceNet node.

void syn_devicenet_set_serial_number (
    SYN_DeviceNet_Node * node,
    uint32_t serial_number
) 

Parameters:

  • node Pointer to DeviceNet node context.
  • serial_number 32-bit serial number.

Public Static Functions Documentation

function handle_explicit_message

Process an explicit DeviceNet message payload.

static bool handle_explicit_message (
    SYN_DeviceNet_Node * node,
    const uint8_t * data,
    uint8_t len,
    uint8_t * tx_data,
    uint8_t * tx_len
) 

Parameters:

  • node Target DeviceNet node instance.
  • data Received message payload buffer.
  • len Byte length of received payload.
  • tx_data Response message payload output buffer.
  • tx_len Pointer to output byte length variable.

Returns:

true if response frame was constructed, false on error.



The documentation for this class was generated from the following file src/syntropic/proto/syn_devicenet.c