HI, I am running on a Verdin dev board with a imx5m-plus module. I am using two can bus lines talking to 2 separate devices.
Everything is working, once I manually go in and turn on both CAN buses using ip link commands. However, I’ve tried using the system call to do those exact commands, and they fail. Yet I can open a shell in the container, and run the commands and they work just fine. I don’t understand the difference. Doesn’t the code run at the same level as the shell login? The system commands all return with error code 15, which I haven’t found explanation of what it means.
Torizoncore 6 latest, yes. In C or C++, you can execute system calls like you typed them from a keyboard. They fork to a command shell and run the command. So, using cantools I am doing:
int ret = system(“ip link set can0 type can bitrate 1000000”);
and
ret = system(“ip link set can0 up”);
Both of which fail with error code 15. If I open a shell into the container and check, both calls have failed, can0 is not set up and not “up”. But I can manually do the same commands in the shell and have it work.
I do this after some other setup code has been done, and also, the containers is running at that point as I am running the debugger in it. I can do the commands from the shell as soon as the container is showing running, as I originally did it before I ran my program, so the debugger was sitting at the first line of code. It is just when I try to run those commands from the system call shown above that it fails.
Hi @lucas_a.tx ,
I can’t run the container as root, as before a certain version (don’t remember what it was), the root user had an empty pw, but now it doesn’t and I don’t find the pw anywhere on your web. I run it as torizon as the user, with a different pw. However, if I right click on the container in VSC, I can attach a shell, and run the commands (or commands in a bash shell file) and it works just fine. I’ve tried running the commands in the bash shell file, via system(“bash turnoncan.sh”; and the command succeeds but most of the time it doesn’t work, but sometimes it does, but rarely.
I am using the Apollo extension to run the container and build the project.
The root user in our containers doesn’t have a password by default. I’m not sure if this happened to you, but If you’re in the container as the torizon user and run su to try changing to root, it will always ask for a password, regardless if it is set or not.
If you’re using the Torizon IDE Extension 2 and you’re trying to debug your application in it, you can change the user running the application on debug with torizon_run_as in <your-project-dir>/.vscode/settings.json, as detailed here: