跳到主要内容

接口定义

LPR3588 计算机由临滴 Neardi-PI4 多功能开发板 和 Neardi Pi 拓展板 组成,外设资源丰富,主要支持以下外设:

整机接口定义​

LPR3588 提供了丰富的接口,具体如下图:

image

丝印设备节点备注
Type-C烧录口,兼容 Type-C 转 DP 输出
Debug调试串口,UART2 转 USB输出,只能用来系统调试
USB1Type-A USB2.0 host
USB2Type-A USB3.0 host
ETH0eth0千兆网卡
ETH1eth1千兆网卡
WIFIwlan02.4/5GHz
CANcan0CAN总线
RS485-1/dev/ttyS8串口,默认波特率9600,自动收发
RS485-2/dev/ttyS7串口,默认波特率9600,自动收发
MIC麦克风接口
Headphone耳机接口
SPEAKER播放音频文件
HDMI1card0-HDMI-A-1HDMI输出,最高支持8K@60fps
Mini-PCIE4G/5G模块
PWR LED电源灯
4G LED4G灯
SYS LEDwork1系统灯
STA LEDwork2STA灯
RTC/dev/rtc0RTC时钟

通信接口​

RS485 使用​

串口是一种常见的通信接口,用于与外部设备进行串行通信。

LPR3588 提供了 2 个 RS485,RS485-1设备文件为/dev/ttyS8,RS485-2设备文件为/dev/ttyS7 ,默认固件支持 RS485 自动收发。

1.在使用串口之前,需要确保串口连接正确,以及波特率和其他参数设置一致。

配置串口参数:9600 波特率、8 位数据位、1 位停止位、无校验、无流控:

stty -F /dev/ttysWK3 9600 cs8 -parenb -cstopb -ixon -ixoff -icanon -echo

9600:波特率(根据你的硬件改,如 115200);
cs8:8 位数据位;
-parenb:无校验位;
-cstopb:1 位停止位;
-ixon/-ixoff:关闭软件流控;
-icanon:关闭行规则(避免自动补回车);
-echo:关闭回显(避免接收端自己回显数据)。

对端设备等待接收字符串

cat /dev/ttyS7

LPR3588 设备发送字符串到对端设备

echo "neardi RS485 test…" > /dev/ttyS7

对端设备的串口终端接收到字符串 “neardi RS485 test…” 即通信成功,LPR3588 接收数据类似。

2.默认固件 RS485 支持自动收发。若无法自动收发,可通过以下内容配置 RS485 流控:

在开发板设备上运行下列命令:

# RS485-1:索引 122 设置流控
# RS485-2:索引 22 设置流控

# 导出索引 22 GPIO,配置为输出模式
echo 22 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio22/direction
# 拉高发送
echo 1 > /sys/class/gpio/gpio22/value
# 拉低接收
echo 0 > /sys/class/gpio/gpio22/value

3V & 5V 开关​

3V and 5V 开关由 GPIO1_D3 控制,GPIO 索引 59, 执行以下命令:

echo 59 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio59/direction
# 拉高开启
echo 1 > /sys/class/gpio/gpio59/value
# 拉低关闭
echo 0 > /sys/class/gpio/gpio59/value

CAN 使用​

LPR3588 提供了一个 CAN 接口,不支持 CAN FD,最大波特率 1M。在使用CAN之前,需要确保CAN设备连接正确,以及波特率和其他参数设置一致。

默认固件包含使用 candump 和 cansend 工具进行收发报文测试即可,若没有工具可以 sudo apt instll can-utils 安装。

# 先关闭can
ip link set can0 down
# 设置 CAN 速率 1M
ip link set can0 type can bitrate 1000000
# up can0设备
ip link set can0 up
# 设置传输的buffer大小
echo 4096 > /sys/class/net/can0/tx_queue_len
# can接收
candump can0
# can发送
cansend can0

更多指令

1、 ip link set canX down //关闭can设备;
2、 ip link set canX up //开启can设备;
3、 ip -details link show canX //显示can设备详细信息;
4、 candump canX //接收can总线发来数据;
5、 ifconfig canX down //关闭can设备,以便配置;
6、 ip link set canX up type can bitrate 1000000 //设置can波特率
7、 conconfig canX bitrate + 波特率;
8、 canconfig canX start //启动can设备;
9、 canconfig canX ctrlmode loopback on //回环测试;
10、canconfig canX restart // 重启can设备;
11、canconfig canX stop //停止can设备;
12、canecho canX //查看can设备总线状态;
13、cansend canX --identifier=ID+数据 //发送数据;
14、candump canX --filter=ID:mask //使用滤波器接收ID匹配的数据

音频配置​

MIC 使用​

使用以下命令可以录制音频文件,支持 wav、mp3 等格式。

录制双声道的 16 位小端格式的音频,采样率为 48000Hz,然后保存为 001.wav 文件。

  • Cmd
  • C
  • Python
arecord -Dhw:0,0 -r48000 -f S16_LE -c2 > 001.wav

• -Dhw:0,0 指定了录音设备,0,0 是card 0 device 0,也就是第一个声卡的第一个设备。

• -r48000 指定了采样率,单位是Hz,48000表示每秒采样48000次。

• -f S16_LE 指定了采样格式,S16_LE表示有符号的16位小端格式,也就是每个采样点占用2个字节,低位在前,高位在后。

• -c2 指定了声道数,2表示双声道,也就是立体声。

• > 001.wav 指定了输出文件,>表示重定向标准输出到文件,001.wav表示文件名,wav表示文件格式。

create audio_record.c

#include <stdio.h>
#include <stdlib.h>
#include <alsa/asoundlib.h>

#define SAMPLE_RATE 44100 // Replace SAMPLE_RATE with a local variable
#define CHANNELS 2 // Replace CHANNELS with a local variable

int main(int argc, char *argv[]) {
const char *device = "hw:0,0"; // Set the audio device
snd_pcm_t *pcm_handle;
snd_pcm_hw_params_t *params;
unsigned int sample_rate = SAMPLE_RATE; // Use a modifiable local variable
int channels = CHANNELS; // Use a modifiable local variable
int pcm, dir;
snd_pcm_uframes_t frames = 32;
FILE *file = fopen("001.wav", "wb");
if (!file) {
perror("Unable to create audio file");
return 1;
}

// Open PCM device
if ((pcm = snd_pcm_open(&pcm_handle, device, SND_PCM_STREAM_CAPTURE, 0)) < 0) {
fprintf(stderr, "Unable to open PCM device %s: %s\n", device, snd_strerror(pcm));
fclose(file);
return 1;
}

// Set hardware parameters
snd_pcm_hw_params_alloca(&params);
snd_pcm_hw_params_any(pcm_handle, params);
snd_pcm_hw_params_set_access(pcm_handle, params, SND_PCM_ACCESS_RW_INTERLEAVED);
snd_pcm_hw_params_set_format(pcm_handle, params, SND_PCM_FORMAT_S16_LE);
snd_pcm_hw_params_set_channels(pcm_handle, params, channels); // Use the variable channels
snd_pcm_hw_params_set_rate_near(pcm_handle, params, &sample_rate, &dir); // Use the variable sample_rate

// Apply parameters
if ((pcm = snd_pcm_hw_params(pcm_handle, params)) < 0) {
fprintf(stderr, "Unable to set hardware parameters: %s\n", snd_strerror(pcm));
snd_pcm_close(pcm_handle);
fclose(file);
return 1;
}

// Get buffer size
snd_pcm_hw_params_get_period_size(params, &frames, &dir);
int buffer_size = frames * channels * 2; // 2 bytes per channel
char *buffer = (char *)malloc(buffer_size);

// Write WAV file header
fwrite("RIFF", 1, 4, file);
fwrite("----", 1, 4, file); // Placeholder
fwrite("WAVE", 1, 4, file);
fwrite("fmt ", 1, 4, file);
int subchunk1_size = 16;
short audio_format = 1;
fwrite(&subchunk1_size, 4, 1, file);
fwrite(&audio_format, 2, 1, file);
fwrite(&channels, 2, 1, file); // Use the variable channels
fwrite(&sample_rate, 4, 1, file); // Use the variable sample_rate
int byte_rate = sample_rate * channels * 2;
fwrite(&byte_rate, 4, 1, file);
short block_align = channels * 2;
fwrite(&block_align, 2, 1, file);
short bits_per_sample = 16;
fwrite(&bits_per_sample, 2, 1, file);

// Write WAV data header
fwrite("data", 1, 4, file);
fwrite("----", 1, 4, file); // Placeholder

printf("Starting recording...\n");

// Start recording
int total_data_size = 0;
while (1) {
pcm = snd_pcm_readi(pcm_handle, buffer, frames);
if (pcm == -EPIPE) {
snd_pcm_prepare(pcm_handle);
} else if (pcm < 0) {
fprintf(stderr, "Recording failed: %s\n", snd_strerror(pcm));
break;
}
fwrite(buffer, 1, buffer_size, file);
total_data_size += buffer_size;
}

// Update WAV file size
fseek(file, 4, SEEK_SET);
int file_size = total_data_size + 36;
fwrite(&file_size, 4, 1, file);
fseek(file, 40, SEEK_SET);
fwrite(&total_data_size, 4, 1, file);

// Clean up resources
free(buffer);
snd_pcm_drain(pcm_handle);
snd_pcm_close(pcm_handle);
fclose(file);

printf("Recording complete\n");
return 0;
}
gcc audio_record.c -o audio_record -lasound
./audio_record

