Development of GUI Programs with QT Library. Advantech RSB-4220


Add to my manuals
78 Pages

advertisement

Development of GUI Programs with QT Library. Advantech RSB-4220 | Manualzz

3.9.2

Development of GUI Programs with QT Library

With the development kit, you can develop a qt-based GUI program. Follow these steps, you can quickly convert your QT Project to a GUI application for RSB-4220:

1.

On your host PC, set up QT Build Environment.

#source /usr/local/cross_compiler/linux-devkit/environment-setup

2.

Build QT Instructions:

# cd projectdir

# qmake projectName.pro

# make

3.Run QT demo:

# ./qtappName -qws

Note!

The -qws Parameter tell the QT Application to run as a server.

3.9.3

Demo program source code

3.9.3.1

Serial Port Programming

Please refer to <BSP_PATH>/source/demo/uart

It is an example of sending and receiving data via the serial port.

Receiving data:

# ./uart_ctrl read /dev/ttyO1

Sending data:

# ./uart_ctrl write /dev/ttyO2

Before using your program of serial port, please ensure that your serial port is in 232/

422/485 mode.

User can reference the uart demo source code to develop the uart application.

3.9.3.2

Watchdog Programming

RSB-4220 support hardware watchdog, the watchdog API is follow posix standards.

The valid timeout value is from 1 to 6553 seconds, if the timeout value to set is not in this scope, driver will set timeout value to default value (60 seconds).

Sample C code:

#include <stdio.h>

#include <stdlib.h>

#include <fcntl.h>

#include <signal.h>

#include <linux/watchdog.h> int fd; int main(int argc, const char *argv[]) { int timeout = 10;

/*open watchdog device, the watchdog device node is /dev/watchdog */ fd=open("/dev/watchdog",O_WRONLY);

/*set timeout to 10 seconds*/

57 RSB-4220 User Manual

/*when set timeout value, the watchdog driver will enable the watchdog automatically.*/ ioctl (fd, WDIOC_SETTIMEOUT, &timeout); while (1)

{

/*feed the watchdog every 5 seconds*/

/*when call this funtion to feed watchdog, the watchdog will reset its internal timer so it doesn't trigger the board reset. If do not feed the watchdog more than 10 seconds, the watchdog will timeout and the board will reset.*/ ioctl( fd, WDIOC_KEEPALIVE, NULL ); sleep (5);

} close (fd);

}

Here are some other APIs for watchdog.

Disable the watchdog timer sample code:

/*if user want to disable the watchdog before timeout, call the following ioctl function*/ int i_dis = WDIOS_DISABLECARD; ioctl( fd, WDIOC_SETOPTIONS, &i_dis );

Enable the watchdog timer sample code:

/*if user want to enable the watchdog again before timeout when it is disabled, call the following ioctl function. */ int i_en = WDIOS_ENABLECARD; ioctl( fd, WDIOC_SETOPTIONS, & i_en);

Get the current timeout value:

/*get the current timeout value the driver used*/ int timeout = 0; ioctl (fd, WDIOC_GETTIMEOUT, &timeout);

Please refer to <BSP_PATH>/source/demo/watchdog folder to get more information.

RSB-4220 User Manual 58

3.9.3.3

GPIO Programming

RSB-4220 has 8 gpios. Please refer to <BSP_PATH>/source/demo/gpio

Usage:

# ./gpio 200 out 1

Note!

“200” means gpio0, and so 200-207 corresponds to gpio0-gpio7.

“out” means output .

“1” is the value set to the corresponding gpio port.

3.9.3.4

Can Programming

Please refer to <BSP_PATH>/source/demo/can_test.

Note!

Can sending data sample c code, please refer to can_write.c.

Can receiving data sample c code, please refer to can_read.c.

3.9.3.5

Brightness Programming

Please refer to <BSP_PATH>/source/demo/brightness

Brightness driver provide the sys interface, so we can set and get brightness value throught the sys file:

/sys/class/backlight/pwm-backlight/brightness

You can set brightness using flowing command:

# echo “20” > /sys/class/backlight/pwm-backlight/brightness

Note!

The value should be between 1-100.

You can get current brightness value using flowing command:

# cat /sys/class/backlight/pwm-backlight/brightness

59 RSB-4220 User Manual

RSB-4220 User Manual 60

Chapter

4

4

System Recovery

This chapter introduces how to recover Linux operating system if it is damaged accidentally.

advertisement

Was this manual useful for you? Yes No
Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Related manuals

advertisement

Table of contents