beautypg.com

Device api, Rtc (real time clock), Buzzer – Moxa Technologies UC-7420/7410 User Manual

Page 80

background image

UC-7420/7410 User’s Manual

Programmer’s Guide

5-4

2. Use the following command on the host to change to the directory that contains hello-debug:

cd /my_work_directory/myfilesystem/testprograms

3. Enter the following command:

#ddd --debugger mxscaleb-gdb hello-debug &

4. Enter the following command at the GDB, DDD command prompt:

Target remote 192.168.4.99:2000

The command produces another line of output on the target console, similar to the following:

Remote debugging using 192.168.4.99:2000

192.168.4.99 is the machine’s IP address, and 2000 is the port number. You can now begin
debugging in the host environment using the interface provided by DDD.

5. Set a breakpoint on main by double clicking, or entering

b main

on the command line.

6. Click the cont button

Device API

UC-7420/7410 supports control devices with the ioctl system API. You will need to include
, and use the following ioctl function.

int ioctl(int d, int request,…);

Input: int d - open device node return file handle

int request – argument in or out

Use the desktop Linux’s man page for detailed documentation:

#man ioctl

RTC (Real Time Clock)

The device node is located at /dev/rtc. UC-7420/7410 supports Linux standard simple RTC
control. You must include .

1. Function: RTC_RD_TIME

int ioctl(fd, RTC_RD_TIME, struct rtc_time *time);

Description: read time information from RTC. It will return the value on argument 3.

2. Function: RTC_SET_TIME

int ioctl(fd, RTC_SET_TIME, struct rtc_time *time);

Description: set RTC time. Argument 3 will be passed to RTC.

Buzzer

The device node is located at /dev/console. UC-7420/7410 supports Linux standard buzzer control,
with UC-7420/7410’s buzzer running at a fixed frequency of 100 Hz. You must include
.

1. Function: KDMKTONE

ioctl(fd, KDMKTONE, unsigned int arg);

Description: The buzzer’s behavior is determined by the argument arg. The “high word” part
of arg gives the length of time the buzzer will sound, and the “low word” part gives the
frequency.

The buzzer’s on / off behavior is controlled by software. If you call the “ioctl” function, you
MUST set the frequency at 100 Hz. If you use a different frequency, the system could crash.