spkr-beep / beep

beep is a command line tool for linux that beeps the PC speaker
https://github.com/spkr-beep/beep
GNU General Public License v2.0
69 stars 11 forks source link

beep and laptops #43

Open galaxysite opened 1 month ago

galaxysite commented 1 month ago

Hi,

When finding bug in some program, we touch "beep": https://github.com/mse-org/mseide-msegui/issues/24

Beep show error on laptop:

Fstat failed. Errno : 2 But in my system /dev/input/by-path there are only those: Screenshot_2024-10-26_14-24-48 $ beep beep: Error: Could not open any device PS: I have a laptop, maybe pcspkr cannot be installed.

Maybe add to beep My fast-playing low-level code from: https://github.com/galaxysite/gorg64_spkplay and possible music playing from binary files for x86* architecture ?

fredvs commented 4 weeks ago

Did you test it for laptop (usually they dont have pc speaker output in the mother board)? I see in your description that Root priveleges are needed, is it still so? I will test it asap on my laptop.

For msegui (and fpc too) it is a known problem, beep() does not work on lot of Linux laptop. The work-around that I use is to use libasound.so https://github.com/fredvs/alsa_sound

fredvs commented 4 weeks ago

Hello. I did compile spkr-beep but at runing on a XUbuntu 22.04 laptop Lenovo IdeaPad i5 there is that error:

$ sudo ./gorg64_spkplay
GALAXY ORGANIZER SPEAKER PLAYER Version 3
Artyomov Alexander 2021  License: GNU AGPLv3 and above
Use: gorg64_spkplay or gorg64_spkplay somemusic.speaker somemusic2.speaker ...
24321 (process ID) old priority 0, new priority -19
An unhandled exception occurred at $0000000000412A76:
EAccessViolation: Access violation
  $0000000000412A76

And using gdb debugger:

Starting program: /home/fred/gorg64_spkplay-main/gorg64_spkplay 
GALAXY ORGANIZER SPEAKER PLAYER Version 3
Artyomov Alexander 2021  License: GNU AGPLv3 and above
Use: gorg64_spkplay or gorg64_spkplay somemusic.speaker somemusic2.speaker ...
[Detaching after fork from child process 25445]
25442 (process ID) old priority 0, new priority -19

Program received signal SIGSEGV, Segmentation fault.
SPKON () at spkunit.pas:46
46          in      al, 61h
galaxysite commented 4 weeks ago

Not root privileges binary. Need:

chown root:root gorg64_spkplay chmod =04755 gorg64_spkplay

fredvs commented 4 weeks ago

I was able to change permission only with sudo:

fred@fred-IdeaPad:~$ cd /home/fred/gorg64_spkplay-main
fred@fred-IdeaPad:~/gorg64_spkplay-main$ chown root:root gorg64_spkplay
chown: changing ownership of 'gorg64_spkplay': Operation not permitted
fred@fred-IdeaPad:~/gorg64_spkplay-main$ sudo chown root:root gorg64_spkplay
[sudo] password for fred: 
fred@fred-IdeaPad:~/gorg64_spkplay-main$ chown root:root gorg64_spkplay
chown: changing ownership of 'gorg64_spkplay': Operation not permitted
fred@fred-IdeaPad:~/gorg64_spkplay-main$ sudo chown root:root gorg64_spkplay
[sudo] password for fred: 
fred@fred-IdeaPad:~/gorg64_spkplay-main$ chmod =04755 gorg64_spkplay
chmod: changing permissions of 'gorg64_spkplay': Operation not permitted
fred@fred-IdeaPad:~/gorg64_spkplay-main$ sudo chmod =04755 gorg64_spkplay

But running via gdb without root permission:

