test.c~ 610 Bytes
/*
 * Test on serial device
 */

////
// Include files
////
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <termios.h>

#include "serial.h"

////
// Constants
////
#define         SERIAL_DEVICE           "/dev/ttyACM0"

////
// 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;
for(i=0;i<8;i++){
  if(read(sd,&c,sizeof(char))!=1){ perror("main.read"); exit(-1); }
  printf("%02x\n",c);
  }
serialClose(sd);
exit(0);
}