2017-07-23 140 views
0

我目前有一個樹莓派與GPS加密狗成功獲取座標。如果我運行cgps -s,我可以看到所有需要的信息,而且我的最終目標是在HTML頁面中顯示此信息。我目前使用NodeJS作爲服務器。樹莓派GPS到HTML + NodeJS

如何從網頁或NodeJS服務器訪問GPS信息?

回答

1

你應該使用child_process.exec

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}`); 
    } 
}); 
+0

感謝您的幫助能夠在應用程序的NodeJS運行Linux命令! – Jareth