All DLN-series adapters are fitted with a single status LED and several user-controlled LEDs. The number of user-controlled LEDs depends on the DLN adapter model.The status LED shows the current state of your device.Each of the user-controlled LEDs can be adjusted to a specific state by using the DlnLedSetState() function. For details, read LED States.
You can find out the number of available user-controlled LEDs by using the DlnLedGetCount() function.
DLN-series adapters allow you to control LEDs’ behavior by defining the value of the DLN_LED_STATE type defined in the dln_led.h
file.The list of its possible LED states is given in the following table:
State | LED Behavior |
DLN_LED_STATE_OFF | Off |
DLN_LED_STATE_ON | On |
DLN_LED_SLOW_BLINK | Blinking slowly |
DLN_LED_FAST_BLINK | Blinking rapidly |
DLN_LED_DOUBLE_BLINK | Blinking in a double-blink pattern |
DLN_LED_TRIPLE_BLINK | Blinking in a triple-blink pattern |
To specify a LED state, use the DlnLedSetState() function. You can check the current state of a LED by using the DlnLedGetState() function.
This example shows how to manipulate LEDs on the DLN-series adapters. You can find the complete example in the “..\Program Files\Diolan\DLN\examples\c_cpp\examples\simple
” folder after DLN setup package installation.
#include "..\..\..\common\dln_generic.h" #include "..\..\..\common\dln_led.h" #pragma comment(lib, "..\\..\\..\\bin\\dln.lib") int _tmain(int argc, _TCHAR* argv[]) { // Open device HDLN device; DlnOpenUsbDevice(&device); // Set LED1 DlnLedSetState(device, 0, DLN_LED_STATE_FAST_BLINK); // Set LED2 DlnLedSetState(device, 1, DLN_LED_STATE_TRIPLE_BLINK); // Close device DlnCloseHandle(device); return 0; }
Line 1:
The dln_generic..h
header file declares functions and data structures for the generic interface. In current example this header is used to call DlnOpenUsbDevice() and DlnCloseHandle() functions.
Line 2:
The dln_led.h header file declares functions and data structures for the LED interface. In current example this header is used to to call DlnLedSetState() function.
Line 3:
Use dln.lib
library while project linking.
Line 10:DlnOpenUsbDevice(&device);
The function establishes the connection with the DLN adapter. This application uses the USB connectivity of the adapter. For additional options, refer to the Device Opening & Identification section.
Line 13:DlnLedSetState(device, 0, DLN_LED_STATE_FAST_BLINK);
Set LED 0 to fast blink state. You can read more about available LED states at LED States section.
Line 15:DlnLedSetState(device, 1, DLN_LED_STATE_TRIPLE_BLINK);
Set LED 1 to triple blink state.
Line 18:DlnCloseHandle(device);
The application closes the handle to the connected DLN-series adapter.
This section describes the LED functions. They are used to control and monitor the LED module of a DLN-series adapter.
Actual control of the device is due to use of commands and responses. Each function utilizes respective commands and responses. You can send such commands directly if necessary.
Retrieves the total number of user-controlled LEDs
Configures the LED state.
Retrieves the current LED state.
All the functions are declared in the dln_led.h
file.
The DlnLedGetCount()
function retrieves the total number of user-controlled LEDs available in the device.
The DlnLedGetState()
function retrieves the current state of the LED.
The DlnLedSetState()
function sets a new state of the specified user-controlled LED.