6.1.2 Verwendung des Webcompilers
|
|
#include "stdio.h"
#include "stdlib.h"
#include "unistd.h"
#include "sys/ioctl.h"
#include "fcntl.h"
#include "asm/etraxgpio.h"
int main(void) {
int fd;
int i;
int iomask;
if ((fd = open("/dev/gpiog", O_RDWR))<0) {
printf("Open error on /dev/gpiog\n");
exit(0);
}
iomask=1<<25;
for (i=0;i<10;i++) {
printf("Led ON\n");
ioctl(fd,_IO(ETRAXGPIO_IOCTYPE,IO_SETBITS),iomask);
sleep(1);
printf("Led OFF\n");
ioctl(fd,_IO(ETRAXGPIO_IOCTYPE,IO_CLRBITS),iomask);
sleep(1);
}
close(fd);
exit(0);
}
Code 6.1.2-1: foxio.c LED an Port G auf Bit 25 zehnmal blinken lassen.
|
gcc-cris -isystem /var/www/webcomp/devboard-R2_01/target/cris-axis-linux-gnu/include ... ... -mlinux -mno-mul-bug-workaround -Wall -Wshadow -O2 -g -c -o foxio.o foxio.c gcc-cris -isystem /var/www/webcomp/devboard-R2_01/target/cris-axis-linux-gnu/include ... ... -mlinux -mno-mul-bug-workaround -L/var/www/webcomp/devboard-R2_01/target/cris-axis-linux-gnu/lib ... ... -Wl,-rpath-link,/var/www/webcomp/devboard-R2_01/target/cris-axis-linux-gnu/lib foxio.o -o foxio.out cris-strip foxio.out
Code 6.1.2-2: Compilebefehle
Ausführbare Datei gezipt
Starten des Programms
|
Bild 6.1.2-1: Übertragung des ausführbaren Files mit FileZilla auf das Foxboard (einfach mit der Maus rüberziehen).
Bild 6.1.2-2: File ausführbar machen und starten von Putty aus - LED blinkt dann.
|
#!/bin/sh echo "Content-type: text/html\n" echo "<html>" echo "<body>" echo "<h1>LED blinkt</h1>" echo "</body>" echo "</html>" /mnt/flash/foxio.out
Code 6.1.2-3: CGI-Programm, um foxio.out über das Internet starten zu können.
Bild 6.1.2-3: Ansicht in einem Internetbrowser.