Commissioning
Programming LED functions
74
Hans Turck GmbH & Co. KG | T +49 208 4952-0 | F +49 208 4952-264 | [email protected] | www.turck.com
7.7.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);
Summary of Contents for 100000897
Page 1: ...Your Global Automation Partner Instructions for Use TN UHF LNX UHF Reader...
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 69: ...V02 00 2021 05 69 fclose fh else printf failed on writing n return 1...
Page 75: ...V02 00 2021 05 75 else printf failed on writing n return 1 return EXIT_SUCCESS...
Page 93: ...V02 00 2021 05 93 Select RS485 RFID and confirm with OK Fig 67 Selecting the RS485 interface...
Page 97: ...V02 00 2021 05 97 Click the Select BL File button Fig 73 Button selecting a BL file...