PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : LCD ansteuern unter Linux



flexkeller
22.12.08, 20:56
Hallo Zusammen,

ich hab mir da grosse Ziele gesteckt und steh schon am Anfang auf dem Schlauch :-)

Das Projekt besteht am Schluss aus einem Zusammenspiel von RFID-Leser/Schreibe, LCD Display und einer Relais Karte zum Steuern von pneumatischen Ventilen.


Ich hab mal (ua. weill ich das Teil als erstes gekriegt habe) mit dem LCD Display begonnen. Es handelt sich dabei um ein ULA200 (http://www.elv.de/USB-LCD-Ansteuerung-ULA-200,-Komplettbausatz-ohne-Kabelset-und-LCD-Anzeige/x.aspx/cid_74/detail_10/detail2_9479) von ELV.
Ich krieg auch hin, dass die Beispiel Programme von: http://www.bralug.de/wiki/LCD-Display_als_Statusanzeige_unter_Linux funktionieren (http://www.bralug.de/wiki/LCD-Display_als_Statusanzeige_unter_Linux). Aber leider sind meine C-Kenntnisse doch schlecht als angenommen und ich blicke da einfach nicht recht durch wie ich in einem eigenen C-Programm Daten an's LCD schicken kann.

Kennt sich einer mit LCD's unter Linux am USB aus? und kann mir einpaar leicht verständliche Beispiele zur Verfügung stellen?

zyrusthc
23.12.08, 00:45
Schon ausprobiert?
http://ssl.bulix.org/projects/lcd4linux/
http://lcdproc.omnipotent.net
http://lcd-linux.sourceforge.net


Greeez Oli

sbrandner
30.12.08, 18:33
Wo genau liegt den dein Problem. Ich habe den Beispielcode auch verwendet und er hat gut funktioniert.

Anbei ein Beispielcode:



#include <fcntl.h>
#include <unistd.h>
#include <termios.h>
#include <stdio.h>

int data;
int fd;
int key(0);
char a=1;
unsigned char rec;
unsigned char r,s;
struct termios tio,backup;
int mysleep = 1000;


# define TERM_DEVICE "/dev/ttyUSB0" /* = COM1 */
// define the Baudrate
#define BAUDRATE B19200

int main(int argc, char** arg)
{
//First we open the usbdevice (trying to find the chip

if ( ( fd = open( "/dev/ttyUSB0", O_RDWR| O_NOCTTY| O_NDELAY )) < 0 ) {
fprintf(stderr,"Can't open dev/ttyUSB0\n");
if ( ( fd = open( "/dev/ttyUSB1", O_RDWR| O_NOCTTY| O_NDELAY )) < 0 ) {
fprintf(stderr,"Can't open dev/ttyUSB1 either\n");
return(-1);
}
}
if ( tcgetattr( fd, &tio ) == -1 )
{
fprintf(stderr,"Can't properly open dev/ttyUSB0\n");
};
backup=tio;
// Setting baudrate
if(cfsetispeed(&tio, BAUDRATE) == -1) {
printf("serial_open(): unable to set input-baudrate\n");
return (-1);
}
if(cfsetospeed(&tio, BAUDRATE) == -1) {
printf("serial_open(): unable to set output-baudrate\n");
return (-1);
}

// Setting the rawmode
// c_lflags -> local modes
// c_iflags -> input modes
// c_oflags -> output modes
// c_cc -> control chars
tio.c_lflag = 0;
tio.c_iflag = 0;
tio.c_cflag = BAUDRATE | CS8 | PARENB;
tio.c_oflag = 0;

if (tio.c_lflag & (ECHO|ICANON|ISIG|IEXTEN))
printf("serial_open(): unable to set terminalmode -lflag ");
if ( tio.c_iflag & (ICRNL|BRKINT|IXON|ISTRIP|INPCK))
printf("serial_open(): unable to set terminalmode -iflag \n");


// now clean the line ...
if(tcflush(fd, TCIOFLUSH) == -1) {
printf("serial_open(): unable to flush data\n");
return (-1);
}
// now clean the line ...
if(tcflow(fd, TCIOFLUSH) == -1) {
printf("serial_open(): unable to flush data\n");
return (-1);
}

// ... and activate the settings for the port
if(tcsetattr(fd, TCSANOW, &tio) == -1) {
printf("serial_open(): unable to set new attributes\n");
return (-1);
}
printf("Sucessfully opened device for read and write\n");

data=0;
rec=0;


int ret=0;

#define SET(x) \
a=(char)x; ret = write(fd,&a,1); usleep(mysleep);

#define REC(x) \
for(int i=0;i<x;++i) \
{ rec=0x00; ret = read(fd,&rec,1); usleep(mysleep);if(i==1)key=rec; }

SET(0x02) // STX
SET(0x6C) // CLR
SET(0x03) // ETX

REC(3)

SET(0x02) // STX
SET(0x70) // POS
SET(0x00) // POS X
SET(0x00) // POS Y
SET(0x03) // ETX

REC(3)

SET(0x02) // STX
SET(0x73) // STR
SET(0x05) // ENQ
SET(0x15) // NAK
SET('R')
SET('e')
SET('a')
SET('d')
SET('y')
SET(0x03) // ETX

//while (read(fd,&rec,1)==-1);

REC(3)

printf("\n");
while (true)
{
REC(3);
if (ret) {
printf("\n received!");
printf(" Received %x \n",key);
}
}

if(tcsetattr(fd, TCSANOW, &backup) == -1) {
printf("serial_open(): unable to restore old attributes\n");
return (-1);
}

return 0;
}

E S
20.01.09, 12:41
Hi,

da gibt es viele Möglichkeiten. Irgendwo hatte ich mal ein kleines Programm gefunden, dass das Display in eine Konsole verwandelt. Damit kannn JEDES programm Daten ausgeben wenn man die Ausgabe auf dieses terminal umleitet.

Bei RS232 Anbindung (oder über Umweg mit USB) kann man sich auch eine Termcap schreiben und in der init.d dieses als terminal anmelden. Mit rootrechten kann man da Ausgaben auf die "fremde" Konsole umleiten und die Termcap übersetzt die Steuerbefehle für das Display.
Ich benutze das im Zusammenhang mit meinem VT510 Terminal an der RS232. Das verfügt über eine "Host writable status line" die über eine zweite Datenleitung gesteuert wird. Die hängt an einer weiteren RS232 und ich "würge" da Statusinformationen des Servers als Laufschrift drauf.

Gruß
Elmar