Posts by tomasherrmann


    hat jemand von euch schonmal von einem
    SPI BSC Slave Modus des Raspberry gehört?
    Neolinga

    die Registerbeschreibung vom BCM2835
    http://www.raspberrypi.org/wp-content/upl…Peripherals.pdf
    hat auf Seite 165 das Bit innerhalb des ControlRegisters CR, das über Master oder Slave entscheidet. Daher halte ich die oft gelesene Aussage, der Raspi hätte die nötige Hardware nicht, einfach für falsch.
    Könnte nicht jemand von den Experten mal den "Software-Hebel" bauen, mit dem sich das Master/Slave-Bit umlegen lässt?

    Hallo wertes Forum,
    mit einer Interrupt-Routine werte ich einen IR-Sensor aus (Fernbedienung) - geht alles so weit so gut.
    Aber:
    wiringPiISR (BUTTON_PIN, INT_EDGE_FALLING, &myInterrupt) macht bei jedem ersten Start Ärger- "unable to open /sys/class/gpio/gpio18/value .. no such file or directory"

    beim zweiten Lauf geht es dann - die Datei ist geschrieben und alles läuft.

    define BUTTON_PIN 1
    int main() {
    // sets up the wiringPi library
    if (wiringPiSetup () < 0) {
    fprintf (stderr, "Unable to setup wiringPi: %s\n", strerror (errno));
    return 1;
    }
    // set Pin 18/1 generate an interrupt on high-to-low transitions and attaches myInterrupt() to the interrupt
    if ( wiringPiISR (BUTTON_PIN, INT_EDGE_FALLING, &myInterrupt) < 0 ) {
    fprintf (stderr, "Unable to setup ISR: %s\n", strerror (errno));
    return 1;
    }

    hat jemand eine Idee?

    Gruss Tomas

    rpi444 : das war´s !

    Code
    #!/usr/bin/env bash

    mit dieser shebang kriege ich den Listeneintrag, den das Herz begehrt!
    bash ./dauerlauf.sh

    (ganz kleines ja aber: warum hat nur dieser blöde Interpreter vorher nicht gemotzt, sondern den Rest des Scripts brav erledigt...)

    HERZLICHEN DANK an alle, die mir geholfen haben, Gruss Tomas

    Das glaube ich dir nicht. Poste mal die Ausgabe von:

    Code
    ps aux

    mach ich:
    USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
    root 1 2.3 0.1 2144 728 ? Ss 21:05 0:01 init [2]
    root 2 0.0 0.0 0 0 ? S 21:05 0:00 [kthreadd]
    root 3 0.0 0.0 0 0 ? S 21:05 0:00 [ksoftirqd/0]
    root 4 0.0 0.0 0 0 ? S 21:05 0:00 [kworker/0:0]
    root 5 0.0 0.0 0 0 ? S< 21:05 0:00 [kworker/0:0H]
    root 6 0.1 0.0 0 0 ? S 21:05 0:00 [kworker/u:0]
    root 7 0.0 0.0 0 0 ? S< 21:05 0:00 [kworker/u:0H]
    root 8 0.0 0.0 0 0 ? S< 21:05 0:00 [khelper]
    root 9 0.0 0.0 0 0 ? S 21:05 0:00 [kdevtmpfs]
    root 10 0.0 0.0 0 0 ? S< 21:05 0:00 [netns]
    root 11 0.1 0.0 0 0 ? S 21:05 0:00 [kworker/0:1]
    root 12 0.0 0.0 0 0 ? S 21:05 0:00 [bdi-default]
    root 13 0.0 0.0 0 0 ? S< 21:05 0:00 [kblockd]
    root 14 0.4 0.0 0 0 ? S 21:05 0:00 [khubd]
    root 15 0.0 0.0 0 0 ? S< 21:05 0:00 [rpciod]
    root 16 0.0 0.0 0 0 ? S 21:05 0:00 [khungtaskd]
    root 17 0.0 0.0 0 0 ? S 21:05 0:00 [kswapd0]
    root 18 0.0 0.0 0 0 ? S 21:05 0:00 [fsnotify_mark]
    root 19 0.0 0.0 0 0 ? S< 21:05 0:00 [nfsiod]
    root 20 0.0 0.0 0 0 ? S< 21:05 0:00 [crypto]
    root 27 0.0 0.0 0 0 ? S< 21:05 0:00 [kthrotld]
    root 28 0.0 0.0 0 0 ? S< 21:05 0:00 [VCHIQ-0]
    root 29 0.0 0.0 0 0 ? S< 21:05 0:00 [VCHIQr-0]
    root 30 0.0 0.0 0 0 ? S< 21:05 0:00 [VCHIQs-0]
    root 31 0.0 0.0 0 0 ? S< 21:05 0:00 [iscsi_eh]
    root 32 0.0 0.0 0 0 ? S< 21:05 0:00 [dwc_otg]
    root 33 0.0 0.0 0 0 ? S< 21:05 0:00 [DWC Notificatio]
    root 34 0.0 0.0 0 0 ? S 21:05 0:00 [kworker/u:1]
    root 35 0.0 0.0 0 0 ? S< 21:05 0:00 [deferwq]
    root 36 0.1 0.0 0 0 ? S 21:05 0:00 [kworker/u:2]
    root 37 1.6 0.0 0 0 ? S 21:05 0:01 [mmcqd/0]
    root 38 0.0 0.0 0 0 ? S 21:05 0:00 [jbd2/mmcblk0p2-]
    root 39 0.0 0.0 0 0 ? S< 21:05 0:00 [ext4-dio-unwrit]
    root 120 0.0 0.0 0 0 ? S 21:05 0:00 [scsi_eh_0]
    root 121 0.0 0.0 0 0 ? S 21:05 0:00 [usb-storage]
    root 162 0.0 0.0 0 0 ? S 21:05 0:00 [kworker/0:2]
    root 164 0.0 0.0 0 0 ? S 21:05 0:00 [kworker/u:3]
    root 208 0.6 0.2 2880 1272 ? Ss 21:05 0:00 udevd --daemon
    root 337 0.0 0.2 2876 996 ? S 21:05 0:00 udevd --daemon
    root 342 0.0 0.2 2876 996 ? S 21:05 0:00 udevd --daemon
    root 353 0.0 0.0 0 0 ? S 21:05 0:00 [flush-179:0]
    root 1576 0.0 0.1 1744 504 ? S 21:05 0:00 /usr/sbin/ifplugd -i lo -q -f -u0 -d10 -w -I
    root 1626 0.0 0.1 1744 512 ? S 21:05 0:00 /usr/sbin/ifplugd -i eth0 -q -f -u0 -d10 -w -I
    root 1947 0.1 0.3 27968 1548 ? Sl 21:05 0:00 /usr/sbin/rsyslogd -c5
    root 2003 0.0 0.1 4020 520 ? Ss 21:05 0:00 /usr/sbin/cron
    104 2016 0.5 0.2 3316 1284 ? Ss 21:05 0:00 /usr/bin/dbus-daemon --system
    root 2070 0.3 0.6 30712 3024 ? Sl 21:05 0:00 /usr/sbin/lightdm
    root 2085 1.7 1.5 16532 7132 tty7 Ss+ 21:05 0:00 /usr/bin/X :0 -auth /var/run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch
    root 2139 0.3 0.7 15320 3144 ? Sl 21:05 0:00 lightdm --session-child 12 15
    proftpd 2140 0.0 0.3 9860 1768 ? Ss 21:05 0:00 proftpd: (accepting connections)
    root 2164 0.6 0.8 27428 3760 ? Sl 21:05 0:00 /usr/sbin/console-kit-daemon --no-daemon
    root 2172 0.0 0.1 1668 456 ? Ss 21:05 0:00 /usr/bin/shutkey
    root 2252 0.7 0.7 22736 3380 ? Sl 21:05 0:00 /usr/lib/policykit-1/polkitd --no-debug
    pi 2294 0.2 0.3 12792 1508 ? Ssl 21:05 0:00 /usr/bin/lxsession -s LXDE -e LXDE
    nobody 2323 0.0 0.1 2012 636 ? Ss 21:05 0:00 /usr/sbin/thd --daemon --triggers /etc/triggerhappy/triggers.d/ --socket /var/run/thd.socket --pidfile /var/run/thd.pid --user nobody /dev/input/event*
    pi 2338 0.0 0.0 3520 352 ? Ss 21:05 0:00 /usr/bin/ssh-agent /usr/bin/dbus-launch --exit-with-session x-session-manager
    pi 2341 0.0 0.1 3368 712 ? S 21:05 0:00 /usr/bin/dbus-launch --exit-with-session x-session-manager
    pi 2342 0.1 0.2 3308 968 ? Ss 21:05 0:00 /usr/bin/dbus-daemon --fork --print-pid 5 --print-address 7 --session
    pi 2348 1.6 1.3 15612 6256 ? S 21:05 0:00 openbox --config-file /home/pi/.config/openbox/lxde-rc.xml
    pi 2351 2.7 2.0 82616 9068 ? S 21:05 0:01 lxpanel --profile LXDE
    pi 2354 2.8 2.6 94164 11692 ? S 21:05 0:01 pcmanfm --desktop --profile LXDE
    root 2361 1.5 2.0 12036 9148 ? S 21:05 0:00 Xtightvnc :1 -desktop X -auth /root/.Xauthority -geometry 1024x786 -depth 24 -rfbwait 120000 -rfbauth /root/.vnc/passwd -rfbport 5901 -fp /usr/share/fonts/X11/misc/,/usr/share/fonts/X11/Type1/,/usr/share/fonts/X11/75dpi/,/usr/share/fonts/X11/100dpi/ -co /etc/X11/rgb
    pi 2363 0.4 1.0 26656 4736 ? Sl 21:05 0:00 /usr/lib/arm-linux-gnueabihf/lxpolkit
    root 2368 0.0 0.1 1752 512 ? S 21:06 0:00 /bin/sh /root/.vnc/xstartup
    pi 2380 0.1 0.5 9264 2320 ? S 21:06 0:00 /usr/lib/gvfs/gvfsd
    root 2381 0.1 0.2 5684 1288 ? S 21:06 0:00 /usr/bin/ck-launch-session /usr/bin/dbus-launch --exit-with-session x-session-manager
    pi 2390 0.0 0.5 6452 2348 ? S 21:06 0:00 /usr/lib/arm-linux-gnueabihf/libmenu-cache1/libexec/menu-cached
    root 2402 0.0 0.1 4288 804 tty1 Ss+ 21:06 0:00 /sbin/getty --noclear 38400 tty1
    root 2403 0.0 0.1 4288 804 tty2 Ss+ 21:06 0:00 /sbin/getty 38400 tty2
    root 2404 0.0 0.1 4288 804 tty3 Ss+ 21:06 0:00 /sbin/getty 38400 tty3
    root 2405 0.0 0.1 4288 804 tty4 Ss+ 21:06 0:00 /sbin/getty 38400 tty4
    root 2406 0.0 0.1 4288 804 tty5 Ss+ 21:06 0:00 /sbin/getty 38400 tty5
    root 2407 0.0 0.1 4288 804 tty6 Ss+ 21:06 0:00 /sbin/getty 38400 tty6
    root 2408 0.0 0.1 2060 732 ttyAMA0 Ss+ 21:06 0:00 /sbin/getty -L ttyAMA0 115200 vt100
    root 2419 0.0 0.0 3520 352 ? Ss 21:06 0:00 /usr/bin/ssh-agent /usr/bin/ck-launch-session /usr/bin/dbus-launch --exit-with-session x-session-manager
    root 2429 0.1 0.3 12792 1496 ? Sl 21:06 0:00 /usr/bin/lxsession -s LXDE -e LXDE
    root 2433 0.0 0.1 3368 712 ? S 21:06 0:00 /usr/bin/dbus-launch --exit-with-session x-session-manager
    root 2436 0.1 0.2 3308 996 ? Ss 21:06 0:00 /usr/bin/dbus-daemon --fork --print-pid 5 --print-address 7 --session
    root 2450 0.8 1.2 12852 5688 ? S 21:06 0:00 openbox --config-file /root/.config/openbox/lxde-rc.xml
    root 2452 2.7 1.9 79832 8608 ? S 21:06 0:01 lxpanel --profile LXDE
    root 2455 2.3 2.2 90464 10056 ? S 21:06 0:00 pcmanfm --desktop --profile LXDE
    root 2468 0.4 0.9 24140 4388 ? Sl 21:06 0:00 /usr/lib/arm-linux-gnueabihf/lxpolkit
    root 2512 1.0 0.7 9804 3260 ? Ss 21:06 0:00 sshd: root@pts/0
    root 2515 0.1 0.5 6452 2348 ? S 21:06 0:00 /usr/lib/arm-linux-gnueabihf/libmenu-cache1/libexec/menu-cached
    root 2518 0.1 0.4 7044 2132 ? S 21:06 0:00 /usr/lib/gvfs/gvfsd
    root 2520 0.1 0.6 31660 2720 ? Sl 21:06 0:00 /usr/lib/gvfs//gvfs-fuse-daemon -f /root/.gvfs
    ntp 2536 0.0 0.3 5376 1380 ? Ss 21:06 0:00 /usr/sbin/ntpd -p /var/run/ntpd.pid -g -c /var/lib/ntp/ntp.conf.dhcp -u 102:104
    root 2537 0.0 0.4 4892 1992 ? Ss 21:06 0:00 dhclient -v -pf /run/dhclient.eth0.pid -lf /var/lib/dhcp/dhclient.eth0.leases eth0
    root 2584 0.0 0.2 6208 1060 ? Ss 21:06 0:00 /usr/sbin/sshd
    root 2592 1.2 0.7 9804 3260 ? Ss 21:06 0:00 sshd: root@pts/1
    pi 2597 0.7 0.8 34836 3768 ? S 21:06 0:00 /usr/lib/gvfs/gvfs-gdu-volume-monitor
    root 2599 1.3 0.7 23144 3492 ? Sl 21:06 0:00 /usr/lib/udisks/udisks-daemon
    root 2600 0.0 0.1 6184 844 ? S 21:06 0:00 udisks-daemon: polling /dev/sda
    pi 2603 0.1 0.5 9460 2276 ? S 21:06 0:00 /usr/lib/gvfs/gvfs-gphoto2-volume-monitor
    pi 2605 0.1 0.5 19692 2304 ? Sl 21:06 0:00 /usr/lib/gvfs/gvfs-afc-volume-monitor
    root 2613 0.6 0.7 33524 3580 ? S 21:06 0:00 /usr/lib/gvfs/gvfs-gdu-volume-monitor
    root 2617 0.0 0.2 4808 1252 pts/0 Ss 21:06 0:00 bash -c cd /root/projects ; /bin/bash
    root 2618 1.1 0.4 5432 1948 pts/0 S 21:06 0:00 /bin/bash
    root 2623 0.1 0.4 7384 2172 ? S 21:06 0:00 /usr/lib/gvfs/gvfs-gphoto2-volume-monitor
    root 2625 0.1 0.5 17672 2332 ? Sl 21:06 0:00 /usr/lib/gvfs/gvfs-afc-volume-monitor
    root 2630 0.0 0.2 4808 1252 pts/1 Ss 21:06 0:00 bash -c cd /root/projects ; /bin/bash
    root 2631 0.1 0.4 5304 1808 pts/1 S 21:06 0:00 /bin/bash
    root 2632 0.1 0.2 5432 1192 pts/0 S+ 21:06 0:00 /bin/bash
    root 2637 89.8 0.2 3820 1228 pts/0 R+ 21:06 0:06 /root/projects/mp3/play
    root 2638 0.0 0.2 5000 1128 pts/1 R+ 21:06 0:00 ps aux

    und die Ausgabe von "pid-von-dauerlauf.pid" lautet: 2632

    Danke, dass Ihr mich noch nicht als völlig hoffnungslosen Fall aufgegeben habt!

    meigrafd: & und forken ist mir jetzt deutlich klarer geworden!

    Was aber bleibt, ist mein Problem mit dem Vorgehen nach Beitrag 5

    Code
    PiD=$(ps aux | grep -v grep | grep test.sh | awk {'print $2'})
    
    
    if [ ! -z "$PiD" ]; then
    
    
      kill -9 $PiD
    
    
    fi


    auch das ps aux liefert nicht den Namen des gestarteten scripts - da kommt nur /bin/bash.

    Ist da was falsch konfiguriert im Betriebssystem?

    Mit der Benutzung von "&" innerhalb deines Scriptes, hast Du durch "forken" einen neuen Prozess (child process) mit einer neuen PID erzeugt.
    Diese child PID sollte in der Variablen $! gespeichert sein.

    Besten Dank für die Erklärung! - ich wusste in der Tat nicht, was das ampersand macht.
    (Ohne "&" komme ich in der Tat nicht in die Nähe eines brauchbaren Ergebnisses)

    hallo, Ihr habt mir echt geholfen - Danke!

    meine derzeitige Lösung sieht jetzt so aus :dauerlauf.sh


    und zum abwürgen: aus.sh

    Code
    #! /bin/bash
    # aus.sh kann den "dauerlauf" prozess abbrechen
    PiD=$(cat pid-von-dauerlauf.pid) 
    ((PiDn=$PiD+1))
    kill $PiDn

    könnte mir noch jemand erklären, warum ich als PID eins zu wenig kriege?

    Hallo,

    gibt es eine Möglichkeit, einem Prozess, der durch ein script (bin/bash) erzeugt wird, einen Namen zu geben?

    Das Script, i.a.W. der Prozess läuft als Endlosschleife, soweit alles ok.
    Wenn ich den Prozess aber doch mal abbrechen möchte, wäre es schick, dies mit
    killall meinProzess
    tun zu können.

    Gruss Tomas

    Hallo wertes Forum,

    mein Projekt ist ein Raspi-MP3 Spieler. Das Lesen und Wechseln von Verzeichnissen auf einem USB-Stick geht auch schon fein. Nun hätte ich aber gern, dass der Raspi auch "merkt", wenn der Stick abgezogen und ein anderer Stick drankommt (es soll dann wieder von Root aus die Baumstruktur erfasst werden etc.).

    Wie kann ich in meiner Hauptprogrammschleife am schnellsten (und mit erträglichem Programmieraufwand) erfahren, dass der Stick gewechselt wurde??

    In der grafischen Umgebung kommt ja beim Anstecken ein Fenster hoch (removable media inserted). Kann ich dieses Signal auch irgendwie in meinem C++ Programm ausnutzen??

    Gruss Tomas

    echt heissen Dank!
    ok, ich wollte auch gerade wieder sachlich werden. Und ich hatte auch schon eine Menge Text geschrieben, als mir mein firefox abstürzte.

    Also, ich habe inzwischen automake und libtool nachinstalliert, die install Anweisung aus mpg123-1.15.4.tar.bz2, Punkt 3 "3. Library-only build" befolgt, meine Dateien an der richtigen Stelle liegen,
    und kriege leider üble Fehler vom Compiler gemeldet. Da werde ich mich jetzt drüber hermachen.
    Gruss Tomas


    gcc -Wall -o "play" "play.c" (in directory: /home/pi/c/geany/mp3)
    play.c: In function 'main':
    play.c:47:9: warning: pointer targets in passing argument 2 of 'ao_play' differ in signedness [-Wpointer-sign]
    /home/pi/c/geany/mp3/ao/ao.h:119:23: note: expected 'char *' but argument is of type 'unsigned char *'
    Compilation failed.
    /tmp/ccjNwuec.o: In function `main':
    play.c.text+0x28): undefined reference to `ao_initialize'
    play.c.text+0x2c): undefined reference to `ao_default_driver_id'
    play.c.text+0x34): undefined reference to `mpg123_init'
    play.c.text+0x44): undefined reference to `mpg123_new'
    play.c.text+0x50): undefined reference to `mpg123_outblock'
    play.c.text+0x7c): undefined reference to `mpg123_open'
    play.c.text+0x90): undefined reference to `mpg123_getformat'
    play.c.text+0x9c): undefined reference to `mpg123_encsize'
    play.c.text+0xdc): undefined reference to `ao_open_live'
    play.c.text+0xf8): undefined reference to `ao_play'
    play.c.text+0x10c): undefined reference to `mpg123_read'
    play.c.text+0x128): undefined reference to `ao_close'
    play.c.text+0x130): undefined reference to `mpg123_close'
    play.c.text+0x138): undefined reference to `mpg123_delete'
    play.c.text+0x13c): undefined reference to `mpg123_exit'
    play.c.text+0x140): undefined reference to `ao_shutdown'
    collect2: ld returned 1 exit status

    "Und wenn Du mal scharf nachdenkst und ein bisschen C kannst, weisst Du wo Du suchen musst ..."

    weisst Du, das sind so echt hilfreiche Sätze...
    Mit Operatoren, Datentypen, Zeigern, Syntax und den eigentlichen Sprachmerkmalen kommt man echt mit Wikis, Beispielprogrammen und Büchern gut weiter - macht sogar echt Spass.
    Aber wo ein Unix-System am liebsten seine Dateien ablegt - und wo C gern nachschaut, das ist für mich als Einsteiger wirklich noch recht finster. Und da finde ich in der Tat viel weniger Hinweise - und Nachdenken hilft an dieser Stelle nicht wirklich.

    Denkfaulheit ist nicht mein Problem. Eher herablassende Antworten.
    Ich schreib das mal so ausführlich, weil´s doch wirklich hilfreicher und netter ginge.

    Ein Satz wie:
    "Die Dateien landen unter /usr/include/c++/4.6/libmpg123" würde doch auch nicht weh tun.
    (Leider ist er halt falsch...)

    Gruss Tomas

    hi dreamshader,
    nö, ein Beispiel hat noch nicht funktioniert. Und ich möchte auch keine magischen Erkenntnisse.
    Vielleicht ein wenig mehr konkrete Hinweise. (Unter Delphi hab ich die auch immer gern gegeben)

    Mein Ziel ist das unten stehende Programm kompilieren zu können.
    Das ist der Schritt zum MP3-Player, der mir noch fehlt. Im Augenblick erkennt mein Raspi einen USB-Stick, liest Verzeichnisse ein (in Stringarrays oder wahlweise doppelt verkettete Zeigerlisten, stellt die Dateien auf einem Grafik-Display dar (über SPI), fragt Knöppe ab , und möchte dann losdudeln.
    (Also bitte nicht gleich die Tour : wenn du ein bisschen C könntest [oder dich mal mit Linux beschäftigen würdest] und mal in ein Buch schaust... usw und fort - ich bin halt nicht mit C auf die Welt gekommen)

    Gruss Tomas


    #include <ao/ao.h>
    #include <mpg123.h>

    #define BITS 8

    int main(int argc, char *argv[])
    {
    mpg123_handle *mh;
    unsigned char *buffer;
    size_t buffer_size;
    size_t done;
    int err;

    int driver;
    ao_device *dev;

    ao_sample_format format;
    int channels, encoding;
    long rate;

    if(argc < 2)
    exit(0);

    /* initializations */
    ao_initialize();
    driver = ao_default_driver_id();
    mpg123_init();
    mh = mpg123_new(NULL, &err);
    buffer_size = mpg123_outblock(mh);
    buffer = (unsigned char*) malloc(buffer_size * sizeof(unsigned char));

    /* open the file and get the decoding format */
    mpg123_open(mh, argv[1]);
    mpg123_getformat(mh, &rate, &channels, &encoding);

    /* set the output format and open the output device */
    format.bits = mpg123_encsize(encoding) * BITS;
    format.rate = rate;
    format.channels = channels;
    format.byte_format = AO_FMT_NATIVE;
    format.matrix = 0;
    dev = ao_open_live(driver, &format, NULL);

    /* decode and play */
    while (mpg123_read(mh, buffer, buffer_size, &done) == MPG123_OK)
    ao_play(dev, buffer, done);

    /* clean up */
    free(buffer);
    ao_close(dev);
    mpg123_close(mh);
    mpg123_delete(mh);
    mpg123_exit();
    ao_shutdown();

    return 0;
    }

    /*
    Save the code as play.c and build it. Remember you must first install libmpg123 and libao.

    gcc -O2 -o play play.c -lmpg123 -lao

    Run the programm with a mp3 file path in command line.

    ./play /path/to/file.mp3
    */