I successfully dockerized my nodejs app running on a Beaglebone black. But now I'd like to access to the CAN from within the docker container but it doesn't work.
Note that I successfully configured the CAN ports in the host and candump shows it works.
$ 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
I build socketcan node module in my Dockerfile as follows:
#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://stackoverflow.com/questions/36202095/node-serialport-failing-on-alpine-linux)
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
Once I run my app from the container, I get the following exception:
-- 🟡- 🚎 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
Thanks to the contributors who led me to a solution.
I finally found that the easiest way to let the container access to the host CAN bus is to use the --network parameter as follows:
$ docker run --rm --network=host <your image>
Forwarding network interfaces to Docker is more or less described here: Sharing virtual network with docker container
Related
I have an empty Javacard as below:
user#system$ java -jar gp.jar --list
ISD: A000000003000000 (OP_READY)
Privs: SecurityDomain, CardLock, CardTerminate, CardReset, CVMManagement
And I have installed a weird applet on it:
user#system$ java -jar gp.jar --install applet.cap
CAP loaded
user#system$
Well, the applet is installed successfully:
user#system$ java -jar gp.jar --list
ISD: A000000003000000 (OP_READY)
Privs: SecurityDomain, CardLock, CardTerminate, CardReset, CVMManagement
APP: 01020304050601(SELECTABLE)
PKG: 010203040506(LOADED)
user#system$
But when I am try to delete the applet I fail:
user#system$ java -jar gp.jar --delete 01020304050601 --debug --verbose
# Successful Mutual Authentication with Security Level = 01 (CMAC)
A>> 84F28002 0A 4F00<CMAC> 00
A<< E3114F08A0000000030000009F700101C5019E 9000
A>> 84F24002 0A 4F00<CMAC> 00
A<< E3104F07010203040506019F700107C50100 9000
A>> 84F21002 0A 4F00<CMAC> 00
A<< E30F4F060102030405069F700101C50100 9000
A>> 84F22002 0A 4F00<CMAC> 00
A<< E30C4F060102030405069F700101 9000
A>> 84E40000 11 4F0701020304050601<CMAC>
A<< 6985
Could not delete D3646467329901. Some app still active?
I have tried the following forms of delete command too:
user#system$ java -jar gp.jar --delete 01020304050601 --force ==> Same result
user#system$ java -jar gp.jar --delete 010203040506 ==> Same result
The only successful form which I can use to delete the applet, is as below:
user#system$ java -jar gp.jar --delete 010203040506 --force
# Successful Mutual Authentication with Security Level = 01 (CMAC)
A>> 84F28002 0A 4F00<CMAC> 00
A<< E3114F08A0000000030000009F700101C5019E 9000
A>> 84F24002 0A 4F00<CMAC> 00
A<< E3104F07010203040506019F700107C50100 9000
A>> 84F21002 0A 4F00<CMAC> 00
A<< E30F4F060102030405069F700101C50100 9000
A>> 84F22002 0A 4F00<CMAC> 00
A<< E30C4F060102030405069F700101 9000
A>> 84E40080 10 4F06010203040506<CMAC>
A<< 9000
The applet and its packages is gone now:
user#system$ java -jar gp.jar --list
ISD: A000000003000000 (OP_READY)
Privs: SecurityDomain, CardLock, CardTerminate, CardReset, CVMManagement
Question: Why do I need to delete the package to delete the applet itself?
Note that this situation appears for a specific cap file only.
FYI: I have tried different tools (Including gpshell, pyapdu, etc.) and I got same results.
The uninstallation process of the applet does not run successfully, therfore the applet instance cannot be deleted alone, most probably you have static content like private static transient byte array declared in the applet code. In this case you must deinitialize any static objects to null by overriding Applet's uninstall method. Check object ownership in the JCRE to understand the problem
An external USB 3.0 HDD Seagate Expantion Drive 1TB is connected to my Raspberry Pi 4B on the Raspbian Buster.
The hard drive rarely works, so the first thing I would like it to shut down during idle time (rotation stopped).
I must say right away that I tried the "hdparm" utility, but it absolutely does not work for me. On my old Raspberry Pi 3B +, it did its job perfectly, but it doesn’t work at all on the new one.
I tried doing
sudo hdparm -S 10 / dev / sda1
and
sudo hdparm -Y / dev / sda1
But all he gives out is
/dev/sda:
issuing sleep command
SG_IO: bad / missing sense data, sb []: 70 00 05 00 00 00 00 0a 00 00 00 00 24 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
At the same time, the disk continues to rotate and the LED on the case is on, no matter how much I wait
I also tried to register the following settings in hdparm.conf:
/dev/sda1 {
spindown_time = 20
}
But this also did not give any effect, the disk continues to rotate.
Also, knowing that udisks2 is installed in the raspbian buster, I tried to create a configuration file Seagate_Expansion_NA4B2GTR-0: 0.conf (this is exactly what the command "udevadm info / dev / sda" gave me) in the directory /etc/udisks2/ with the contents
[ATA]
StandbyTimeout = 20
But it didn't work either.
The fact that the disk does not stop spinning is my first problem. The second problem is that when you turn off or restart Raspberry, the disk does not park its heads and its power is interrupted abruptly, which causes a very unpleasant rattle. I found similar queries on the Internet, this is a very common problem.
I would like that during the procedure of shutting down the OS, the disk should be correctly unmounted and its power turned off before power is lost on the USB 3.0 port.
Fortunately, I was able to write a similar script and it works great:
hddshutdown.sh
sudo umount -f /dev/sda1
sudo udisksclt power-off -b /dev/sda1
sleep 5
If I run this script just while the OS is running, it does exactly what I need: The disk is unmounted, the disk rotation stops and the LED on the case goes out. However, I cannot get this script to work the same way during the OS shutdown procedure.
I wrote this unit for systemd:
hddshutdown.service in /usr/lib/systemd/system/
[Unit]
Description=[=======USB-HDD-spindown============]
DefaultDependencies=no
After=umount.target
Before=shutdown.target poweroff.target reboot.target halt.target
[Service]
ExecStart=/bin/sh /home/pi/hddshutdown.sh
Type=oneshot
RemainAfterExit=yes
[Install]
WantedBy=reboot.target
I did "sudo systemctl enable hddshutdown", tried several different configuration options, played with different Before, After, and WantedBy values, but none of the options worked, just one, the drive is successfully unmounted, but the power does not turn off, the drive continues to spin and LED is on until the moment the Pi is turned off. Moreover, I know for sure that the sh-script starts exactly, the "sleep" delay, which I set at the end of the script, really works.
I do not know Linux very well and this was my first experience writing units for systemd. I found information that udisksctl needs DBus to work, but it doesn’t exist during shutdown, and that’s why the drive’s power cannot turn off. I could not find a way to execute this unit as early as possible during the shutdown procedure when DBus is still available. (I don’t even know what it is, maybe I said stupidity)
Please help me solve 2 of these problems, thanks in advance.
I myself found the answer to my question. Because I use the Seagate Expansion drive, I used the Seagate Dashboard program from the official site to "reprogram" my hard drive. I was able to turn off the external LED-indicator and set the rotation shutdown time to 10 minutes and now on any system the hard disk is turned off after 10 minutes. Using programs like hdparm or udisks is no longer required!
What worked for me to make my HDD spin-down automatically when idle was this new implementation of hd-idle.
My particular setup is: Raspberry Pi 4B + Suptronics X835 + WD Blue WD20EZRZ.
Non of the other usual tools worked for me (hdparm, original hd-idle).
I have a project to make mobile robot with Dynamixel AX-12A as the wheel, so i changes the AX-12A to Wheel Mode with CM-530 and it works well.
I follow the guide from http://www.oppedijk.com/robotics/control-dynamixel-with-raspberrypi
I already check my serial communication (UART) on Raspi using Terminal Minicom with only wiring up GPIO14 and GPIO15 together and it works well
Here is my /boot/config.txt at the end of code:
dtoverlay=pi3-disable-bt
hdmi_force_hotplug=1
enable_uart=1
init_uart_clock=16000000
Here is my /boot/cmdline.txt:
dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p7 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait splash plymouth.ignore-serial-consoles
Here is my Python3 Code:
import serial
import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.OUT)
GPIO.setwarnings(False)
port = serial.Serial("/dev/ttyAMA0", baudrate=1000000, timeout=3.0)
while True:
GPIO.output(18, GPIO.HIGH)
port.write(bytearray.fromhex("FF FF 00 04 03 20 FF D8"))
time.sleep(0.1)
GPIO.output(18, GPIO.LOW)
time.sleep(3)
The problem is dynamixel ax-12a not responding to my hexa which should move with value 255. And there is no error feedback from program.
Btw i'm working this project with VNC through wifi in PC, did this cause problems with the communication?
If someone could help me, i thank you.
*sorry if i have bad english
After very long discussion, now i can control the motor, the problem is i sent the wrong instruction packet FF FF 00 04 03 20 FF D8, it should be FF FF 00 05 03 20 FF 00 D8.
The official Angular quickstart is not able to run karma tests after a clean install on Windows 10. I typed the following 4 commands and nothing else:
C:\projects\temp>git clone https://github.com/angular/quickstart.git
C:\projects\temp>cd C:\projects\temp\quickstart
C:\projects\temp\quickstart>npm install
...install logs omitted for brevity
C:\projects\temp\quickstart>npm start
...app launched successfully, but logs omitted for brevity
C:\projects\temp\quickstart>npm test
...Error shown in complete logs below
The full error message resulting after the final command is as follows:
C:\projects\temp\quickstart>npm test
> angular-quickstart#1.0.0 pretest C:\projects\temp\quickstart
> npm run build
> angular-quickstart#1.0.0 build C:\projects\temp\quickstart
> tsc -p src/
> angular-quickstart#1.0.0 test C:\projects\temp\quickstart
> concurrently "npm run build:watch" "karma start karma.conf.js"
[0]
[0] > angular-quickstart#1.0.0 build:watch C:\projects\temp\quickstart
[0] > tsc -p src/ -w
[0]
[1] 01 06 2017 14:33:49.385:WARN [watcher]: Pattern "C:/projects/temp/quickstart/testing/**/*.js" does not match any file.
[1] 01 06 2017 14:33:49.406:WARN [watcher]: Pattern "C:/projects/temp/quickstart/testing/**/*.ts" does not match any file.
[1] 01 06 2017 14:33:49.407:WARN [watcher]: Pattern "C:/projects/temp/quickstart/testing/**/*.js.map" does not match any file.
[1] 01 06 2017 14:33:49.891:WARN [karma]: No captured browser, open http://localhost:9876/
[1] 01 06 2017 14:33:49.906:WARN [karma]: Port 9876 in use
[1] 01 06 2017 14:33:49.908:INFO [karma]: Karma v1.7.0 server started at http://0.0.0.0:9877/
[1] 01 06 2017 14:33:49.908:INFO [launcher]: Launching browser Chrome with unlimited concurrency
[1] 01 06 2017 14:33:49.958:INFO [launcher]: Starting browser Chrome
[1] 01 06 2017 14:33:51.821:INFO [watcher]: Changed file "C:/projects/temp/quickstart/src/app/app.component.js".
[1] 01 06 2017 14:33:51.843:INFO [watcher]: Changed file "C:/projects/temp/quickstart/src/app/app.component.spec.js".
[1] 01 06 2017 14:33:51.850:INFO [watcher]: Changed file "C:/projects/temp/quickstart/src/app/app.module.js".
[0] 2:33:51 PM - Compilation complete. Watching for file changes.
[1] 01 06 2017 14:33:51.873:INFO [watcher]: Changed file "C:/projects/temp/quickstart/src/main.js".
[1] 01 06 2017 14:33:51.965:INFO [Chrome 58.0.3029 (Windows 10 0.0.0)]: Connected on socket pXysNFDP8RC3agm8AAAA with id 9156960
[1] 01 06 2017 14:33:52.077:INFO [karma]: Delaying execution, these browsers are not ready: Chrome 58.0.3029 (Windows 10 0.0.0)
What needs to change in order for npm test to succeed out of the box on Windows 10?
The Angular quickstart project has largely been superseded by the Angular CLI. I would suggest using the CLI it for any new projects as it not only gives you an initial framework for your application, but it will also generate the additional boilerplate needed as you extend your application.
Before installing Angular CLi, ensure you have an up to date version of Node (6.9.0 or higher) and NPM (3 or higher). Also there may be other prerequisites not listed in the documentation, to install on an Android system I found it also needed Python 2.7 and g++ installed.
Install with:
npm install -g #angular/cli
To create a new project:
ng new PROJECT-NAME
cd PROJECT-NAME
ng serve
ng new will take some time to complete as in addition to building the project structure it also does the npm install.
Run unit tests with ng test and end-to-end tests with ng e2e.
Both ng test and ng serve will run continuously watching for changes and rebuilding the affected code. You can even leave both running in separate windows if you wish.
ng generate BLUEPRINT will generate new code, blueprints include module, component, service, class, directive, enum, guard, interface, pipe
Other useful commands:. You may want to experiment with this a bit before you write a real app: by default each component or service goes into its own subdirectory and is added to the top level app module, but you can explicitly create modules to provide additional structure if you wish.
ng build: builds your application into the output path.
ng doc KEYWORD: opens angular documentation for that keyword.
ng eject: ejects the app and outputs webpack configuration
ng lint: lints the project
ng xi18n: extracts i18n messages from the project.
This is not answer, just give more case to find out root cause.
I followed steps which you described and got this:
D:\Project\temp\quickstart>npm test
> angular-quickstart#1.0.0 pretest D:\Project\temp\quickstart
> npm run build
> angular-quickstart#1.0.0 build D:\Project\temp\quickstart
> tsc -p src/
> angular-quickstart#1.0.0 test D:\Project\temp\quickstart
> concurrently "npm run build:watch" "karma start karma.conf.js"
[0]
[0] > angular-quickstart#1.0.0 build:watch D:\Project\temp\quickstart
[0] > tsc -p src/ -w
[0]
[1] 02 06 2017 22:34:04.733:WARN [watcher]: Pattern
"D:/Project/temp/quickstart/testing/**/*.js" does not match any file.
[1] 02 06 2017 22:34:04.746:WARN [watcher]: Pattern
"D:/Project/temp/quickstart/testing/**/*.ts" does not match any file.
[1] 02 06 2017 22:34:04.747:WARN [watcher]: Pattern
"D:/Project/temp/quickstart/testing/**/*.js.map" does not match any file.
[1] 02 06 2017 22:34:05.103:WARN [karma]: No captured browser, open
http://localhost:9876/
[1] 02 06 2017 22:34:05.120:INFO [karma]: Karma v1.7.0 server started at
http://0.0.0.0:9876/
[1] 02 06 2017 22:34:05.120:INFO [launcher]: Launching browser Chrome with
unlimited concurrency
[1] 02 06 2017 22:34:05.156:INFO [launcher]: Starting browser Chrome
[1] 02 06 2017 22:34:06.742:INFO [Chrome 58.0.3029 (Windows 10 0.0.0)]:
Connected on socket GGConP8Ks64GubSYAAAA with id 70486747
[1] 02 06 2017 22:34:07.822:INFO [watcher]: Changed file
"D:/Project/temp/quickstart/src/app/app.component.js".
[1] 02 06 2017 22:34:07.837:INFO [watcher]: Changed file
"D:/Project/temp/quickstart/src/app/app.component.spec.js".
[1] 02 06 2017 22:34:07.856:INFO [watcher]: Changed file
"D:/Project/temp/quickstart/src/app/app.module.js".
[0] 10:34:07 PM - Compilation complete. Watching for file changes.
[1] 02 06 2017 22:34:07.865:INFO [watcher]: Changed file
"D:/Project/temp/quickstart/src/main.js".
[1] 02 06 2017 22:34:08.084:INFO [karma]: Delaying execution, these browsers
are not ready: Chrome 58.0.3029 (Windows 10 0.0.0)
Chrome 58.0.3029 (Windows 10 0.0.0): Executed 2 of 2 SUCCESS (0.159 secs /
0.149 secs)
Chrome 58.0.3029 (Windows 10 0.0.0): Executed 2 of 2 SUCCESS (0.117 secs /
0.112 secs)
I have added a new service to my CentOS box. It should be started after the mounting the file systems.
Would appreciate your assistance,
Liora
You can add the following line in /etc/init.d/<your-service-script> file.
chkconfig: - 00 99
This denotes it will start the service number as 00 (first) and while stopping it is 99 (almost last).
You can make it as 01 and it would be better.