开源改变世界

树莓派“打开串口时出错” #58

推推 grbl 3年前 (2023-02-02) 224次浏览
关闭
soswow 开了这个issue 2016 年 7 月 17 日 · 18条评论
关闭

树莓派“打开串口时出错”#58

soswow 开了这个issue 2016 年 7 月 17 日 · 18条评论

注释

树莓派“打开串口时出错” #58

我不确定我的设置有什么问题。

$ .npm/bin/cnc --host 10.0.0.23
Started the server at http://10.0.0.23:8000/.
2016-07-17T12:13:40.292Z - error: [cncserver] Error opening serial port "ttyAMA0": err={}     at /home/pi/.npm/lib/node_modules/cncjs/dist/cnc/app/index.js:1353:44

我可以通过minicomcutecom连接,但不能使用 cncjs =(
不确定接下来要尝试什么。

树莓派“打开串口时出错” #58
作者
pi@raspberrypi ~ $ node -v
v4.4.7
pi@raspberrypi ~ $ npm -v
2.15.8
树莓派“打开串口时出错” #58
合作者

我可以知道你运行的是什么版本的 cnc 吗?

$ .npm/bin/cnc -V
1.4.0
树莓派“打开串口时出错” #58
作者

1.4.0
我今天安装了它。通过 npm。

树莓派“打开串口时出错” #58
合作者

不确定它是否与串口库有关,我刚刚将最新版本(即cncjs@1.4.0)中的串口从v3.1.2升级到v4.0.1。你能尝试安装cncjs@1.3.2并检查它是否有效吗?

$ npm uninstall -g cncjs
$ npm install -g cncjs@1.3.2
树莓派“打开串口时出错” #58

在 RPi 上升级到 1.4.0 时,我遇到了同样的问题。我做了一个完整的卸载/安装而不是升级,之后它运行良好。从头开始的完整安装更新了串口版本,然后事情又开始了。

树莓派“打开串口时出错” #58
合作者

你好@soswow,

你有没有安装任何以前的版本?如果是,请按照以下建议尝试简单的卸载并重新安装@meikrantz,看看是否可以解决您遇到的问题。

树莓派“打开串口时出错” #58
作者

我之前没有安装cncjs。我只是按照有关
如何碰撞 gcc 等的说明并安装了串行端口。现在,当我想到它

  • 在碰撞 gcc 并按照这些说明进行操作之前,我尝试在
    没有 gcc 4.8 的情况下安装它,但它失败了。所以我在遇到 gcc 后再次安装。我
    会尝试卸载并重新安装。

在 2016 年 7 月 18 日星期一下午 5:15 Cheton Wu notifications@github.com写道:

你好@soswow https://github.com/soswow ,

你有没有安装任何以前的版本?如果是,请按照以下建议尝试简单的
卸载并重新安装@meikrantz
https://github.com/meikrantz,看看是否可以解决您
遇到的问题。


你收到这个是因为你被提到了。

直接回复此电子邮件,在 GitHub
#58(评论)
上查看,或 将线程静音
https://github.com/notifications/unsubscribe-auth/AAGmITVXZr3u-3t6X6NTZ1ZyTBT122C9ks5qWygAgaJpZM4JONrO

树莓派“打开串口时出错” #58
合作者

要为 Node.js v4 或更高版本编译插件(例如 serialport),需要 gcc/g++ 4.8 或更高版本。raspbian-jessie 映像随 gcc 版本 4.8 一起提供,您可以从它开始使事情变得简单。

此外,我还建议您将 NPM v2 更新为 v3,这解决了几个安装问题,并且可以以扁平的方式安装包依赖项。您可以使用以下命令升级 npm:

$ npm install -g npm
$ npm -v
3.10.5

升级到 NPM v3 后,您可能需要重新安装(即卸载和安装)全局包以重建包依赖性。

树莓派“打开串口时出错” #58
作者

我试过 npm 3。

$ sudo .npm/bin/cnc --host 10.0.0.23
Started the server at http://10.0.0.23:8000/.
2016-07-19T11:24:54.321Z - error: [cncserver] Error opening serial port "ttyAMA0": err={}     at /home/pi/.npm/lib/node_modules/cncjs/dist/cnc/app/index.js:1353:44
npm install -g cncjs
/home/pi/.npm/bin/cnc -> /home/pi/.npm/lib/node_modules/cncjs/bin/cnc

> serialport@4.0.1 install /home/pi/.npm/lib/node_modules/cncjs/node_modules/serialport
> node-pre-gyp install --fallback-to-build

node-pre-gyp ERR! Tried to download: https://github.com/EmergingTechnologyAdvisors/node-serialport/releases/download/4.0.1/serialport-v4.0.1-node-v46-linux-arm.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for serialport@4.0.1 and node@4.4.7 (node-v46 ABI) (falling back to source compile with node-gyp)
make: Entering directory '/home/pi/.npm/lib/node_modules/cncjs/node_modules/serialport/build'
  CXX(target) Release/obj.target/serialport/src/serialport.o
  CXX(target) Release/obj.target/serialport/src/serialport_unix.o
  CXX(target) Release/obj.target/serialport/src/serialport_poller.o
  SOLINK_MODULE(target) Release/obj.target/serialport.node
  COPY Release/serialport.node
make: Leaving directory '/home/pi/.npm/lib/node_modules/cncjs/node_modules/serialport/build'
/home/pi/.npm/lib
pi@raspberrypi ~ $ npm -v
3.10.5
pi@raspberrypi ~ $ which npm
/home/pi/bin/npm
pi@raspberrypi ~ $ ls -la /home/pi/bin/npm
lrwxrwxrwx 1 pi pi 21 Jul 19 10:46 /home/pi/bin/npm -> /home/pi/.npm/bin/npm
pi@raspberrypi ~ $ which node
/usr/local/bin/node
pi@raspberrypi ~ $ node -v
v4.4.7
pi@raspberrypi ~ $ ls -la /usr/local/bin/node
-rwxr-xr-x 1 root staff 22270888 Jul 19 09:51 /usr/local/bin/node

我正在为 RPI 使用 grbl shield。我会尝试他们的预构建图像。http://wiki.protoneer.co.nz/Raspberry_Pi_CNC_User_Interface_SD_Card_Image
我还下载了干净的 jessi 图像。以防万一。

此外,我正在考虑尝试编写一些简单的 nodejs 应用程序并测试我是否可以连接到该端口。用于调试目的

树莓派“打开串口时出错” #58
合作者
奇顿 评论了 2016 年 7 月 20 日  

你好@soswow,

我只是使用 USB 电缆将我的 RPi2 与运行 Grbl v0.9j 的 Arduino UNO R3 连接起来。我连接的串口是/dev/ttyUSB0,不是ttyAMA0。我可以知道您是否在 Pi 上使用 GPIO 串行设备,而不是 USB 电缆吗?

树莓派“打开串口时出错” #58

树莓派“打开串口时出错” #58
作者

正如我在上一篇中所说的。评论-我正在使用这个盾牌http://wiki.protoneer.co.nz/Raspberry_Pi_CNC@Protoneer #19

树莓派“打开串口时出错” #58

我有相同的 Protoneer 板,它显示为 /dev/ttyAMA0。我似乎记得以前必须手动卸载 serialport,但记忆有点模糊。

树莓派“打开串口时出错” #58
合作者

您可以尝试使用 serialport-terminal 工具检查它是否连接到/dev/ttyAMA0设备吗?

$ /home/pi/.npm/lib/node_modules/serialport/bin/serialport-terminal.js -p /dev/ttyAMA0 -b 115200

如果它没有报告任何错误,请使用以下配置设置~/.cncrc在您的用户主目录(即)下添加一个文件,然后再次启动:/home/pi/.cncrccnc

{
    "ports": [
        {
            "comName": "/dev/ttyAMA0",
            "manufacturer": ""
        }
    ]
}

/dev/ttyAMA0除了ttyAMA0. _

树莓派“打开串口时出错” #58
合作者
奇顿 评论了 2016 年 7 月 20 日  

node_modules/serialport/bin/serialport-terminal.js -p /dev/ttyAMA0 -b 115200
Error [Error: Error: Permission denied, cannot open /dev/ttyAMA0]

如果您遇到上述权限被拒绝的错误,您可以查看这篇文章以获取修复:
https ://www.raspberrypi.org/forums/viewtopic.php?p=139945

  1. /dev/ttyAMA0从中删除对的引用/boot/cmdline.txt

    原文内容:

    dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p6 rootfstype=ext4 elevator=deadline rootwait

    新内容:

    dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p6 rootfstype=ext4 elevator=deadline rootwait
  2. /etc/inittab通过注释掉以下行来禁用该串行端口上的 getty

    #T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
  3. 重启

树莓派“打开串口时出错” #58
合作者

请注意,您可能仍需要添加~/.cncrc我之前提到的文件才能使用/dev/ttyAMA0而不是ttyAMA0.

树莓派“打开串口时出错” #58
作者
狼吞虎咽 评论了 2016 年 7 月 20 日  

我在!

我已经用 -g 手动重新安装了串口。
我添加了 .cncrc
以为我需要--config ~/.cncrc专门运行才能看到这个新设备。我怀疑 .cncrc 是转折点。我想知道这是否是一个真正的错误?