Problem initializing the uos library in the service

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
32 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Problem initializing the uos library in the service

Andrey
This post was updated on .
Hello.

I created a console program using the uos library. If I run the program as a console, then the program works. If I run the program as a Linux service, the "Access Denied" error occurs when executing uos_LoadLib("LibPortaudio-64.so",nil,nil,nil,nil).


Reply | Threaded
Open this post in threaded view
|

Re: Problem initializing the uos library in the service

fredvs
Administrator
This post was updated on .
Hello Andrey.

> If I run the program as a Linux service, the "Access Denied" error occurs when executing uos_LoadLib("LibPortaudio-64.lib",nil,nil,nil,nil).

Did you try with the full path of LibPortaudio.so ?

Something like:
uos_LoadLib(' /dir_of_uos/examples/lib/Linux/64bit/LibPortaudio-64.so',nil,nil,nil,nil).


Also, the extension of the library is ".so" in /uos/examples/lib/Linux/64bit/LibPortaudio-64.so (not LibPortaudio-64.lib).
And with fpc, imho, you should use ('LibPortaudio-64.so',nil,nil,nil,nil).    ---> use -'- instead of -"- for the string-path.
Reply | Threaded
Open this post in threaded view
|

Re: Problem initializing the uos library in the service

fredvs
Administrator
In reply to this post by Andrey
Re-hello Andrey.

If Portaudio is installed on your system (via sudo apt install libportaudio2, but it should be installed by default because lot of apps use it), you may try to load it with:

uos_LoadLib('system',nil,nil,nil,nil).
Reply | Threaded
Open this post in threaded view
|

Re: Problem initializing the uos library in the service

Andrey
In reply to this post by fredvs
Hello.
Sorry, I misspelled the extension in the post above (".so").
When downloading the library, I use the full path to the file: WorkPath+'lib/Linux/64bit/LibPortaudio-64.so'.
Reply | Threaded
Open this post in threaded view
|

Re: Problem initializing the uos library in the service

fredvs
Administrator
Is it working now?
Reply | Threaded
Open this post in threaded view
|

Re: Problem initializing the uos library in the service

Andrey
Added the uos_LoadLib('system',nil,nil,nil,nil,nil) call, it worked.
Thank you very much.
Reply | Threaded
Open this post in threaded view
|

Re: Problem initializing the uos library in the service

fredvs
Administrator
Ha, nice, I am very happy.
Reply | Threaded
Open this post in threaded view
|

Re: Problem initializing the uos library in the service

Andrey
In reply to this post by Andrey
Hello Fred.
I was happy early.
After adding uos_load('system',nil,nil,nil,nil), the "LibPortaudio-64.so" library is loaded, the player is created

For player OUT:
uos_AddDFromAndLessMuted() and uos_InputAddDSP() are executed, but uos_AddIntoDevOut() returns -1

For player IN:
uos_AddFromDevIn() returns -1
Text_program[1].txtlog_run[1].log
Reply | Threaded
Open this post in threaded view
|

Re: Problem initializing the uos library in the service

fredvs
Administrator
Hello Andrey.

Hum, difficult to diagnose.
If you run your code "normally", not via a service, is it working?

Also in your code, to load the library, you first try with "system" then with a custom path if "system" failed.

Note that there is a error if the result < 0.
Something like:

if uos_loadlib('system',nil,nil,nil,nil,nil) < 0 then writeln('Library from system not loaded') else writeln('Library from system loaded');

When running your code, do you know what library was loaded, the one from "system" or from custom path?

If you try with a other input, for example a mic,  is it working?
Reply | Threaded
Open this post in threaded view
|

Re: Problem initializing the uos library in the service

Andrey
If you run your code "normally", not via a service, is it working? - Yes? it work.

When running your code, do you know what library was loaded, the one from "system" or from custom path? - I don't know how to define it.

If you try with a other input, for example a mic,  is it working? - It doesn't work for either recording or playback.
Reply | Threaded
Open this post in threaded view
|

Re: Problem initializing the uos library in the service

fredvs
Administrator
This post was updated on .
> When running your code, do you know what library was loaded, the one from "system" or from custom path? - I don't know how to define it.

You may try something like this:

if uos_loadlib('system',nil,nil,nil,nil,nil) < 0 then
 begin

   writeln('Library from system not loaded, trying library of custom path...');
   if uos_loadlib('/my/custom/path/'LibPortaudio-64.so',nil,nil,nil,nil,nil) < 0 then
     writeln('Library from custom path not loaded too ;-( ...') else
     writeln('Library from custom path loaded ;-).');

 end else writeln('Library from system loaded ;-).');
Reply | Threaded
Open this post in threaded view
|

Re: Problem initializing the uos library in the service

Andrey
The problem is that until I execute uos_loadlib('system',nil,nil,nil), running uos_loadlib('/my/custom/path/'+LibPortaudio-64.so ',nil,nil,nil,nil,nil) calls error "AccessDenied".
Reply | Threaded
Open this post in threaded view
|

Re: Problem initializing the uos library in the service

fredvs
Administrator
This post was updated on .
So if I understand ok, the system library is not loaded and trying to load a library outside system you get  "AccessDenied".

I never programed service, could you give me some infos how you did to create the service?
Is it loaded by the system after boot?
Why do you need a service, what is it doing?
Reply | Threaded
Open this post in threaded view
|

Re: Problem initializing the uos library in the service

fredvs
Administrator
This post was updated on .
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Problem initializing the uos library in the service

fredvs
Administrator
Did you try to run the service with root privilege ?
Reply | Threaded
Open this post in threaded view
|

Re: Problem initializing the uos library in the service

fredvs
Administrator
Reply | Threaded
Open this post in threaded view
|

Re: Problem initializing the uos library in the service

Andrey
In reply to this post by fredvs
Hello Fred.

Make Service:

Create file : /lib/systemd/system/MyService.service
----------------------------
[Unit]
Description=MyDescription
After=multi-user.target

[Service]
Type=idle
ExecStart=<my path for program>/MyProgram

[Install]
WantedBy=multi-user.target
----------------------------------

execute cmd :

  sudo chmod 644 /lib/systemd/system.MyService.service

execute cmd reload daemon:

  sudo systemctl daemon-reload

execute cmd for enabled my service:  

  sudo systemctl enable MyService.service

After restarting the PC, my service starts.
The service is started with root rights.


Reply | Threaded
Open this post in threaded view
|

Re: Problem initializing the uos library in the service

fredvs
Administrator
Hello Andrew.

Sorry but I am not sure about your result, is it working now?
Reply | Threaded
Open this post in threaded view
|

Re: Problem initializing the uos library in the service

Andrey
No, everything is the same, I showed you how to create a service. That's how it was originally.
Reply | Threaded
Open this post in threaded view
|

Re: Problem initializing the uos library in the service

fredvs
Administrator
;-(

If it works as "standalone" but not via service, it seems to me that maybe it is the service itself that is not configured properly.

I will study (asap) how service works and try to do a simple service using a simple uos app.
But sadly I could not do this at the moment, I am super busy.

Fre;D
12