Raspberry Pi GPS 到 HTML + NodeJS
Raspberry Pi GPS to HTML + NodeJS
我目前有一个 Raspberry Pi 带有 GPS 加密狗,可以成功获取坐标。如果我 运行 cgps -s 我可以看到我需要的所有信息,我的最终目标是在 HTML 页面中显示这些信息。我目前正在使用 NodeJS 作为服务器。
如何从网页或 NodeJS 服务器访问 GPS 信息?
您应该能够 运行 使用 child_process.exec
在 NodeJS 应用程序中执行 Linux 命令
const exec = require('child_process').exec;
const child = exec('cgps -s',
(error, stdout, stderr) => {
console.log(`stdout: ${stdout}`);
console.log(`stderr: ${stderr}`);
if (error !== null) {
console.log(`error: ${error}`);
}
});
我目前有一个 Raspberry Pi 带有 GPS 加密狗,可以成功获取坐标。如果我 运行 cgps -s 我可以看到我需要的所有信息,我的最终目标是在 HTML 页面中显示这些信息。我目前正在使用 NodeJS 作为服务器。
如何从网页或 NodeJS 服务器访问 GPS 信息?
您应该能够 运行 使用 child_process.exec
在 NodeJS 应用程序中执行 Linux 命令const exec = require('child_process').exec;
const child = exec('cgps -s',
(error, stdout, stderr) => {
console.log(`stdout: ${stdout}`);
console.log(`stderr: ${stderr}`);
if (error !== null) {
console.log(`error: ${error}`);
}
});