35
APPENDIX C
Serial Programming Code for RAD
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <termios.h>
#include <stdio.h>
/* baudrate settings are defined in
<asm/termbits.h>, which is
included by <termios.h> */
#define BAUDRATE B38400
/* change this definition for the
correct port */
#define MODEMDEVICE "/dev/ttyS1"
#define _POSIX_SOURCE 1 /* POSIX
compliant source */
#define FALSE 0
#define TRUE 1
volatile int STOP=FALSE;
main()
{
int fd,c, res;
struct termios oldtio,newtio;
char buf[255];
/*
Open modem device for reading and
writing and not as controlling tty
because we don't want to get killed if
linenoise sends CTRL-C.
*/
fd = open(MODEMDEVICE, O_RDWR |
O_NOCTTY );
if (fd <0) {perror(MODEMDEVICE); exit(-
1); }
tcgetattr(fd,&oldtio); /* save current
serial port settings */
Kommentare zu diesen Handbüchern