Install the PyAudio library:

sudo apt update
sudo apt install python3-pip
sudo apt install portaudio19-dev
pip3 install pyaudio

create audio_record.py

import wave
import pyaudio

# Audio format parameters
FORMAT = pyaudio.paInt16 # 16-bit PCM
CHANNELS = 2
RATE = 48000 # Sample rate
CHUNK = 4096 # Buffer size

# Create a PyAudio object
p = pyaudio.PyAudio()

# Open an audio stream
stream = p.open(format=FORMAT,
channels=CHANNELS,
rate=RATE,
input=True,
frames_per_buffer=CHUNK)

# Open a WAV file for writing
wf = wave.open('001.wav', 'wb')
wf.setnchannels(CHANNELS)
wf.setsampwidth(p.get_sample_size(FORMAT))
wf.setframerate(RATE)

print("Recording...")

# Record audio data
try:
while True:
data = stream.read(CHUNK)
wf.writeframes(data)
except KeyboardInterrupt:
print("Recording stopped.")

# Clean up
print("Recording complete. Saved as 001.wav")
stream.stop_stream()
stream.close()
p.terminate()
wf.close()
python audio_record.py

LINE/SPK 使用​

  • 音频默认从扬声器(SPK)输出。
# 配置SPK通路打开
amixer -c 0 cset name='OUT2 Switch' on

使用第一个声卡的第一个设备播放001.wav文件。

  • Cmd
  • C
  • Python
aplay -D hw:0,0 001.wav

• -D hw:0,0 指定了播放设备,hw:0,0 是card 0 device 0,也就是第一个声卡的第一个设备。

• 001.wav 指定了音频文件,wav表示文件格式,001表示文件名。

Install the ALSA library and its development headers:

sudo apt update
sudo apt install libasound2-dev

create audio_play.c

#include <stdio.h>
#include <stdlib.h>
#include <alsa/asoundlib.h>

