Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start_CAN on startup #397

Open
JochenDeprezVintecc opened this issue Apr 23, 2024 · 19 comments
Open

Start_CAN on startup #397

JochenDeprezVintecc opened this issue Apr 23, 2024 · 19 comments

Comments

@JochenDeprezVintecc
Copy link

@owzagj Is there some kind of service we can enable so the Start_CAN command gets executed on boot. This way the CAN interfaces are immediately active.
I get the point of not enabling them if you do not need them.
But I suppose most use cases with the owa5x will require them so being able to enable them from startup would be quite nice.

@owzagj
Copy link
Collaborator

owzagj commented Apr 24, 2024

Hi @JochenDeprezVintecc there are several possibilities depending on your development approach:

  • You may run a script from inside a container which sets the Start_CAN command. This link maybe useful.
  • You may remount the BalenaOS filesystem as R/W, create a systemd service which runs "Start_CAN 1" and then enable it.
  • You may build a BalenaOS custom image using this repo and adding your own startup configuration.

Hope this helps! Any question don't hesitate to ask!

@JochenDeprezVintecc
Copy link
Author

Hi, I have currently fixed this by creating a custom systemd service. But as far as I understand, this service will disapear if I do a HostOS update. So for production purposes I will probably need to build a container to do the Start_CAN command. I have downloaded a package from your developer zone. But I run into problems with having the wrong c++ compiler.

I also am looking into the GPS, will I have to follow the same steps to start GPS? Like build a container and run the command to start it? Because I see no command on the HostOS to start GPS

@owzagj
Copy link
Collaborator

owzagj commented May 9, 2024

Hello @JochenDeprezVintecc, thanks for your question.

Regarding the c++ problems, could you please give me some more feedback about the nature of the problems? Maybe a log would be helpful.

About the GPS, let me check and I'll come back to you ASAP.

Thanks in advance!

@JochenDeprezVintecc
Copy link
Author

Hi, I have fixed some issues with the c++ compilation but when trying to run make on the ow5x_AN8 module I downloaded from the developer zone I get the following error:

root@4fd5059:/rtu# make

