API Reference
C/C++ API Reference
Return Interface Enum
typedef enum
{
RETURN_FAILURE = 0,
RETURN_SUCCESS = 1
} ret_interface_t;
Description
Used to indicate the success or failure status of an interface operation.
| Enumerator | Value | Description |
|---|---|---|
| RETURN_FAILURE | 0 | Operation failed |
| RETURN_SUCCESS | 1 | Operation succeeded |
CAN Baud Rate Enum
typedef enum
{
UNKNOWN_OR_INVALID_BAUDRATE = -1,
BAUDRATE_10K,
BAUDRATE_20K,
BAUDRATE_50K,
BAUDRATE_100K,
BAUDRATE_125K,
BAUDRATE_250K,
BAUDRATE_500K,
BAUDRATE_750K,
BAUDRATE_1M
} CANBaudRate;
Description
Defines the supported CAN bus communication baud rates for the interface.
| Enumerator | Value | Description |
|---|---|---|
| UNKNOWN_OR_INVALID_BAUDRATE | -1 | Invalid or unknown baud rate |
| BAUDRATE_10K | 0 | 10 kbps |
| BAUDRATE_20K | 1 | 20 kbps |
| BAUDRATE_50K | 2 | 50 kbps |
| BAUDRATE_100K | 3 | 100 kbps |
| BAUDRATE_125K | 4 | 125 kbps |
| BAUDRATE_250K | 5 | 250 kbps |
| BAUDRATE_500K | 6 | 500 kbps |
| BAUDRATE_750K | 7 | 750 kbps |
| BAUDRATE_1M | 8 | 1 Mbps |
CANInterface.CANInterface()
CANInterface::CANInterface()
Description
Construct a new CANInterface object.
CANInterface.closeInterface()
uint8_t CANInterface::closeInterface()
Description
Closes CANInterface and running threads.
Returns
| Datatype | Description |
|---|---|
uint8_t | uint8_t Success(0) or Failure(1) |
CANInterface.getConnectedDevices()
std::map<uint32_t, uint8_t> CANInterface::getConnectedDevices()
Description
Get list of connected devices.
Returns
| Datatype | Description |
|---|---|
std::map<uint32_t,uint8_t> | Map array of node id's and corresponding device types which are connected. |
CANInterface.initInterface()
uint8_t CANInterface::initInterface(std::string interface_name, std::function< void(uint32_t, uint8_t)> on_new_dev_cb=nullptr, std::function< void(uint32_t)> on_dev_disconnect_cb=nullptr)
Description
Invokes lower level interface initialisation and starts various threads.
Parameters
| Datatype | Variable | Description |
|---|---|---|
std::string | interface_name | Name of CAN Interface eg. can0, vcan0...etc |
std::function< void(uint32_t, uint8_t)> | on_new_dev_cb | Callback function which will be called when a new device is connected. The arguments of the function are: • CAN Node ID of the device of type uint32_t • Value of uint8_t type variable represents the type of the device which is connected. • 0 means that an actuator is connected. • 1 means that a motor driver is connected. • 2 means that an IMU is connected. • 3 means that an NCoder is connected. Return value of the function is void ie. it returns nothing. |
std::function< void(uint32_t)> | on_dev_disconnect_cb | Callback function which will be called when a device is disconnected. The argument of this function is the CAN Node ID of the device of type uint32_t and return value of the function is void i.e. it returns nothing. |
Returns
| Datatype | Description |
|---|---|
uint8_t | uint8_t Success(0) or Failure(1) |
USBInterface.USBInterface()
USBInterface::USBInterface()
Description
Construct a new USBInterface object.
USBInterface.closeInterface()
uint8_t USBInterface::closeInterface()
Description
Closes USBInterface and running threads.
Returns
| Datatype | Description |
|---|---|
uint8_t | uint8_t Success(0) or Failure(1) |
USBInterface.enterDFUMode()
ret_interface_t USBInterface::enterDFUMode()
Description
Set NLink to DFU Mode.
Returns
| Datatype | Description |
|---|---|
ret_interface_t | ret_interface_t Success(0) or Failure(1) |
USBInterface.eraseConfiguration()
ret_interface_t USBInterface::eraseConfiguration()
Description
Erase the configuration from NLink.
Returns
| Datatype | Description |
|---|---|
ret_interface_t | ret_interface_t Success(0) or Failure(1) |
USBInterface.getCANBaudRate()
ret_interface_t USBInterface::getCANBaudRate(CANBaudRate *baud_rate)
Description
Get CAN Baud Rate for NLink.
Parameters
| Datatype | Variable | Description |
|---|---|---|
CANBaudRate * | baud_rate | Pointer to CANBaudRate where current baud rate will be stored |
Returns
| Datatype | Description |
|---|---|
ret_interface_t | ret_interface_t Success(0) or Failure(1) |
USBInterface.getConnectedDevices()
std::map<uint32_t, uint8_t> USBInterface::getConnectedDevices()
Description
Get list of connected devices.
Returns
| Datatype | Description |
|---|---|
std::map<uint32_t,uint8_t> | Map array of node id's and corresponding device types which are connected. |
USBInterface.getFirmwareVersion()
ret_interface_t USBInterface::getFirmwareVersion(uint8_t *fw_version_major, uint8_t *fw_version_minor, uint8_t *fw_version_revision, std::string *fw_version_commit)
Description
Get the firmware version of the device.
Parameters
| Datatype | Variable | Description |
|---|---|---|
uint8_t * | fw_version_major | - |
uint8_t * | fw_version_minor | - |
uint8_t * | fw_version_revision | - |
std::string * | fw_version_commit | - |
Returns
| Datatype | Description |
|---|---|
ret_interface_t | ret_interface_t Success(0) or Failure(1) |
USBInterface.getHardwareVersion()
ret_interface_t USBInterface::getHardwareVersion(uint8_t *hw_version_major, uint8_t *hw_version_minor, uint8_t *hw_revision)
Description
Get the hardware version of the device.
Parameters
| Datatype | Variable | Description |
|---|---|---|
uint8_t * | hw_version_major | - |
uint8_t * | hw_version_minor | - |
uint8_t * | hw_revision | - |
Returns
| Datatype | Description |
|---|---|
ret_interface_t | ret_interface_t Success(0) or Failure(1) |
USBInterface.initInterface()
uint8_t USBInterface::initInterface(std::string interface_name, std::function< void(uint32_t, uint8_t)> on_new_dev_cb=nullptr, std::function< void(uint32_t)> on_dev_disconnect_cb=nullptr)
Description
Invokes lower level interface initialisation and starts various threads.
Parameters
| Datatype | Variable | Description |
|---|---|---|
std::string | interface_name | Name of CAN Interface eg. can0, vcan0...etc |
std::function< void(uint32_t, uint8_t)> | on_new_dev_cb | Callback function which will be called when a new device is connected. The arguments of the function are: • CAN Node ID of the device of type uint32_t • Value of uint8_t type variable represents the type of the device which is connected. • 0 means that an actuator is connected. • 1 means that a motor driver is connected. • 2 means that an IMU is connected. • 3 means that an NCoder is connected. Return value of the function is void ie. it returns nothing. |
std::function< void(uint32_t)> | on_dev_disconnect_cb | Callback function which will be called when a device is disconnected. The argument of this function is the CAN Node ID of the device of type uint32_t and return value of the function is void i.e. it returns nothing. |
Returns
| Datatype | Description |
|---|---|
uint8_t | uint8_t Success(0) or Failure(1) |
USBInterface.rebootNLink()
ret_interface_t USBInterface::rebootNLink()
Description
Reboot the NLink device.
Returns
| Datatype | Description |
|---|---|
ret_interface_t | ret_interface_t Success(0) or Failure(1) |
USBInterface.saveConfiguration()
ret_interface_t USBInterface::saveConfiguration()
Description
Save the configuration to NLink.
Returns
| Datatype | Description |
|---|---|
ret_interface_t | ret_interface_t Success(0) or Failure(1) |
USBInterface.setCANBaudRate()
ret_interface_t USBInterface::setCANBaudRate(CANBaudRate baud_rate)
Description
Set CAN Baud Rate for NLink.
Parameters
| Datatype | Variable | Description |
|---|---|---|
CANBaudRate | baud_rate |
Returns
| Datatype | Description |
|---|---|
ret_interface_t | uint8_t Success(0) or Failure(1) |
Python API Reference
CANInterface.CANInterface()
CANInterface(interface_name: str)
Description
CANInterface class constructor.
@param interface_name Interface identifier string.
Parameters
| Datatype | Variable | Description |
|---|---|---|
str | interface_name | - |
CANInterface.close()
close()
Description
Close the interface.
CANInterface.getConnectedDevices()
getConnectedDevices() -> 'list[int]'
Description
Get connected devices on the interface.
Returns
| Datatype | Description |
|---|---|
'list[int]' | List of CAN Node IDs of connected devices. |
USBInterface.USBInterface()
USBInterface(interface_name: str)
Description
USBInterface class constructor.
@param interface_name Interface identifier string.
Parameters
| Datatype | Variable | Description |
|---|---|---|
str | interface_name | - |
USBInterface.close()
close()
Description
Close the interface.
USBInterface.enterDFUMode()
enterDFUMode() -> bool
Description
Enter Device Firmware Update Mode.
Returns
| Datatype | Description |
|---|---|
bool | True if successful else False. |
USBInterface.eraseConfiguration()
eraseConfiguration() -> bool
Description
Erase current configuration from the device.
Returns
| Datatype | Description |
|---|---|
bool | True if successful else False. |
USBInterface.getCANBaudRate()
getCANBaudRate() -> 'tuple[int, nmotion_transport.CANBaudRate]'
Description
Get CAN Baudrate for the interface.
Returns
| Datatype | Description |
|---|---|
'tuple[int, nmotion_transport.CANBaudRate]' | CAN Baudrate value. |
USBInterface.getConnectedDevices()
getConnectedDevices() -> 'dict[int, int]'
Description
Get connected devices on the interface.
Returns
| Datatype | Description |
|---|---|
'dict[int, int]' | List of CAN Node IDs and device type of connected devices. |
USBInterface.getFirmwareVersion()
getFirmwareVersion() -> 'tuple[int, int, int, str]'
Description
Get Firmware version of the device.
Returns
| Datatype | Description |
|---|---|
'tuple[int, int, int, str]' | Firmware version as major, minor, revision, commit. |
USBInterface.getHardwareVersion()
getHardwareVersion() -> 'tuple[int, int, int]'
Description
Get Hardware version of the device.
Returns
| Datatype | Description |
|---|---|
'tuple[int, int, int]' | Hardware version as major, minor, revision. |
USBInterface.rebootNLink()
rebootNLink() -> bool
Description
Reboot the NLink device.
Returns
| Datatype | Description |
|---|---|
bool | True if successful else False. |
USBInterface.saveConfiguration()
saveConfiguration() -> bool
Description
Save current configuration to the device.
Returns
| Datatype | Description |
|---|---|
bool | True if successful else False. |
USBInterface.setCANBaudRate()
setCANBaudRate(baudrate: nmotion_transport.CANBaudRate) -> int
Description
Set CAN Baudrate for the interface.
Parameters
| Datatype | Variable | Description |
|---|---|---|
nmotion_transport.CANBaudRate | baudrate | CAN Baudrate to be set. |
Returns
| Datatype | Description |
|---|---|
int | True if successful else False. |