balena-os / balena-owa5x

Apache License 2.0
3 stars 0 forks source link

Start_CAN on startup #397

Open JochenDeprezVintecc opened 4 months ago

JochenDeprezVintecc commented 4 months ago

@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 commented 4 months ago

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

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

JochenDeprezVintecc commented 4 months ago

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 commented 4 months ago

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 commented 3 months ago

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 commented 3 months ago

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 commented 3 months ago

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 commented 3 months ago

Hi, you can email them to: jochen.deprez@vintecc.com

owzagj commented 3 months ago

Hello Jochen,

I tried to but it was rejected! [cid:3c18d2f4-ca6e-4a3c-a0b9-267128d4a5ae]

is the email address okey? can I attach zip files to it?

Thanks!

Álvaro Guzmán Juán R&D Engineer

[Logotipo Descripción generada automáticamente] Phone: (+34) 946 025 323 E-mail: @.**@.> www.owasys.comhttp://www.owasys.com/ Bizkaia Technology Park, 202 E-48170, Zamudio Bizkaia Spain This email and any attachment may contain confidential, propietary or legally priviledged information. If you are not the intended recipient of this message, please notify it to the sender and delete it without resending or backing it, as it is legally prohibited. If you do not want to receive any communication from Owasys, S.L., please send en email to @.**@.> or a letter to Owasys, S.L., Bizkaia Technology Park 202, 48170 Zamudio, Bizkaia, Spain.”. Please think of the environment before printing this email