Building owa5x_AN8 Object
gcc -Wall -D_REENTRANT -O2 -oowa5x_AN8 ./*.c -ldl -lpthread -lRTU_Module
/usr/bin/ld: cannot find -lRTU_Module
collect2: error: ld returned 1 exit status
make: *** [Makefile:24: build] Error 1

@JochenDeprezVintecc
Copy link
Author

When building the owa5x_AN3 I seem to be able to run the make command but then on execution of the binary I get also an error to libRTU_Module.so

root@4fd5059:/io# make

Building owa5x_AN3 Object
cc -Wall -D_REENTRANT -O -oowa5x_AN3 ./*.c -ldl -lpthread
strip owa5x_AN3
root@4fd5059:/io# ./owa5x_AN3
Enter owa3x_AN3 version(0.0.2) program
20240523-094650 No shared library /lib/libRTU_Module.so found
/lib/libRTU_Module.so: cannot open shared object file: No such file or directory
root@4fd5059:/io#

@owzagj
Copy link
Collaborator

owzagj commented May 24, 2024

It seems your toolchain is lacking that library. May you give me an email so I can send them to you?

They should be located in /usr/lib/owasys and /lib/

Thanks in advance

@JochenDeprezVintecc
Copy link
Author

Hi, you can email them to:
[email protected]

@owzagj
Copy link
Collaborator

owzagj commented May 27, 2024 via email

@owzagj
Copy link
Collaborator

owzagj commented May 27, 2024

@owzagj
Copy link
Collaborator

owzagj commented May 29, 2024

Hello @JochenDeprezVintecc did you have the chance to test the libraries?

Please let me know, I'm here to help!

BR

@JochenDeprezVintecc
Copy link
Author

Hi, the libRTU errors seem to be gone, now I have some other errors:

When running the owa5x_AN3 from within a container, I get the following error:
root@4fd5059:/io# ./owa5x_AN3
Enter owa3x_AN3 version(0.0.2) program
All external Control functions loaded
All external functions loaded...
No shared library /lib/libGSM_Module.so foundlibasound.so.2: cannot open shared object file: No such file or directory
No GSM_GoToStandBy() found...
RTU: connect(): No such file or directory
Error -1 when opening socket communication
Error 43 in RTUControl_Start()...
20240530-141324 UnloadExternalLibrary() ok
20240530-141324 UnloadExternalLibrary() ok

Also when running the Start_CAN binary from within my container, I get the following error:

root@4fd5059:/# ./Start_CAN 1
No shared library /lib/libGSM_Module.so foundlibasound.so.2: cannot open shared object file: No such file or directory
No GSM_GoToStandBy() found...
RTU: connect(): No such file or directory
Error -1 when opening socket communication
Error 43 in RTUControl_Start()...

It seems to be the same kind of error with the socket communication

My container is running in privileged mode though

@JochenDeprezVintecc
Copy link
Author

Hi @owzagj, any idea how I could resolve the socket communication error?

@owzagj
Copy link
Collaborator

owzagj commented Jun 12, 2024 via email

@owzagj
Copy link
Collaborator

owzagj commented Jun 12, 2024 via email

@JochenDeprezVintecc
Copy link
Author

Hi, I do not see the attachment.

@owzagj
Copy link
Collaborator

owzagj commented Jun 12, 2024

owa5x_HW_Docker_setup A

To achieve a easy deployment for a big number of Owa devices, it is a good idea to use docker images, due to the ease of setup on a new device and the posibility of deploying in a bulk using Docker Compose.

In this tutorial is exposed how to create a new docker container and how to set it up so it comunicates with the rest of HW modules in the Owa. For the purpose of this tutorial an Owa_5x running FW_1.1.0 has been used.

Requisites

Docker installed on the Owa:

Refer to the tutorial on the official website: https://docs.docker.com/engine/install/debian/

Creating docker image

The next command will create a docker container with debian with access to corresponding sockets.

docker run -v /tmp/PMsck:/tmp/PMsck -v /tmp/TMsck:/tmp/TMsck --privileged -it debian

Installing required libraries

Once on the command prompt inside the container, take the container_id, which is displayed on the hostname part of the command prompt.

Open another terminal on the Owa and run the following commands to install the Owasys libraries inside the docker container.

##RUN IN OWA TERMINAL
docker cp /lib/libFMS_Module.so d1d9beb4e833:/lib/
docker cp /lib/libGPS2_Module.so d1d9beb4e833:/lib/
docker cp /lib/libGSM_Module.so d1d9beb4e833:/lib/
docker cp /lib/libINET_Module.so d1d9beb4e833:/lib/
docker cp /lib/libIOs_Module.so d1d9beb4e833:/lib/
docker cp /lib/libRTU_Module.so d1d9beb4e833:/lib/
docker cp /lib/owasys/ d1d9beb4e833:/lib/
docker cp /usr/lib/aarch64-linux-gnu/libasound.so.2 d1d9beb4e833:/usr/lib/aarch64-linux-gnu/
docker cp /usr/lib/aarch64-linux-gnu/libasound.so.2.0.0 d1d9beb4e833:/usr/lib/aarch64-linux-gnu/

Installing your script/program on the container

Last thing is to install the program so it can be executed inside the docker container, in this tutorial Start_BT_WiFi will be used for demonstration purposes.

##RUN IN OWA TERMINAL
docker cp /usr/bin/Start_BT_WiFi d1d9beb4e833:/usr/bin/

Running the program

Once the previous steps are completed, the container can be used as if it was the Owa.

##RUN IN DOCKER CONTAINER
root@d1d9beb4e833:/ Start_BT_WiFi 1
BT/WIFi ENABLE OK

##Dmesg OUTPUT
[ 6121.652336] BT: Loading driver           
[ 6121.758971] BT Request firmware: nxp/sdsd8987_combo.bin                             
[ 6122.872029] BT: FW download over, size 607832 bytes                                 
[ 6123.893987] BT FW is active(10)                                                     
[ 6123.911200] BT: Driver loaded successfully              

History

Version Date Comments
A 2023-10-05 First version

@owzagj
Copy link
Collaborator

owzagj commented Jun 12, 2024

Please @JochenDeprezVintecc , let's move this conversation to the email so I can send you files and so on:

[email protected]

BR

@otlaitil
Copy link
Contributor

otlaitil commented Oct 7, 2024

Hello @owzagj - I have the same problem, I would need to start can from the docker application.

I can copy the libraries to the docker image but the issue is with socket communication. Balena does not allow bind mounts.

Trying to mount the sockets with:

volumes:
  - /tmp/PMsck:/tmp/PMsck
  - /tmp/TMsck:/tmp/TMsck

Gives you an error from Balena: Bind mounts are not allowed.

Could you please advice on how to overcome this?

@otlaitil
Copy link
Contributor

otlaitil commented Oct 7, 2024

I suggest we would always start CAN on boot: #545

otlaitil added a commit to otlaitil/balena-owa5x that referenced this issue Oct 11, 2024
As discussed in balena-os#397 starting CAN communication from within balena docker applications is difficult due to needing owasys libraries in the image and needing to mount sockets to the running container.

This commit enables CAN on boot.

Changelog-entry: Start CAN on boot
floion pushed a commit to otlaitil/balena-owa5x that referenced this issue Oct 11, 2024
As discussed in balena-os#397 starting CAN communication from within balena docker applications is difficult due to needing owasys libraries in the image and needing to mount sockets to the running container.

This commit enables CAN on boot.

Changelog-entry: Start CAN on boot
otlaitil added a commit to otlaitil/balena-owa5x that referenced this issue Oct 12, 2024
As discussed in balena-os#397 starting CAN communication from within balena docker applications is difficult due to needing owasys libraries in the image and needing to mount sockets to the running container.

This commit enables CAN on boot.

Changelog-entry: Start CAN on boot
Signed-off-by: Otto Laitila <[email protected]>
floion pushed a commit to otlaitil/balena-owa5x that referenced this issue Oct 28, 2024
As discussed in balena-os#397 starting CAN communication from within balena docker applications is difficult due to needing owasys libraries in the image and needing to mount sockets to the running container.

This commit enables CAN on boot.

Changelog-entry: Start CAN on boot
Signed-off-by: Otto Laitila <[email protected]>
floion pushed a commit to otlaitil/balena-owa5x that referenced this issue Oct 29, 2024
As discussed in balena-os#397 starting CAN communication from within balena docker applications is difficult due to needing owasys libraries in the image and needing to mount sockets to the running container.

This commit enables CAN on boot.

Changelog-entry: Start CAN on boot
Signed-off-by: Otto Laitila <[email protected]>
floion pushed a commit to otlaitil/balena-owa5x that referenced this issue Oct 29, 2024
As discussed in balena-os#397 starting CAN communication from within balena docker applications is difficult due to needing owasys libraries in the image and needing to mount sockets to the running container.

This commit enables CAN on boot.

Changelog-entry: Start CAN on boot
Signed-off-by: Otto Laitila <[email protected]>
floion pushed a commit to otlaitil/balena-owa5x that referenced this issue Oct 30, 2024
As discussed in balena-os#397 starting CAN communication from within balena docker applications is difficult due to needing owasys libraries in the image and needing to mount sockets to the running container.

This commit enables CAN on boot.

Changelog-entry: Start CAN on boot
Signed-off-by: Otto Laitila <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants