#include <stdio.h>   /* Standard input/output definitions */
#include <string.h>  /* String function definitions */
#include <unistd.h>  /* UNIX standard function definitions */
#include <fcntl.h>   /* File control definitions */
#include <errno.h>   /* Error number definitions */
#include <termios.h> /* POSIX terminal control definitions */


int main (int argc, char *argv[]){

        int fd;
        int n;
        int laenge;
        char *cmd;
        struct termios options;

        /* open the port */
        fd = open("/dev/ttyS1", O_RDWR | O_NOCTTY | O_NDELAY);
        fcntl(fd, F_SETFL, 0);

        /* get the current options */
        tcgetattr(fd, &options);

        options.c_cflag &= ~PARENB;
        options.c_cflag &= ~CSTOPB;
        options.c_cflag &= ~CSIZE;
        options.c_cflag |= CS8;
        cfsetispeed(&options, B9600);
        cfsetospeed(&options, B9600);

        /* set the options */
        tcsetattr(fd, TCSANOW, &options);

        cmd = argv[1];
        strcat( cmd , "\n");
        laenge = strlen(cmd);

        n = write(fd, cmd, laenge);

        close (fd);

        return n;
}