serialRedonV2.c 539 Bytes
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <termios.h>

#include "serial.c"

////
// Constants
////
#define         SERIAL_DEVICE           "/dev/ttyAMA0"

////
// Global variables
////

////
// Main function
////

int main(void){
int c=0;
int sd=serialOpen(SERIAL_DEVICE,SERIAL_BOTH);
serialConfig(sd,B9600);
if(write(sd,&c,sizeof(char))!=1){ perror("main.write"); exit(-1); }
int i;
while(1){
  if(read(sd,&c,sizeof(char))!=1){ perror("main.read"); exit(-1); }
  printf("%d\n",c);
  }
serialClose(sd);
exit(0);
}