von cas » Sa 27. Dez 2008, 00:14
mega-hz hat geschrieben:@cas:
könnte ich diese Routine schon zum setzen einzelner Bits am LPT nehmen?
----------------
/*
* example.c: very simple example of port I/O
*
* This code does nothing useful, just a port write, a pause,
* and a port read. Compile with `gcc -O2 -o example example.c',
* and run as root with `./example'.
*/
#include <stdio>
#include <unistd>
#include <asm>
#define BASEPORT 0x378 /* lp1 */
int main()
{
/* Get access to the ports */
if (ioperm(BASEPORT, 3, 1)) {perror("ioperm"); exit(1);}
/* Set the data signals (D0-7) of the port to all low (0) */
outb(0, BASEPORT);
/* Sleep for a while (100 ms) */
usleep(100000);
/* Read from the status port (BASE+1) and display the result */
printf("status: %d\n", inb(BASEPORT + 1));
/* We don't need the ports anymore */
if (ioperm(BASEPORT, 3, 0)) {perror("ioperm"); exit(1);}
exit(0);
}
/* end of example.c */
------------------------------------
Woher bekomme ich die oben aufgeführten include dateien?
Und wie gehe ich am besten vor, unter ner (putty)konsole auf meinem Server?
Mit nem Texteditor diese Datei erstellen, z.B. in /home speichern und dann?
Gruß,
Wolfram.
Die routine sollte als Grundlage reichen, aber ich kann Dir nicht Linux C-Programmierung im Dialog über das Forum beibringen (das wäre für uns beide frustrierend da zu langsam).
Ich sehe 2 Möglichkeiten:
a) Du arbeitest Dich durch die FAQs (
http://www.faqs.org/faqs) oder ein gutes Buch (z. B.
http://www.wrox.com/WileyCDA/WroxTitle/ ... ption.html , das freie PDF aus dem Buch sollte Deine Fragen von oben beantworten)
b) Du öffnest SSH (Port 22) zu Deinem Entwicklungs-Rechner, installierst "screen", und wir schauen uns die Aufgabe zusammen auf dem Server an (d.h. ändern das Programm, compilieren es und testen es aus)
Aus Sicherheitsgründen möchte man nicht den C-Compiler und alle Programme zum übersetzen (die GCC Toolchain) auf einem Server haben (das ist eine Einladung für Cracker), sondern man compiliert und testet auf einem Entwicklungssystem, und wenn das Programm läuft, dann kopiert man das fertige Programm auf den Server.
Ciao
Carsten