Auf der Seite https://github.com/daniel-git/usblamp gibt es einen Treiben um eine USB-Lampe anzusteuern. Das lief bei mir bislang unter debian. Ich habe jetzt aber meinen Rechner neu mit Arch aufgesetzt und stehe vor einem Problem.

make
g++ -Wall -std=c++0x -o usblamp main.cpp USBLamp.cpp USBLamp.hpp Color.cpp Color.hpp -lusb
USBLamp.cpp: In Elementfunktion »void USBLamp::init()«:
USBLamp.cpp:79:61: Fehler: assigning to an array from an initializer list
USBLamp.cpp:82:61: Fehler: assigning to an array from an initializer list
USBLamp.cpp:85:61: Fehler: assigning to an array from an initializer list
make: *** [main] Fehler 1

Momentan habe ich Version: gcc-4.6.0-5

Wer kann weiterhelfen ??

Brauche ich noch ein Paket oder ist die Kombination gcc-Version Code untauglich ?
Wenn ich das richtig sehe wurde dort ein Feature aus c++0x benutzt, welches in gcc 4.6 nicht mehr verfügbar ist. Mit diesem Patch solltest du das beheben können:
diff --git src/USBLamp.cpp src/USBLamp.cpp
index b233e22..e6813db 100644
--- src/USBLamp.cpp
+++ src/USBLamp.cpp
@@ -74,16 +74,15 @@ void USBLamp::send(char *bytes, int size) {
 
 void USBLamp::init() {
     int size = 8;
-    char data[8];
 
-    data = { 0x1f, 0x02, 0x00, 0x2e, 0x00, 0x00, 0x2b, 0x03 };
-    send(data, size);
+    char data1[8] = { 0x1f, 0x02, 0x00, 0x2e, 0x00, 0x00, 0x2b, 0x03 };
+    send(data1, size);
 
-    data = { 0x00, 0x02, 0x00, 0x2e, 0x00, 0x00, 0x2b, 0x04 };
-    send(data, size);
+    char data2[8] = { 0x00, 0x02, 0x00, 0x2e, 0x00, 0x00, 0x2b, 0x04 };
+    send(data2, size);
 
-    data = { 0x00, 0x02, 0x00, 0x2e, 0x00, 0x00, 0x2b, 0x05 };
-    send(data, size);
+    char data3[8] = { 0x00, 0x02, 0x00, 0x2e, 0x00, 0x00, 0x2b, 0x05 };
+    send(data3, size);
 }
 
 void USBLamp::setColor(Color newColor) {
Edit: Ich habe jetzt den Patch ohne git-prefix drin. Diesen kannst du einfach anwenden in dem du
in den Ordner von usblamp welchselst (dort muss ein src/ Ordner sein) und dort den Befehl
patch -p0 < /pfad/zum/patch
aufrufst.

Edit2: Ich einen Fork des Projekts auf github angelegt und dort den Patch eingespielt. Du musst also nur noch dieses Repository clonen: https://github.com/pSub/usblamp
Änderung in USBlamp.cpp:
void USBLamp::init() {
    const int size = 8;
    send("\x1f\x02\x00\x2e\x00\x00\x2b\x03", size);
    send("\x00\x02\x00\x2e\x00\x00\x2b\x04", size);
    send("\x00\x02\x00\x2e\x00\x00\x2b\x05", size);
}
Habe selber keine usblamp, aber vielleicht funktioniert es so ja !?

Gruß, LW.

EDIT: Lösung von pSub hab ich übersehen - ist sicher die Bessere - sorry!
OK, ich habs mit psubs Lösung probiert und, ....

super :-)))))))))))))))))) Sie leuchtet wieder !!!

VIELEN DANK !!
3 Jahre später
Leider funktionieren der patch bzw. fork auf https://github.com/pSub/usblamp nicht mehr.

beim versuch zu compilen passiert folgendes:
make
g++ -Wall -o usblamp main.cpp USBLamp.cpp USBLamp.hpp Color.cpp Color.hpp -lusb
USBLamp.cpp: In member function ‘void USBLamp::setColor(Color)’:
USBLamp.cpp:94:84: warning: narrowing conversion of ‘((USBLamp*)this)->USBLamp::color.Color::red’ from ‘unsigned char’ to ‘char’ inside { } is ill-formed in C++11 [-Wnarrowing]
char data[] = {color.red, color.green, color.blue, 0x00, 0x00, 0x00, 0x00, 0x05};
^
USBLamp.cpp:94:84: warning: narrowing conversion of ‘((USBLamp*)this)->USBLamp::color.Color::green’ from ‘unsigned char’ to ‘char’ inside { } is ill-formed in C++11 [-Wnarrowing]
USBLamp.cpp:94:84: warning: narrowing conversion of ‘((USBLamp*)this)->USBLamp::color.Color::blue’ from ‘unsigned char’ to ‘char’ inside { } is ill-formed in C++11 [-Wnarrowing]
Creshal schriebWarnung ≠ Fehler
Sorry 🙂

Beim Ausführen passiert folgendes:

[root@DEGUSKAOKLAINB src]# usblamp color blue
no lamp found

[root@DEGUSKAOKLAINB src]# lsusb

Bus 004 Device 003: ID 0a5c:5800 Broadcom Corp. BCM5880 Secure Applications Processor
Bus 004 Device 004: ID 1294:1320 RISO KAGAKU CORP.
Bus 004 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 004: ID 413c:2513 Dell Computer Corp. internal USB Hub of E-Port Replicator
Bus 003 Device 007: ID 046a:010a Cherry GmbH
Bus 003 Device 006: ID 05e3:0610 Genesys Logic, Inc. 4-port hub
Bus 003 Device 005: ID 05e3:0610 Genesys Logic, Inc. 4-port hub
Bus 003 Device 003: ID 413c:2513 Dell Computer Corp. internal USB Hub of E-Port Replicator
Bus 003 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

[root@DEGUSKAOKLAINB src]# dmesg | tail -n3

[ 22.884255] fuse init (API version 7.22)
[ 259.277778] usb 4-1.1: new low-speed USB device number 4 using ehci-pci
[ 259.373492] hid-generic 0003:1294:1320.0003: hiddev0,hidraw2: USB HID v1.10 Device [MAIL MAIL ] on usb-0000:00:1d.0-1.1/input0



Eine Idee ?
6 Monate später
  • [gelöscht]

Vermutlich bist du inzwischen selbst drauf gekommen, war ja schon im Januar.
Bei dem Code für die usblamp auf github gehts um das DreamCheeky Device. Bei dem Gerät mit ID 1294:1320 von der Riso Kagaku Corp handelt es sich um einen billigen Klon. Somit ist es klar dass er "no lamp found" sagt, da er eben die unterstützte LED nicht findet.