int main(int argc, char *argv[]) {
const char *device = "hw:0,0"; // Set audio device
const char *filename = "001.wav"; // Audio file path
snd_pcm_t *pcm_handle;
snd_pcm_hw_params_t *params;
unsigned int sample_rate = 44100; // Sample rate
int pcm, dir;
snd_pcm_uframes_t frames;
FILE *file;
char *buffer;
int buffer_size;

// Open audio file
file = fopen(filename, "rb");
if (!file) {
perror("Unable to open audio file");
return 1;
}

// Open PCM device
if ((pcm = snd_pcm_open(&pcm_handle, device, SND_PCM_STREAM_PLAYBACK, 0)) < 0) {
fprintf(stderr, "Unable to open PCM device %s: %s\n", device, snd_strerror(pcm));
fclose(file);
return 1;
}

// Set hardware parameters
snd_pcm_hw_params_alloca(&params);
snd_pcm_hw_params_any(pcm_handle, params);
snd_pcm_hw_params_set_access(pcm_handle, params, SND_PCM_ACCESS_RW_INTERLEAVED);
snd_pcm_hw_params_set_format(pcm_handle, params, SND_PCM_FORMAT_S16_LE);
snd_pcm_hw_params_set_channels(pcm_handle, params, 2);
snd_pcm_hw_params_set_rate_near(pcm_handle, params, &sample_rate, &dir);

// Apply parameters
if ((pcm = snd_pcm_hw_params(pcm_handle, params)) < 0) {
fprintf(stderr, "Unable to set hardware parameters: %s\n", snd_strerror(pcm));
snd_pcm_close(pcm_handle);
fclose(file);
return 1;
}

// Get frame size and buffer size
snd_pcm_hw_params_get_period_size(params, &frames, &dir);
buffer_size = frames * 4; // 2 channels, each sample is 2 bytes
buffer = (char *) malloc(buffer_size);

// Play audio
while (fread(buffer, 1, buffer_size, file) > 0) {
if ((pcm = snd_pcm_writei(pcm_handle, buffer, frames)) == -EPIPE) {
snd_pcm_prepare(pcm_handle);
} else if (pcm < 0) {
fprintf(stderr, "Playback failed: %s\n", snd_strerror(pcm));
}
}

// Cleanup
free(buffer);
snd_pcm_drain(pcm_handle);
snd_pcm_close(pcm_handle);
fclose(file);

printf("Playback completed\n");
return 0;
}
gcc audio_play.c -o audio_play -lasound
./audio_play

Install the PyAudio and wave libraries:

sudo apt update
sudo apt install python3-pyaudio

create audio_play.py

import pyaudio
import wave

def play_audio(filename):
# Open WAV audio file
with wave.open(filename, 'rb') as wf:
# Initialize PyAudio
p = pyaudio.PyAudio()

# Configure audio stream
stream = p.open(format=p.get_format_from_width(wf.getsampwidth()),
channels=wf.getnchannels(),
rate=wf.getframerate(),
output=True)

# Read and play audio data
data = wf.readframes(1024)
while data:
stream.write(data)
data = wf.readframes(1024)

# Stop and close audio stream
stream.stop_stream()
stream.close()

# Terminate PyAudio
p.terminate()
print("Playback completed")

# Play file
play_audio('001.wav')
python3 audio_play.py

视频显示​

HDMI/DP 说明​

xrandx命令可以查看当前HDMI连接:

neardi@3588:~$ xrandr
Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 16384 x 16384
HDMI-1 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
1920x1080 60.00*+ 60.00 50.00 30.00 24.00
4096x2160 24.00
3840x2160 30.00 25.00 24.00
1920x1080i 60.00 50.00
1280x720 60.00 60.00 50.00 50.00 30.00 24.00
720x576 50.00 50.00
720x480 59.94 59.94 59.94

完整节点

HDMI:/sys/devices/platform/display-subsystem/drm/card0/card0-HDMI-A-1/

查看 HDMI 所支持分辨率:

cat /sys/devices/platform/display-subsystem/drm/card0/card0-HDMI-A-1/modes

[设置 HDMI 输出其他分辨率]


网络配置​

ETH 说明​

1.可以通过调试串口、ssh 或者 adb 来查看 IP 地址,例如:

root@RK3588:/home/neardi# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host noprefixroute
valid_lft forever preferred_lft forever
2: can0: <NOARP,ECHO> mtu 16 qdisc noop state DOWN group default qlen 10
link/can
3: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
link/ether 7e:3f:c8:42:ac:78 brd ff:ff:ff:ff:ff:ff
4: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 82:3f:c8:42:ac:78 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.105/24 brd 192.168.1.255 scope global dynamic noprefixroute eth1
valid_lft 86396sec preferred_lft 86396sec
inet6 fe80::3830:893:e61b:6959/64 scope link noprefixroute
valid_lft forever preferred_lft forever

2.通过 ethtool 或者 iperf3 测试网络速率:

