Problem beim Schreiben auf die COM ttyS1
-
Hallo
habe ein Problem beim Schreiben auf die COM wenn ich lese gehts(read(port,buffer,1)
aber beim schreiben gehts nicht write(port,"Hallo",5))Hier mal der Quelltext:
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <termios.h>
#include <iostream.h>
#define BAUDRATE B4800
#define DEVICE "/dev/ttyS1"int main()
{
int port,laenge;struct termios oldio,newio;
char buffer[1];
port=open(DEVICE,O_RDWR);if(port<0)
{cout <<"COM PORT OPEN FALSE";
return(0);
}
else
{
cout <<"PORT OPEN";
}
tcgetattr(port,&oldio);
newio.c_cflag=BAUDRATE | CS8 | CRTSCTS | CLOCAL | CREAD;
newio.c_iflag=0;
newio.c_oflag=OPOST | ONLCR;
newio.c_lflag=0;
tcflush(port,TCIFLUSH);
tcsetattr(port,TCSANOW,&newio);while(1)
{
if(write(port,"HALLO",5)<0)
{
cout<<"Schreiben fehlgeschlagen!";}
}
tcsetattr(port,TCSANOW,&oldio);
close(port);
}