V01.00 | 2019/04
61
7.6.5
Programming LED functions with C or C++
The following example shows the programming of the LED functions with Ansi C/C++.
#include <stdio.h>
#include <stdlib.h>
// initialize function (use extern for C++)
char* strcpy(char* target, const char* source);
char* strcat(char* s1, const char* s2);
int main(void) {
// LEDs for the customer:
char *appl_green_led = "appl_green";
char *appl_red_led = "appl_red";
char *error_green_led = "err_green";
char *error_red_led = "err_red";
char *run_green_led = "run_green";
char *run_red_led = "run_red";
char *LED_FILE = "/sys/class/leds/";
char *brightness = "/brightness";
FILE *fh;
char cur_Str[50] = {0};
strcpy(cur_Str, LED_FILE);
// take LED which will shine:
strcat(cur_Str, run_red_led);
strcat(cur_Str, brightness);
//WRITE:
printf("string to led: %s\n", cur_Str);
// write LED...
if((fh = fopen(cur_Str, "w")) != 0)
{
// write "1" to switch on and "0" to switch of LED
fputs((const char*)"0",fh);
fclose(fh);
}
else
{
printf("failed on writing ...\n");
return -1;
}
return EXIT_SUCCESS;
}
Summary of Contents for TN-UHF LNX Series
Page 1: ...Your Global Automation Partner Instructions for Use TN UHF LNX UHF Read Write Head ...
Page 2: ...2 Hans Turck GmbH Co KG T 49 208 4952 0 F 49 208 4952 264 more turck com www turck com ...
Page 75: ...V01 00 2019 04 75 Select RS485 RFID and confirm with OK Fig 62 Selecting the RS485 interface ...