root@RK3588:/# ethtool eth0
Settings for eth0:
Supported ports: [ TP MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Supported pause frame use: Symmetric Receive-only
Supports auto-negotiation: Yes
Supported FEC modes: Not reported
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Advertised pause frame use: Symmetric Receive-only
Advertised auto-negotiation: Yes
Advertised FEC modes: Not reported
Speed: 1000Mb/s <---------- 千兆速率
Duplex: Full
Auto-negotiation: on
Port: Twisted Pair
PHYAD: 0
Transceiver: external
MDI-X: Unknown
Supports Wake-on: ug
Wake-on: d
Current message level: 0x0000003f (63)
drv probe link timer ifdown ifup
Link detected: yes

iperf3 用来测试以太网吞吐。测试时一端作为服务端,LPR3588 可以作为客户端连接过去。

服务端:

iperf3 -s

客户端:

iperf3 -c <server-ip> -t 30

例如:

iperf3 -c 192.168.1.250 -t 30

Wi-Fi 说明​

通过如下命令查看当前Wi-Fi型号:

cat /sys/bus/sdio/devices/mmc2\:0001\:1/vendor
cat /sys/bus/sdio/devices/mmc2\:0001\:1/device
  • 0x02d0:0xaae8:AP6275S.
  • 0x024c:0xb852:RTL8852.
  • 0x024c:0xd723:RTL8723DS.
  • 0x024c:0xc821:RTL8821CS.
  • 0x1ffe:0x6316:FD7352S.
  • 0x0000:0x0000:FD7256S。

Connect Wi-Fi:

执行以下命令快捷连接 WiFi:

nmtui

执行以下命令,使用 nmcli 连接 WiFi:

  • Cmd

  • C

  • Search Wi-Fi:

sudo nmcli device wifi rescan
  • Show all Wi-Fi:
nmcli dev wifi list
  • Connect Wi-Fi:
sudo nmcli device wifi connect neardi_5G password neardi_pwd

• neardi_5G 是WiFi 网络(SSID) 的名称。

• neardi_pwd 是连接到该WiFi 网络所需的密码。

• sudo 用于确保nmcli 具有管理网络连接所需的权限,因为在某些系统上连接到WiFi 网络可能需要管理权限。

create connect_wifi.c

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

void connect_to_wifi(const char *ssid, const char *password) {
char command[256];

// Create the WPA configuration file without the -e option
snprintf(command, sizeof(command), "echo 'network={\\n ssid=\"%s\"\\n psk=\"%s\"\\n}' | sudo tee /etc/wpa_supplicant/wpa_supplicant.conf", ssid, password);
if (system(command) != 0) {
perror("Failed to create wpa_supplicant.conf");
return;
}

// Run wpa_supplicant
if (system("sudo wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf") != 0) {
perror("Failed to start wpa_supplicant");
return;
}

// Obtain an IP address
if (system("sudo dhclient wlan0") != 0) {
perror("Failed to obtain an IP address");
}
}

int main() {
const char *ssid = "neardi_5G";
const char *password = "neardi_pwd";

connect_to_wifi(ssid, password);
return 0;
}
gcc connect_wifi.c -o connect_wifi
sudo ./connect_wifi

热点AP 配置教程


4G/5G GPS 模块使用​

LPR3588 默认不带 4G/5G 和 GPS 模块,需要选装。

使用教程可查看:[4G/5G 拨号教程]


存储设备​

SSD的使用​

首先需确定使用的 SSD 接口是什么类型,LPR3588 SSD 使用 PCIe3x4 控制器,通过 port0 2lane 差分信号线进行通信。

接入 SSD 后,通过 lspci 查看 LPR3588 是否识别到 SSD。

识别到后通过 lsblk 查看 SSD 生成的块设备节点,默认自动挂载,可通过 df -h 查看挂载点。

若未自动挂载,可能 SSD 接口定义和 LPR3588 不匹配,或者 SSD 未分区、类型不匹配

SSD 未分区,通过以下命令进行分区:

sudo fdisk /dev/sda

# 命令(输入 m 获取帮助):m
# d 删除分区
# n 添加新分区
# p 打印分区表
# w 将分区表写入磁盘并退出
# q 退出而不保存更改

SSD 类型不匹配,通过以下命令格式化为 linux 常用文件系统格式:

sudo mkfs.ext4 /dev/sda1

TF卡使用​

查看已连接设备:

lsblk 命令可以列出系统中的所有块设备,包括硬盘、SSD、USB 驱动器、TF 卡等。

输出示例:

neardi@LPA3588:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
mmcblk0 179:0 0 115.2G 0 disk
├─mmcblk0p1 179:1 0 1M 0 part
├─mmcblk0p2 179:2 0 4M 0 part
├─mmcblk0p3 179:3 0 4M 0 part
├─mmcblk0p4 179:4 0 64M 0 part
├─mmcblk0p5 179:5 0 128M 0 part
├─mmcblk0p6 179:6 0 32M 0 part
└─mmcblk0p7 179:7 0 115G 0 part /
mmcblk0boot0 179:32 0 4M 1 disk
mmcblk0boot1 179:64 0 4M 1 disk
mmcblk1 179:96 0 58.6G 0 disk
├─mmcblk1p1 179:97 0 4M 0 part
├─mmcblk1p2 179:98 0 4M 0 part
├─mmcblk1p3 179:99 0 64M 0 part
├─mmcblk1p4 179:100 0 128M 0 part
├─mmcblk1p5 179:101 0 32M 0 part
└─mmcblk1p6 179:102 0 58.4G 0 part /media/neardi/47a3b5be-53bd-4d96-b3d0-e095c4879f34

默认挂载在/media/neardi/,如果你想挂载在其他地方,请按照以下说明操作:

# umount
sudo umount /media/neardi
# mount
sudo mount /dev/mmcblk0p1 /mnt/tfcard

如果权限不足,执行 sudo chown -R neardi:neardi /media/neardi.


时间配置​

RTC时钟​

LPR3588 RTC 时钟使用 HYM8563 芯片。

如何修改RTC时钟为'2025-11-11 12:00:00'

  • Cmd
  • C
#关闭网络时间协议(NTP)的服务,使得RTC时钟不受网络时间的影响
timedatectl set-ntp false
#设置RTC时钟的时间为2025年11月11日12时00分00秒
timedatectl set-time '2025-11-11 12:00:00'
#将RTC时钟的时间同步到系统时钟,使得系统时钟和RTC时钟保持一致,可加在/etc/init.d/rockchip.sh中
hwclock --hctosys

create time_setter.c

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>

void exec_command(const char *cmd) {
int ret = system(cmd);
if (ret != 0) {
fprintf(stderr, "Command failed: %s\n", cmd);
exit(1);
}
}

// Set system time
void set_system_time(const char *time_str) {
char cmd[128];
snprintf(cmd, sizeof(cmd), "timedatectl set-time '%s'", time_str);
exec_command(cmd);
}

// Disable NTP
void disable_ntp() {
exec_command("timedatectl set-ntp false");
}

// Synchronize hardware clock to system clock
void sync_hwclock_to_system() {
exec_command("hwclock --hctosys");
}

// Print help information
void print_usage() {
printf("Usage: time_setter -t <time>\n");
printf(" -t <time> Set system time (format: 'YYYY-MM-DD HH:MM:SS')\n");
printf(" -h Show help\n");
}

int main(int argc, char *argv[]) {
if (argc != 3) {
print_usage();
return 1;
}

const char *time_str = NULL;

int opt;
while ((opt = getopt(argc, argv, "t:h")) != -1) {
switch (opt) {
case 't':
time_str = optarg;
break;
case 'h':
default:
print_usage();
return 0;
}
}

if (time_str == NULL) {
fprintf(stderr, "Error: Time argument is required\n");
print_usage();
return 1;
}

// 1. Disable NTP
disable_ntp();

// 2. Set system time
set_system_time(time_str);

// 3. Synchronize hardware clock to system clock
sync_hwclock_to_system();

printf("Time has been set to: %s\n", time_str);
return 0;
}
gcc -o time_setter time_setter.c
./time_setter -t "2025-11-11 12:00:00"

指示灯​

  1. Power 电源指示灯,常亮表示设备已通电且电源正常供电。
  2. SYS 系统状态灯,正常运行时周期性闪烁,表示系统主控正常运行。
  3. STA 状态指示灯,可用于反映系统工作状态、应用层心跳,正常时闪烁。
  4. 4G 灯,行为由所用拨号模块(如 Quectel EC20)定义,例如:
  • 常亮:已注册网络
  • 闪烁:正在拨号或数据传输中
  • 熄灭:无信号或模块未初始化