Moxa UC-8410A-LX [69/86] Brtc real time clock

Moxa UC-8410A-LX [69/86] Brtc real time clock
UC-8410A Series Linux Software Programmer’s Guide
6-7
moxa@Moxa:~$ ./hello-release
Hello World
Makefile Example
The following Makefile is copied from the Hello example on the UC-8410A-LX’s example package. It is used for
cross compiling.
CC = arm-linux-gnueabihf-gcc
CPP = arm-linux-gnueabihf-g++
SOURCES = hello.c
OBJS = $(SOURCES:.c=.o)
all: hello
hello: $(OBJS)
$(CC) -o $@ $^ $(LDFLAGS) $(LIBS)
clean:
rm -f $(OBJS) hello core *.gdb
For native compiling, change:
CC = gcc
CPP = g++
Modbus
The Modbus protocol is a messaging structure used to establish master-slave/client-server communication
between intelligent devices. It is a de facto standard, truly open, and the most widely used network protocol in
industrial manufacturing environments. It has been implemented by hundreds of vendors on thousands of
different devices to transfer discrete/analog I/O and register data between control devices.
The libmodbus version in Debian 8 is v3.0.6. We use libmodbus as our modbus package. Download the source
and example code from the following link.
http://libmodbus.org/releases/libmodbus-3.0.6.tar.gz
NOTE
Click the following li
nk for more information about libmodbus:
http://libmodbus.org/
RTC (Real Time Clock)
The device node is located at /dev/rtc0. The UC-8410A-LX series supports Linux standard simple RTC control.
You must
include <linux/rtc.h
>
in your program to use the following functions.
Function RTC_RD_TIME
Description Reads time information from the RTC; returns the value of argument 3.
Usage struct rtc_time rtc_tm;
ioctl(fd, RTC_RD_TIME, &rtc_tm);
Function RTC_SET_TIME
Description Sets the RTC time. Argument 3 will be passed to the RTC.
Usage struct rtc_time rtc_tm;
ioctl(fd, RTC_SET_TIME, &rtc_tm);
Function RTC_ALM_SET
Description Sets the alarm time.
Usage struct rtc_time rtc_tm;
ioctl(fd, RTC_ALM_SET, &rtc_tm);

Содержание

Скачать