Project

General

Profile

Statistics
| Revision:

root / branches / encoders / code / behaviors / spline / server / server.c @ 1197

History | View | Annotate | Download (663 Bytes)

1
#include <termios.h>
2
#include <stdio.h>
3
#include <stdlib.h>
4
#include <sys/types.h>
5
#include <sys/stat.h>
6
#include <fcntl.h>
7

    
8
int main()
9
{
10
        int serialFile = open("/dev/ttyUSB0", O_RDONLY);
11
        if(serialFile < 1)
12
        {
13
                printf("Error opening serial\n");
14
                return -1;
15
        }
16
    struct termios attributes;
17
    tcgetattr(serialFile, &attributes);
18

    
19
        cfsetispeed(&attributes, 115200);
20
        cfsetospeed(&attributes, 115200);
21
        tcsetattr(serialFile, TCSANOW, &attributes);
22
                    
23
        int encoders[2];
24
        while(1)
25
        {
26
                read(serialFile, encoders, sizeof(encoders));
27
                printf("%d %d\n", encoders[0], encoders[1]);
28
        }
29

    
30
}
31