Revision 1237
Server code updated to handle velocity, untested
server.c | ||
---|---|---|
4 | 4 |
#include <sys/types.h> |
5 | 5 |
#include <sys/stat.h> |
6 | 6 |
#include <fcntl.h> |
7 |
#include "encoders.h" |
|
7 | 8 |
|
8 | 9 |
#define LS 0 |
9 | 10 |
#define LD 1 |
... | ... | |
12 | 13 |
#define FORWARD 1 |
13 | 14 |
#define BACKWARD 0 |
14 | 15 |
#define SENDER 1 |
15 |
#define RECEIVER 0 |
|
16 |
#define RECEIVER 0
|
|
16 | 17 |
|
18 |
int left_dx = 0; |
|
19 |
int right_dx = 0; |
|
20 |
|
|
17 | 21 |
void setAttrib(int file) |
18 | 22 |
{ |
19 | 23 |
struct termios attributes; |
... | ... | |
26 | 30 |
attributes.c_cflag &= ~CSIZE; |
27 | 31 |
attributes.c_cflag |= CS8; |
28 | 32 |
|
29 |
// attributes.c_cflag &= ~ICRNL; |
|
30 |
// attributes.c_cflag &= ~OCRNL; |
|
31 |
// attributes.c_cflag |= (CLOCAL | CREAD); |
|
32 |
// attributes.c_lflag &= ~ICANON; |
|
33 |
// attributes.c_cc[VMIN] = 1; |
|
34 |
// attributes.c_cc[VTIME] = 50; |
|
33 |
attributes.c_cflag &= ~ICRNL; |
|
34 |
attributes.c_cflag &= ~OCRNL; |
|
35 |
attributes.c_cflag |= (CLOCAL | CREAD); |
|
36 |
attributes.c_lflag &= ~ICANON; |
|
35 | 37 |
|
36 | 38 |
|
37 | 39 |
if (tcsetattr(file, TCSANOW, &attributes) < 0){ |
... | ... | |
64 | 66 |
|
65 | 67 |
//Sending velocity as LS LD RS RD |
66 | 68 |
int tempCount = 0; |
69 |
|
|
70 |
int dx, left_v; |
|
67 | 71 |
|
68 | 72 |
while(1) |
69 | 73 |
{ |
... | ... | |
94 | 98 |
|
95 | 99 |
int leftEncoder = (encoders[0] << 8) | encoders[1]; |
96 | 100 |
int rightEncoder = (encoders[2] << 8) | encoders[3]; |
97 |
printf("%d %d\n", leftEncoder, rightEncoder); |
|
98 |
|
|
101 |
// printf("%d %d\n", leftEncoder, rightEncoder); |
|
102 |
|
|
103 |
encoder_recv(leftEncoder, rightEncoder); |
|
104 |
printf("LEFT V: %d \t RIGHT V: %d\n", encoder_get_v(LEFT), encoder_get_v(RIGHT)); |
|
105 |
|
|
106 |
|
|
107 |
|
|
108 |
|
|
99 | 109 |
} |
100 | 110 |
|
101 | 111 |
} |
Also available in: Unified diff