1f48dd44
mdelapor
mise en ligne du ...
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#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);
}
|