我成功地将我的nodejs应用程序放入了一个Beaglebone黑色板上的Docker容器中。但现在我想从Docker容器中访问CAN总线,但它无法正常工作。
请注意,我已经在主机上成功地配置了CAN端口,并且candump显示它可以正常工作。
$ candump can1
can1 18FF30D0 [8] 00 00 00 00 00 00 00 00
can1 18FF02D0 [4] 00 00 00 00
can1 18FF21D0 [3] 00 00 00
can1 18FF3CD0 [4] 00 7D 28 7D
can1 18FF30D0 [8] 00 03 00 00 00 00 00 00
can1 18FF02D0 [4] 00 00 00 00
我在Dockerfile中如下构建了socketcan节点模块:
#If you don't have node/npm already, add that first
RUN apk add --no-cache nodejs
# Add the necessary build and runtime dependencies (see https://dev59.com/kZXfa4cB1Zd3GeqPeWU4)
RUN apk add --no-cache make gcc g++ python3 linux-headers udev
#RUN apk add --no-cache --virtual .gyp python3 make g++
RUN npm install
当我从容器中运行我的应用程序时,我会得到以下异常:
-- - Canbus:can0: switched to channel "can0"…
Pepsr v2.1.192 5:36:40 PM [pepsr-iingenierie] -- - Canbus:can0: cancel CAN as other channel "can0" doesn’t work either
Pepsr v2.1.192 5:36:40 PM [pepsr-iingenierie] -- - Canbus:can0: Error: Error while creating channel
at Object.exports.createRawChannel (/home/debian/Desktop/devel/iot/node_modules/socketcan/socketcan.js:38:12)
at Canbus._connect (/home/debian/Desktop/devel/iot/pepsr.ddk.protocol.canBus.js:308:34)
at Canbus.connect (/home/debian/Desktop/devel/iot/pepsr.module.js:272:9)
at Object.<anonymous> (/home/debian/Desktop/devel/iot/pepsr.js:608:20)
at Module._compile (internal/modules/cjs/loader.js:1015:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
at Module.load (internal/modules/cjs/loader.js:879:32)
at Function.Module._load (internal/modules/cjs/loader.js:724:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
at internal/main/run_main_module.js:17:47