Zum Inhalt springen

Shern

Mitglieder
  • Gesamte Inhalte

    6
  • Benutzer seit

  • Letzter Besuch

  1. Shern

    Anfänger Hilfe

    Stooooooooooooooooop Kommando zurück ... eine Frage hab ich noch : Kann ich über ein Script or so die Daten aus einer Datei auslesen die minütlich aktualisiert wird auslesen und in eine Ssql oder Mysql Datenbank speichern? Das hört sich kompliziert an und möchte nicht auch noch ( noch nicht ) Mysql lernen :cool:. Ne ist bestimmt cool aber mir zuviel für den ersten Monat. Vielleicht könnt ihr mir helfen und anstoss geben wie ich es hinbekommen könnte da ich angst habe das die Datei sehr schnell sehr groß wird. Ich glaub an euch ihr schaft das
  2. Shern

    Anfänger Hilfe

    Sooo ich habe die Schleife herausgenommen und der Fehler trat auf da ich die Dateien auf Windows entpackt habe und per WinSCP hochgeladen habe und Windows hat mir dann die Dateien zerschossen und konnte sie nicht kompilieren. Nun habe ich ein crontab laufen der mir jede Minute die Temperatur ausgibt als Zahl. Diese wird auch in eine Datei geschrieben und von da mit PHP ausgelesen... und es funktioniert einwandfrei . Dafür großen Dank an alle ich vermute php verlauf und diagramme etc gehören nicht hier rein deswegen kann geclosed oder verschoben werden (ersteres wäre cool )
  3. Shern

    Anfänger Hilfe

    Ok das mit dem Pipen funzt nicht d.h. er schreibt nichts in die Datei aber ich vermute das er nichts hineinschreiben da es eine endlosschleife ist und erst schreibt wenn sie beendet ist!? (Vermute ich). Darum habe ich gedacht wenn ich das sleep am Ende wegnehme ob die Datei dann sich beendet. Nun beim gcc compilieren kommen tausende Fehler deswegen nochmal der Hilfe schrei an euch, was zum Teufel ist daran alles falsch das er diese Fehler ausgibt: Temper.c Datei-Inhalt: #include <stdio.h> #include <string.h> #include <usb.h> #include <errno.h> /* * Temper.c by Robert Kavaler (c) 2009 (relavak.com) * All rights reserved. * * Temper driver for linux. This program can be compiled either as a library * or as a standalone program (-DUNIT_TEST). The driver will work with some * TEMPer usb devices from RDing (www.PCsensor.com). * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * THIS SOFTWARE IS PROVIDED BY Robert Kavaler ''AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Robert kavaler BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #include "temper.h" #define VENDOR_ID 0x1130 #define PRODUCT_ID 0x660c struct Temper { struct usb_device *device; usb_dev_handle *handle; int debug; int timeout; }; Temper * TemperCreate(struct usb_device *dev, int timeout, int debug) { Temper *t; int ret; t = calloc(1, sizeof(*t)); t->device = dev; t->debug = debug; t->timeout = timeout; t->handle = usb_open(t->device); if(!t->handle) { free(t); return NULL; } if(t->debug) { printf("Trying to detach kernel driver\n"); } ret = usb_detach_kernel_driver_np(t->handle, 0); if(ret) { if(errno == ENODATA) { if(t->debug) { printf("Device already detached\n"); } } else { if(t->debug) { printf("Detach failed: %s[%d]\n", strerror(errno), errno); printf("Continuing anyway\n"); } } } else { if(t->debug) { printf("detach successful\n"); } } ret = usb_detach_kernel_driver_np(t->handle, 1); if(ret) { if(errno == ENODATA) { if(t->debug) printf("Device already detached\n"); } else { if(t->debug) { printf("Detach failed: %s[%d]\n", strerror(errno), errno); printf("Continuing anyway\n"); } } } else { if(t->debug) { printf("detach successful\n"); } } if(usb_set_configuration(t->handle, 1) < 0 || usb_claim_interface(t->handle, 0) < 0 || usb_claim_interface(t->handle, 1)) { usb_close(t->handle); free(t); return NULL; } return t; } Temper * TemperCreateFromDeviceNumber(int deviceNum, int timeout, int debug) { struct usb_bus *bus; int n; n = 0; for(bus=usb_get_busses(); bus; bus=bus->next) { struct usb_device *dev; for(dev=bus->devices; dev; dev=dev->next) { if(debug) { printf("Found device: %04x:%04x\n", dev->descriptor.idVendor, dev->descriptor.idProduct); } if(dev->descriptor.idVendor == VENDOR_ID && dev->descriptor.idProduct == PRODUCT_ID) { if(debug) { printf("Found deviceNum %d\n", n); } if(n == deviceNum) { return TemperCreate(dev, timeout, debug); } n++; } } } return NULL; } void TemperFree(Temper *t) { if(t) { if(t->handle) { usb_close(t->handle); } free(t); } } static int TemperSendCommand(Temper *t, int a, int b, int c, int d, int e, int f, int g, int h) { unsigned char buf[32]; int ret; bzero(buf, 32); buf[0] = a; buf[1] = b; buf[2] = c; buf[3] = d; buf[4] = e; buf[5] = f; buf[6] = g; buf[7] = h; if(t->debug) { printf("sending bytes %d, %d, %d, %d, %d, %d, %d, %d\n", a, b, c, d, e, f, g, h); } ret = usb_control_msg(t->handle, 0x21, 9, 0x200, 0x01, (char *) buf, 32, t->timeout); if(ret != 32) { perror("usb_control_msg failed"); return -1; } return 0; } static int TemperGetData(Temper *t, char *buf, int len) { int ret; return usb_control_msg(t->handle, 0xa1, 1, 0x300, 0x01, (char *) buf, len, t->timeout); } int TemperGetTemperatureInC(Temper *t, float *tempC) { char buf[256]; int ret, temperature, i; TemperSendCommand(t, 10, 11, 12, 13, 0, 0, 2, 0); TemperSendCommand(t, 0x54, 0, 0, 0, 0, 0, 0, 0); for(i = 0; i < 7; i++) { TemperSendCommand(t, 0, 0, 0, 0, 0, 0, 0, 0); } TemperSendCommand(t, 10, 11, 12, 13, 0, 0, 1, 0); ret = TemperGetData(t, buf, 256); if(ret < 2) { return -1; } temperature = (buf[1] & 0xFF) + (buf[0] << 8); temperature += 1152; // calibration value *tempC = temperature * (125.0 / 32000.0); return 0; } int TemperGetOtherStuff(Temper *t, char *buf, int length) { TemperSendCommand(t, 10, 11, 12, 13, 0, 0, 2, 0); TemperSendCommand(t, 0x52, 0, 0, 0, 0, 0, 0, 0); TemperSendCommand(t, 10, 11, 12, 13, 0, 0, 1, 0); return TemperGetData(t, buf, length); } #ifdef UNIT_TEST #define USB_TIMEOUT 1000 /* milliseconds */ int main(void) { Temper *t; char buf[256]; int i, ret; usb_set_debug(0); usb_init(); usb_find_busses(); usb_find_devices(); t = TemperCreateFromDeviceNumber(0, USB_TIMEOUT, 1); if(!t) { perror("TemperCreate"); exit(-1); } /* TemperSendCommand(t, 10, 11, 12, 13, 0, 0, 2, 0); TemperSendCommand(t, 0x43, 0, 0, 0, 0, 0, 0, 0); TemperSendCommand(t, 0, 0, 0, 0, 0, 0, 0, 0); TemperSendCommand(t, 0, 0, 0, 0, 0, 0, 0, 0); TemperSendCommand(t, 0, 0, 0, 0, 0, 0, 0, 0); TemperSendCommand(t, 0, 0, 0, 0, 0, 0, 0, 0); TemperSendCommand(t, 0, 0, 0, 0, 0, 0, 0, 0); TemperSendCommand(t, 0, 0, 0, 0, 0, 0, 0, 0); */ bzero(buf, 256); ret = TemperGetOtherStuff(t, buf, 256); printf("Other Stuff (%d bytes):\n", ret); for(i = 0; i < ret; i++) { printf(" %02x", buf[i] & 0xFF); if(i % 16 == 15) { printf("\n"); } } printf("\n"); for(; { float tempc; if(TemperGetTemperatureInC(t, &tempc) < 0) { perror("TemperGetTemperatureInC"); exit(1); } printf("temperature %.2fF %.2fC\n", (9.0 / 5.0 * tempc + 32.0), tempc); sleep(10); } return 0; } #endif [/code] Was muss ich da genau ändern damit er nicht diese Schleife fortsetzt. Ausgabe wenn ich compiliere: Davor und danach kommt genau im Anschluss die Eingabe befehlszeile die ich weg geschnitten habe wegen sicherheitsgründen. Eingegeben habe ich "gcc temper.c temper".
  4. Shern

    Anfänger Hilfe

    Hey ok also ich hab mal etwas gelernt und hab auch anschub von meinem Ausbilder bekommen in Sachen Linux nun habe ich den USB TEMPer installiert ( wenn ich es so nennen darf und eingerichtet das heißt er funkt tadellos) Nun geht auch alles mit der Software dh es zeigt eine Temperatur an. Nun muss ich aber diese Daten also die Temperatur iwie in eine Art Datenbank schreiben und sie dann mit php auf einer html seite ausgeben. Das problem dabei ist der Prozess zeigt diese Temperaturren nur an und schreibt sie nicht in eine log oder so. Nun meine Frage an die Linux Pros kann ich diese Daten die er ausgibt iwie abfangen/auslesen/speichern um sie weiter benutzen zu können? Der Code der Date ist: #include <stdio.h> #include <string.h> #include <usb.h> #include <errno.h> /* * Temper.c by Robert Kavaler (c) 2009 (relavak.com) * All rights reserved. * * Temper driver for linux. This program can be compiled either as a library * or as a standalone program (-DUNIT_TEST). The driver will work with some * TEMPer usb devices from RDing (www.PCsensor.com). * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * THIS SOFTWARE IS PROVIDED BY Robert Kavaler ''AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Robert kavaler BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #include "temper.h" #define VENDOR_ID 0x1130 #define PRODUCT_ID 0x660c struct Temper { struct usb_device *device; usb_dev_handle *handle; int debug; int timeout; }; Temper * TemperCreate(struct usb_device *dev, int timeout, int debug) { Temper *t; int ret; t = calloc(1, sizeof(*t)); t->device = dev; t->debug = debug; t->timeout = timeout; t->handle = usb_open(t->device); if(!t->handle) { free(t); return NULL; } if(t->debug) { printf("Trying to detach kernel driver\n"); } ret = usb_detach_kernel_driver_np(t->handle, 0); if(ret) { if(errno == ENODATA) { if(t->debug) { printf("Device already detached\n"); } } else { if(t->debug) { printf("Detach failed: %s[%d]\n", strerror(errno), errno); printf("Continuing anyway\n"); } } } else { if(t->debug) { printf("detach successful\n"); } } ret = usb_detach_kernel_driver_np(t->handle, 1); if(ret) { if(errno == ENODATA) { if(t->debug) printf("Device already detached\n"); } else { if(t->debug) { printf("Detach failed: %s[%d]\n", strerror(errno), errno); printf("Continuing anyway\n"); } } } else { if(t->debug) { printf("detach successful\n"); } } if(usb_set_configuration(t->handle, 1) < 0 || usb_claim_interface(t->handle, 0) < 0 || usb_claim_interface(t->handle, 1)) { usb_close(t->handle); free(t); return NULL; } return t; } Temper * TemperCreateFromDeviceNumber(int deviceNum, int timeout, int debug) { struct usb_bus *bus; int n; n = 0; for(bus=usb_get_busses(); bus; bus=bus->next) { struct usb_device *dev; for(dev=bus->devices; dev; dev=dev->next) { if(debug) { printf("Found device: %04x:%04x\n", dev->descriptor.idVendor, dev->descriptor.idProduct); } if(dev->descriptor.idVendor == VENDOR_ID && dev->descriptor.idProduct == PRODUCT_ID) { if(debug) { printf("Found deviceNum %d\n", n); } if(n == deviceNum) { return TemperCreate(dev, timeout, debug); } n++; } } } return NULL; } void TemperFree(Temper *t) { if(t) { if(t->handle) { usb_close(t->handle); } free(t); } } static int TemperSendCommand(Temper *t, int a, int b, int c, int d, int e, int f, int g, int h) { unsigned char buf[32]; int ret; bzero(buf, 32); buf[0] = a; buf[1] = b; buf[2] = c; buf[3] = d; buf[4] = e; buf[5] = f; buf[6] = g; buf[7] = h; if(t->debug) { printf("sending bytes %d, %d, %d, %d, %d, %d, %d, %d\n", a, b, c, d, e, f, g, h); } ret = usb_control_msg(t->handle, 0x21, 9, 0x200, 0x01, (char *) buf, 32, t->timeout); if(ret != 32) { perror("usb_control_msg failed"); return -1; } return 0; } static int TemperGetData(Temper *t, char *buf, int len) { int ret; return usb_control_msg(t->handle, 0xa1, 1, 0x300, 0x01, (char *) buf, len, t->timeout); } int TemperGetTemperatureInC(Temper *t, float *tempC) { char buf[256]; int ret, temperature, i; TemperSendCommand(t, 10, 11, 12, 13, 0, 0, 2, 0); TemperSendCommand(t, 0x54, 0, 0, 0, 0, 0, 0, 0); for(i = 0; i < 7; i++) { TemperSendCommand(t, 0, 0, 0, 0, 0, 0, 0, 0); } TemperSendCommand(t, 10, 11, 12, 13, 0, 0, 1, 0); ret = TemperGetData(t, buf, 256); if(ret < 2) { return -1; } temperature = (buf[1] & 0xFF) + (buf[0] << 8); temperature += 1152; // calibration value *tempC = temperature * (125.0 / 32000.0); return 0; } int TemperGetOtherStuff(Temper *t, char *buf, int length) { TemperSendCommand(t, 10, 11, 12, 13, 0, 0, 2, 0); TemperSendCommand(t, 0x52, 0, 0, 0, 0, 0, 0, 0); TemperSendCommand(t, 10, 11, 12, 13, 0, 0, 1, 0); return TemperGetData(t, buf, length); } #ifdef UNIT_TEST #define USB_TIMEOUT 1000 /* milliseconds */ int main(void) { Temper *t; char buf[256]; int i, ret; usb_set_debug(0); usb_init(); usb_find_busses(); usb_find_devices(); t = TemperCreateFromDeviceNumber(0, USB_TIMEOUT, 1); if(!t) { perror("TemperCreate"); exit(-1); } /* TemperSendCommand(t, 10, 11, 12, 13, 0, 0, 2, 0); TemperSendCommand(t, 0x43, 0, 0, 0, 0, 0, 0, 0); TemperSendCommand(t, 0, 0, 0, 0, 0, 0, 0, 0); TemperSendCommand(t, 0, 0, 0, 0, 0, 0, 0, 0); TemperSendCommand(t, 0, 0, 0, 0, 0, 0, 0, 0); TemperSendCommand(t, 0, 0, 0, 0, 0, 0, 0, 0); TemperSendCommand(t, 0, 0, 0, 0, 0, 0, 0, 0); TemperSendCommand(t, 0, 0, 0, 0, 0, 0, 0, 0); */ bzero(buf, 256); ret = TemperGetOtherStuff(t, buf, 256); printf("Other Stuff (%d bytes):\n", ret); for(i = 0; i < ret; i++) { printf(" %02x", buf[i] & 0xFF); if(i % 16 == 15) { printf("\n"); } } printf("\n"); for(; { float tempc; if(TemperGetTemperatureInC(t, &tempc) < 0) { perror("TemperGetTemperatureInC"); exit(1); } printf("temperature %.2fF %.2fC\n", (9.0 / 5.0 * tempc + 32.0), tempc); sleep(600); } return 0; } #endif[/code] Ich hofe ihr könnt mir helfen
  5. Shern

    Anfänger Hilfe

    Wow danke das ist doch schon einmal etwas Ja der Server ist gesichert da mein Ausbilder ihn installiert sowie konfiguriert etc. hat, ich vermute er wusste schon was er da tat/tut. Ja sry für die falsche Auskunft ich soll mit einem Temperatur USB Stick die Temperatur per shell, bash etc. (darf ich mir aussuchen wie) auslesen und sie mit php auf einer html seite anzeigen, mit Verlauf, aktuelle Temperatur (TEMPer heist der Sensor USB-Thermometer UTE-00411) ... Wow stimmt auf sowas bin ich noch gar nicht gekommen, wohl noch in mörgentlicher Müdigkeit gewesen, ich hätte jetzt ein Tut nach dem anderen durchgearbeitet. Wie gesagt es soll nur eine Übung sein mich näher mit Linux vertraut zu machen, was ich auch SEHR gut finde. Danke euch wer noch etwas weis, auch Anleitung etc darf sie mir gerne schicken, per PM oder sie hier eintragen.
  6. Shern

    Anfänger Hilfe

    Hey @ all, vielleicht könnt ihr mit helfen, und zwar folgendes: Ich habe zurzeit Betrieblich ein projekt laufen bei dem wir mit Linux arbeiten genauer Ubuntu 10.4. Nun müssen wir da mit PHP am Schluss Daten ausgeben von dem PC aber auch Temperaturen von einem USB Stick (TEMPer). Nun ist meine Bitte ob mir Jemand Starthilfe geben kann, (1 lehrjahr noch) wie ich beginnen könnte und wo bzw. wie ich es am schnellsten Lerne mit Linux einigermaßen umzugehen, da dieses Projekt mich besonders reizt und ich glaube das Linux etwas tolles sein kann . Ein paar Daten: OS: Ubuntu 10.4, Root Server im Betrieb, Zugang zu außen ist gut gesichert MFG Sherm

Fachinformatiker.de, 2024 by SE Internet Services

fidelogo_small.png

Schicke uns eine Nachricht!

Fachinformatiker.de ist die größte IT-Community
rund um Ausbildung, Job, Weiterbildung für IT-Fachkräfte.

Fachinformatiker.de App

Download on the App Store
Get it on Google Play

Kontakt

Hier werben?
Oder sende eine E-Mail an

Social media u. feeds

Jobboard für Fachinformatiker und IT-Fachkräfte

×
×
  • Neu erstellen...