(gdb) r
Starting program: /home/fred/gorg64_spkplay-main/gorg64_spkplay 
GALAXY ORGANIZER SPEAKER PLAYER Version 3
Artyomov Alexander 2021  License: GNU AGPLv3 and above
Use: gorg64_spkplay or gorg64_spkplay somemusic.speaker somemusic2.speaker ...
[Detaching after fork from child process 77479]
renice: failed to set priority for 77476 (process ID): Permission denied

Program received signal SIGSEGV, Segmentation fault.
SPKON () at spkunit.pas:46
46          in      al, 61h
(gdb)

And running with root permission:

gdb) r
Starting program: /home/fred/gorg64_spkplay-main/gorg64_spkplay 
GALAXY ORGANIZER SPEAKER PLAYER Version 3
Artyomov Alexander 2021  License: GNU AGPLv3 and above
Use: gorg64_spkplay or gorg64_spkplay somemusic.speaker somemusic2.speaker ...
[Detaching after fork from child process 77646]
77643 (process ID) old priority 0, new priority -19

Program received signal SIGSEGV, Segmentation fault.
SPKON () at spkunit.pas:46
46          in      al, 61h
(gdb) 
galaxysite commented 4 weeks ago

Without set uid by root system not give access to I/O (function ioperm fails and "in" operation blocked).

If not working sudo need su.

gdb not have root access.

fredvs commented 3 weeks ago

In XUbuntu su does not work, the equivalent is sudo -i

fred-IdeaPad:~# sudo -i
root@fred-IdeaPad:~# /home/fred/gorg64_spkplay-main/gorg64_spkplay
GALAXY ORGANIZER SPEAKER PLAYER Version 3
Artyomov Alexander 2021  License: GNU AGPLv3 and above
Use: gorg64_spkplay or gorg64_spkplay somemusic.speaker somemusic2.speaker ...
79263 (process ID) old priority 0, new priority -19
An unhandled exception occurred at $0000000000459916:
EAccessViolation: Access violation
  $0000000000459916  SPKON,  line 45 of spkunit.pas
galaxysite commented 3 weeks ago

sudo -i ? May be... But after sudo -i who say chown ?

Need rights: ls -l ./gorg64_spkplay -rwsr-xr-x 1 root root 17544 ноя 2 20:57 ./gorg64_spkplay

fredvs commented 3 weeks ago
root@fred-IdeaPad:~#  ls -l /home/fred/gorg64_spkplay-main/gorg64_spkplay
-rwsr-xr-x 1 root root 1183448 nov  2 18:30 /home/fred/gorg64_spkplay-main/gorg64_spkplay
galaxysite commented 3 weeks ago

1183448 strange numbers. But the rest is correct. Maybe it's a feature of Ubuntu? And then run.

galaxysite commented 3 weeks ago

I update https://github.com/galaxysite/gorg64_spkplay and GORG: http://soft.self-made-free.ru/GORG64_283.tar.xz

Added functions getuid/geteuid and setuid. This might improve clarity at startup and add some features.

fredvs commented 3 weeks ago

I update https://github.com/galaxysite/gorg64_spkplay

Free Pascal Compiler OOTB v. 3.2.4_glibc225 [2024/07/30] for x86_64
Copyright (c) 1993-2024 by Florian Klaempfl & friends.
Target OS: Linux for x86-64
Compiling gorg64_spkplay.pas
Compiling spkunit.pas
gorg64_spkplay.pas(32,43) Fatal: Can't find unit urun used by gorg64_spkplay_syscalls
Fatal: Compilation aborted
galaxysite commented 3 weeks ago

Yes, I add urun and urunu in github.

fredvs commented 3 weeks ago

OK, I will try after the fight with rust. Note that now I am disconnected after you have change the locale to english. When I try to reconnect it say that you are offline.

fredvs commented 3 weeks ago

Yes, I add urun and urunu in github.

....
Compiling gorg64_spkplay.pas
Compiling spkunit.pas
Compiling urun.pas
gorg64_spkplay.pas(94,4) Error: Identifier not found "portserr"
gorg64_spkplay.pas(156,4) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted