Commissioning
Programming RFID channels
58
Hans Turck GmbH & Co. KG | T +49 208 4952-0 | F +49 208 4952-264 | [email protected] | www.turck.com
7.5.2
Programming RFID channels with C or C++
The following examples illustrate the programming of the RFID interface with Ansi C or C++.
#include <stdio.h>
#include <stdlib.h>
#include <termios.h>
#include <fcntl.h>
// initialize function (use extern for C++)
ssize_t write (int __fd, void *__buf, size_t __n) __wur;
ssize_t write (int __fd, const void *__buf, size_t __n) __wur;
int close (int __fd);
int main(void) {
//choose Interface for connection
const char *Path = "/dev/COM0";
struct termios options;
int fd, count, i ;
unsigned char currentBuff[1];
unsigned char InBuff[255];
unsigned char *p_InBuff = InBuff;
unsigned char Message[] = {0x0D}; //deExample command for “Get
status”
if((fd = open((Path), O_RDWR | O_NOCTTY)) != -1)
{
// Set serial Interface
tcgetattr (fd, &options);
cfsetspeed(&options, B115200);
options.c_cflags |= CS8|CSTOPB;
options.c_flags &= ~(PARENB.PARODD)
tcsetattr (fd, TCSANOW, &options);
// write to Interface COM0
if ((write(fd, Message, sizeof(Message))) == -1)
{
printf("not able to write...");
}
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...