From: Jochen Deprez @.> Sent: Monday, May 27, 2024 11:59 AM To: balena-os/balena-owa5x @.> Cc: Alvaro Guzman @.>; Mention @.> Subject: Re: [balena-os/balena-owa5x] Start_CAN on startup (Issue #397)

Hi, you can email them to: @.**@.>

— Reply to this email directly, view it on GitHubhttps://github.com/balena-os/balena-owa5x/issues/397#issuecomment-2133120941, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A2RRXI7YI7HSGMQJSNE7YHLZEL7YJAVCNFSM6AAAAABGUZBG4GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMZTGEZDAOJUGE. You are receiving this because you were mentioned.Message ID: @.***>

owzagj commented 3 months ago

Please, try download it from here:

https://owasys.sharepoint.com/:u:/s/support/EbLgaXC9WnRDvvlZhVUGn6QB6t_v2Z68tqiVdmABqsSg5w?e=ueLxID

owzagj commented 3 months ago

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

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

BR

JochenDeprezVintecc commented 3 months ago

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 commented 2 months ago

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

owzagj commented 2 months ago

Hi Jochen,

You have to map the sockets from the native rootfs into the container's. Try this workaround in the container definition file:

services:
  myservice:
    volumes:
      - hosttmp:/tmp
volumes:
  hosttmp:
    driver_opts:
      type: none
      o: bind
      device: /tmp

Also in dockers containers you can:

1.

Run the container in priviledge mode:

 *

$ docker run --privileged -d whatever

2.

Map the rootfs

 *

docker run -v /sys:/sys -d whatever

3.

To access the RTU lib map the sockets /tmp/PMsck, /tmp/Tmsck

You can find info in this links:

https://stackoverflow.com/questions/58113780/access-shared-library-inside-a-docker-container https://docs.balena.io/learn/develop/hardware/

BR

Álvaro Guzmán Juán R&D Engineer

[Logotipo Descripción generada automáticamente] Phone: (+34) 946 025 323 E-mail: @.**@.> www.owasys.comhttp://www.owasys.com/ Bizkaia Technology Park, 202 E-48170, Zamudio Bizkaia Spain This email and any attachment may contain confidential, propietary or legally priviledged information. If you are not the intended recipient of this message, please notify it to the sender and delete it without resending or backing it, as it is legally prohibited. If you do not want to receive any communication from Owasys, S.L., please send en email to @.**@.> or a letter to Owasys, S.L., Bizkaia Technology Park 202, 48170 Zamudio, Bizkaia, Spain.”. Please think of the environment before printing this email


From: Jochen Deprez @.> Sent: Tuesday, June 11, 2024 11:32 AM To: balena-os/balena-owa5x @.> Cc: Alvaro Guzman @.>; Mention @.> Subject: Re: [balena-os/balena-owa5x] Start_CAN on startup (Issue #397)

Hi @owzagjhttps://github.com/owzagj, any idea how I could resolve the socket communication error?

— Reply to this email directly, view it on GitHubhttps://github.com/balena-os/balena-owa5x/issues/397#issuecomment-2160252227, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A2RRXI3ATOP27K5BABBQP73ZG2737AVCNFSM6AAAAABGUZBG4GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNRQGI2TEMRSG4. You are receiving this because you were mentioned.Message ID: @.***>

owzagj commented 2 months ago

Hi again,

you may also find interesting the tutorial attaached tutorial for owa5X and docker.

Regards

Álvaro Guzmán Juán R&D Engineer

[Logotipo Descripción generada automáticamente] Phone: (+34) 946 025 323 E-mail: @.**@.> www.owasys.comhttp://www.owasys.com/ Bizkaia Technology Park, 202 E-48170, Zamudio Bizkaia Spain This email and any attachment may contain confidential, propietary or legally priviledged information. If you are not the intended recipient of this message, please notify it to the sender and delete it without resending or backing it, as it is legally prohibited. If you do not want to receive any communication from Owasys, S.L., please send en email to @.**@.> or a letter to Owasys, S.L., Bizkaia Technology Park 202, 48170 Zamudio, Bizkaia, Spain.”. Please think of the environment before printing this email


From: Alvaro Guzman @.> Sent: Wednesday, June 12, 2024 11:19 AM To: balena-os/balena-owa5x @.> Subject: Re: [balena-os/balena-owa5x] Start_CAN on startup (Issue #397)

Hi Jochen,

You have to map the sockets from the native rootfs into the container's. Try this workaround in the container definition file:

services:
  myservice:
    volumes:
      - hosttmp:/tmp
volumes:
  hosttmp:
    driver_opts:
      type: none
      o: bind
      device: /tmp

Also in dockers containers you can:

1.

Run the container in priviledge mode:

 *

$ docker run --privileged -d whatever

2.

Map the rootfs

 *

docker run -v /sys:/sys -d whatever

3.

To access the RTU lib map the sockets /tmp/PMsck, /tmp/Tmsck

You can find info in this links:

https://stackoverflow.com/questions/58113780/access-shared-library-inside-a-docker-container https://docs.balena.io/learn/develop/hardware/

BR

Álvaro Guzmán Juán R&D Engineer

[Logotipo Descripción generada automáticamente] Phone: (+34) 946 025 323 E-mail: @.**@.> www.owasys.comhttp://www.owasys.com/ Bizkaia Technology Park, 202 E-48170, Zamudio Bizkaia Spain This email and any attachment may contain confidential, propietary or legally priviledged information. If you are not the intended recipient of this message, please notify it to the sender and delete it without resending or backing it, as it is legally prohibited. If you do not want to receive any communication from Owasys, S.L., please send en email to @.**@.> or a letter to Owasys, S.L., Bizkaia Technology Park 202, 48170 Zamudio, Bizkaia, Spain.”. Please think of the environment before printing this email


From: Jochen Deprez @.> Sent: Tuesday, June 11, 2024 11:32 AM To: balena-os/balena-owa5x @.> Cc: Alvaro Guzman @.>; Mention @.> Subject: Re: [balena-os/balena-owa5x] Start_CAN on startup (Issue #397)

Hi @owzagjhttps://github.com/owzagj, any idea how I could resolve the socket communication error?

— Reply to this email directly, view it on GitHubhttps://github.com/balena-os/balena-owa5x/issues/397#issuecomment-2160252227, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A2RRXI3ATOP27K5BABBQP73ZG2737AVCNFSM6AAAAABGUZBG4GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNRQGI2TEMRSG4. You are receiving this because you were mentioned.Message ID: @.***>

JochenDeprezVintecc commented 2 months ago

Hi, I do not see the attachment.

owzagj commented 2 months ago

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 commented 2 months ago

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

alvaro.guzman@owasys.com

BR