60
Appendix
Appendix C: Ubutu Command Code
This section includes Ubuntu command code.
Brightness
The source code is located in
/sys/class/backlight/backlight.25/brightness
We use “
sudo sh -
c "echo 3 > /sys/class/backlight/backlight.25/brightness”
”
to set the brightness.
The range is between 0 to 7.
Use the command “
cat /sys/class/backlight/backlight.25/brightness”
to get the brightness
information.
System information
Execute
uname -a
Linux arm 3.14.52-1.1.1_ga+gb93b878 #15 SMP PREEMPT Mon Aug 8 19:13:40 CST 2016
armv7l armv7l armv7l GNU/Linux
Execute
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04 LTS
Release:16.04
Codename: xenial
Serial Port
a. Open COM Port
// ***************************************************************************
//
Parameter:
// static char *portname = "/dev/ttyUSB0";
// static int COMPort_fd;
//
Baud rate: 115200
//
bits per second: 8
//
parity: none
//
stop bits: 1
//
// ***************************************************************************
static void
cmd_open
(void)
{
COMPort_fd = open (portname, O_RDWR | O_NOCTTY | O_SYNC);
if
(
COMPort_fd
<
0
)
{
printf(
"error %d opening %s: %s\n"
,
errno, portname, strerror (errno)
);
return
;
}
else
{
printf(
"Open sccuess\n"
);
}
set_interface_attribs
(
COMPort_fd, B115200,
0
);
// set baudrate 8n1 (no parity)
set_blocking
(COMPort_fd,
0
);
// set no blocking
printf(
"COM initial ok\n"
);