Common labCAN bus device handling and management This group defines all common functions for handling of devices attached to labCAN bus.
|
LCB_Func long LCB_CALL | LCB_GetDevErrMsg (dev_hdl DeviceHandle, unsigned long DevErr, char *pMsgBuf, int MsgBufSize) |
| Get the error string for a certain device error message. More...
|
|
LCB_Func long LCB_CALL | LCB_GetDeviceProperty (dev_hdl DeviceHandle, int PropertyId, double *Value) |
| Function for reading a device specific property. More...
|
|
LCB_Func long LCB_CALL | LCB_GetDevName (dev_hdl DeviceHandle, char *pNameStringBuf, int StringBufSize) |
| Query name of specific device. More...
|
|
LCB_Func long LCB_CALL | LCB_GetNodeId (dev_hdl DeviceHandle) |
| Query node identifier of specific device Each CANopen device has a unique node identifier that identifies the device on a CAN bus. More...
|
|
LCB_Func long LCB_CALL | LCB_IsSimulated (dev_hdl DeviceHandle) |
| Checks if the given DeviceHandle is a simulated device. More...
|
|
LCB_Func long LCB_CALL | LCB_ReadDevParam (dev_hdl DeviceHandle, unsigned long DevParamId, void *pReadBuf, unsigned long BufSize, unsigned char AdjustEndian) |
| Read certain parameter from device. More...
|
|
LCB_Func long LCB_CALL | LCB_ReadLastDevErr (dev_hdl DeviceHandle, unsigned long *pDevErr) |
| Read last device error from a specific device. More...
|
|
LCB_Func long LCB_CALL | LCB_SetCommState (dev_hdl DeviceHandle, unsigned char CommState) |
| Set device in a configurable state. More...
|
|
LCB_Func long LCB_CALL | LCB_SetDeviceProperty (dev_hdl DeviceHandle, int PropertyId, double Value) |
| Function for setting a device specific property. More...
|
|
LCB_Func long LCB_CALL | LCB_WriteDevParam (dev_hdl DeviceHandle, unsigned long DevParamId, void *pWriteBuf, unsigned long BufSize, unsigned char AdjustEndian) |
| Write certain parameter to device. More...
|
|
◆ LCB_CommState
Communication state identifiers for LCB_SetCommState()
Enumerator |
---|
LCB_COMM_STOPPED | no process data communication
|
LCB_COMM_CONFIGURABLE | for configuration purposes - preoperational
|
LCB_COMM_OPERATIONAL | full communication - some parameters are not writable in this state
|
◆ LCB_GetDevErrMsg()
LCB_Func long LCB_CALL LCB_GetDevErrMsg |
( |
dev_hdl |
DeviceHandle, |
|
|
unsigned long |
DevErr, |
|
|
char * |
pMsgBuf, |
|
|
int |
MsgBufSize |
|
) |
| |
Get the error string for a certain device error message.
This function decodes the error code obtained by a call to LCB_ReadLastDevErr().
- Parameters
-
[in] | DeviceHandle | Valid bus handle |
[in] | DevErr | Device erorr code returned by readLastDevErr() |
[out] | pMsgBuf | Message buffer for storage of error message string |
[in] | MsgBufSize | Size of message buffer pMsgBuf in bytes |
- Return values
-
ERR_NOTSUP | The erro code is unknown - no message was found |
ERR_PARAM_INVALID | Invalid device handle |
ERR_NOERR | Error message was found |
- Examples:
- capi_event_queue_test.cpp.
◆ LCB_GetDeviceProperty()
LCB_Func long LCB_CALL LCB_GetDeviceProperty |
( |
dev_hdl |
DeviceHandle, |
|
|
int |
PropertyId, |
|
|
double * |
Value |
|
) |
| |
Function for reading a device specific property.
- See also
- LCB_SetDeviceProperty
- Parameters
-
[in] | DeviceHandle | Valid device handle |
[in] | PropertyId | Device specific device property identifier |
[out] | Value | Returns the current value of the given device property. |
- Return values
-
ERR_NOERR | Success |
-ERR_NOTSUP | The given device property is not supported for the device given in DeviceHandle |
< | 0 Error code |
- Examples:
- capi_contiflow_test.cpp, and capi_rotaxys_test.cpp.
◆ LCB_GetDevName()
LCB_Func long LCB_CALL LCB_GetDevName |
( |
dev_hdl |
DeviceHandle, |
|
|
char * |
pNameStringBuf, |
|
|
int |
StringBufSize |
|
) |
| |
Query name of specific device.
Normally all devices are named. That means each device carries a unique name
- Parameters
-
[in] | DeviceHandle | Valid device handle |
[out] | pNameStringBuf | Message buffer for storage of error message string |
[in] | StringBufSize | Size of message buffer pMsgBuf in bytes |
- Returns
- Error code - ERR_NOERR indicates success
- Examples:
- capi_event_queue_test.cpp, capi_nemaxys_test.cpp, and capi_nemesys_valve_test.cpp.
◆ LCB_GetNodeId()
LCB_Func long LCB_CALL LCB_GetNodeId |
( |
dev_hdl |
DeviceHandle | ) |
|
Query node identifier of specific device Each CANopen device has a unique node identifier that identifies the device on a CAN bus.
- Parameters
-
[in] | DeviceHandle | Valid device handle |
- Return values
-
>= | 0 Node ID |
< | 0 Error code |
◆ LCB_IsSimulated()
LCB_Func long LCB_CALL LCB_IsSimulated |
( |
dev_hdl |
DeviceHandle | ) |
|
Checks if the given DeviceHandle is a simulated device.
- Parameters
-
[in] | DeviceHandle | Valid device handle |
- Return values
-
0 | It is a real device |
1 | It is a simulated device |
< | 0 Error code |
- Examples:
- capi_rotaxys_test.cpp.
◆ LCB_ReadDevParam()
LCB_Func long LCB_CALL LCB_ReadDevParam |
( |
dev_hdl |
DeviceHandle, |
|
|
unsigned long |
DevParamId, |
|
|
void * |
pReadBuf, |
|
|
unsigned long |
BufSize, |
|
|
unsigned char |
AdjustEndian |
|
) |
| |
Read certain parameter from device.
Each device may contain a number of parameters to read or write. These parameters are device specific and you need a good knowledge or a good documentation of the device parameters.
- Parameters
-
[in] | DeviceHandle | Valid device handle |
[in] | DevParamId | Device parameter identifier |
[out] | pReadBuf | Stores the data read from device |
[in] | BufSize | Contains the size of the buffer |
[in] | AdjustEndian | This parameter indicates if the function should adjust the endianess of the data read from device If the device bus transports the data in a different endian format like the host machine, then the endianess will be adjusted if this parameter is true. Normally this parameter should be set to true for numbers (integers, bytes...) and to false for string or other data. |
- Returns
- Error code - ERR_NOERR indicates success
- See also
- LCB_WriteDevParam()
◆ LCB_ReadLastDevErr()
LCB_Func long LCB_CALL LCB_ReadLastDevErr |
( |
dev_hdl |
DeviceHandle, |
|
|
unsigned long * |
pDevErr |
|
) |
| |
Read last device error from a specific device.
If an error occured then the device stores the last error so that it is accessible later at any time. This function reads the last error code from the device. Call LCB_GetDevErrMsg() to get a more descriptive error message for a certain device error code.
- Parameters
-
[in] | DeviceHandle | Valid device handle |
[out] | pDevErr | Returns last device error |
- Returns
- Error code - ERR_NOERR indicates success
◆ LCB_SetCommState()
LCB_Func long LCB_CALL LCB_SetCommState |
( |
dev_hdl |
DeviceHandle, |
|
|
unsigned char |
CommState |
|
) |
| |
Set device in a configurable state.
Some device parameters are only writeable if the device is not operational but in a configurable state. The function LCB_WriteDevParam() might require to set the device into an configurable state. To set the device into a configurable state, this function should be called with the parameter LCB_COMM_CONFIGURABLE. If the configuration is finished, the device should be set operational again by calling this function with the parameter LCB_COMM_OPERATIONAL.
- Parameters
-
[in] | DeviceHandle | Valid device handle |
[in] | CommState | The communication state to set this device to
|
- Returns
- Error code - ERR_NOERR indicates success
- See also
- LCB_CommState
◆ LCB_SetDeviceProperty()
LCB_Func long LCB_CALL LCB_SetDeviceProperty |
( |
dev_hdl |
DeviceHandle, |
|
|
int |
PropertyId, |
|
|
double |
Value |
|
) |
| |
Function for setting a device specific property.
Devices may support special device properties that are not accessible via the common device specific API. Use this function to set the value of a certain property by providing a property ID and a value.
- See also
- LCB_GetDeviceProperty
- Parameters
-
[in] | DeviceHandle | Valid device handle |
[in] | PropertyId | Device specific device property identifier |
[in] | Value | Value to set for the given device property |
- Return values
-
ERR_NOERR | Success |
-ERR_NOTSUP | The given device property is not supported for the device given in DeviceHandle |
< | 0 Error code |
- Examples:
- capi_contiflow_test.cpp, and capi_rotaxys_test.cpp.
◆ LCB_WriteDevParam()
LCB_Func long LCB_CALL LCB_WriteDevParam |
( |
dev_hdl |
DeviceHandle, |
|
|
unsigned long |
DevParamId, |
|
|
void * |
pWriteBuf, |
|
|
unsigned long |
BufSize, |
|
|
unsigned char |
AdjustEndian |
|
) |
| |
Write certain parameter to device.
See readDevParam for a detailed description
- Parameters
-
[in] | DeviceHandle | Valid device handle |
[in] | DevParamId | Device parameter identifier |
[out] | pWriteBuf | Stores the data read from device |
[in] | BufSize | Contains the size of the buffer and returns the numer of bytes read from device |
[in] | AdjustEndian | This parameter indicates if the function should adjust the endianess of the data before writing to device |
- Returns
- Error code - ERR_NOERR indicates success
- See also
- LCB_ReadDevParam()
- Note
- For some parameters it might be necessary to set the device communication state machine into a configurable state.