mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-12-22 10:30:13 +00:00
Fix indentation
This commit is contained in:
parent
2059be3a43
commit
016bcdb8a8
@ -80,7 +80,8 @@ print_hex_line(unsigned char *prefix, unsigned char *outbuf, int index)
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
struct termios options;
|
||||
fd_set mask, smask;
|
||||
@ -95,21 +96,21 @@ int main(int argc, char **argv)
|
||||
unsigned char lastc = '\0';
|
||||
|
||||
int index = 1;
|
||||
while (index < argc) {
|
||||
if (argv[index][0] == '-') {
|
||||
while(index < argc) {
|
||||
if(argv[index][0] == '-') {
|
||||
switch(argv[index][1]) {
|
||||
case 'b':
|
||||
/* set speed */
|
||||
if (strcmp(&argv[index][2], "38400") == 0) {
|
||||
if(strcmp(&argv[index][2], "38400") == 0) {
|
||||
speed = B38400;
|
||||
speedname = "38400";
|
||||
} else if (strcmp(&argv[index][2], "19200") == 0) {
|
||||
} else if(strcmp(&argv[index][2], "19200") == 0) {
|
||||
speed = B19200;
|
||||
speedname = "19200";
|
||||
} else if (strcmp(&argv[index][2], "57600") == 0) {
|
||||
} else if(strcmp(&argv[index][2], "57600") == 0) {
|
||||
speed = B57600;
|
||||
speedname = "57600";
|
||||
} else if (strcmp(&argv[index][2], "115200") == 0) {
|
||||
} else if(strcmp(&argv[index][2], "115200") == 0) {
|
||||
speed = B115200;
|
||||
speedname = "115200";
|
||||
} else {
|
||||
@ -153,7 +154,7 @@ int main(int argc, char **argv)
|
||||
index++;
|
||||
} else {
|
||||
device = argv[index++];
|
||||
if (index < argc) {
|
||||
if(index < argc) {
|
||||
fprintf(stderr, "too many arguments\n");
|
||||
return usage(1);
|
||||
}
|
||||
@ -162,33 +163,33 @@ int main(int argc, char **argv)
|
||||
fprintf(stderr, "connecting to %s (%s)", device, speedname);
|
||||
|
||||
#ifndef __APPLE__
|
||||
fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY | O_DIRECT | O_SYNC );
|
||||
fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY | O_DIRECT | O_SYNC);
|
||||
#else
|
||||
fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY | O_SYNC );
|
||||
#endif
|
||||
if (fd <0) {
|
||||
if(fd < 0) {
|
||||
fprintf(stderr, "\n");
|
||||
perror(device);
|
||||
exit(-1);
|
||||
}
|
||||
fprintf(stderr, " [OK]\n");
|
||||
|
||||
if (fcntl(fd, F_SETFL, 0) < 0) {
|
||||
if(fcntl(fd, F_SETFL, 0) < 0) {
|
||||
perror("could not set fcntl");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (tcgetattr(fd, &options) < 0) {
|
||||
if(tcgetattr(fd, &options) < 0) {
|
||||
perror("could not get options");
|
||||
exit(-1);
|
||||
}
|
||||
/* fprintf(stderr, "serial options set\n"); */
|
||||
/* fprintf(stderr, "serial options set\n"); */
|
||||
cfsetispeed(&options, speed);
|
||||
cfsetospeed(&options, speed);
|
||||
/* Enable the receiver and set local mode */
|
||||
options.c_cflag |= (CLOCAL | CREAD);
|
||||
/* Mask the character size bits and turn off (odd) parity */
|
||||
options.c_cflag &= ~(CSIZE|PARENB|PARODD);
|
||||
options.c_cflag &= ~(CSIZE | PARENB | PARODD);
|
||||
/* Select 8 data bits */
|
||||
options.c_cflag |= CS8;
|
||||
|
||||
@ -197,28 +198,27 @@ int main(int argc, char **argv)
|
||||
/* Raw output */
|
||||
options.c_oflag &= ~OPOST;
|
||||
|
||||
if (tcsetattr(fd, TCSANOW, &options) < 0) {
|
||||
if(tcsetattr(fd, TCSANOW, &options) < 0) {
|
||||
perror("could not set options");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
/* Make read() return immediately */
|
||||
/* if (fcntl(fd, F_SETFL, FNDELAY) < 0) { */
|
||||
/* perror("\ncould not set fcntl"); */
|
||||
/* exit(-1); */
|
||||
/* } */
|
||||
/* if (fcntl(fd, F_SETFL, FNDELAY) < 0) { */
|
||||
/* perror("\ncould not set fcntl"); */
|
||||
/* exit(-1); */
|
||||
/* } */
|
||||
|
||||
FD_ZERO(&mask);
|
||||
FD_SET(fd, &mask);
|
||||
FD_SET(fileno(stdin), &mask);
|
||||
|
||||
index = 0;
|
||||
for (;;) {
|
||||
for(;;) {
|
||||
smask = mask;
|
||||
nfound = select(FD_SETSIZE, &smask, (fd_set *) 0, (fd_set *) 0,
|
||||
(struct timeval *) 0);
|
||||
nfound = select(FD_SETSIZE, &smask, (fd_set *) 0, (fd_set *) 0, (struct timeval *) 0);
|
||||
if(nfound < 0) {
|
||||
if (errno == EINTR) {
|
||||
if(errno == EINTR) {
|
||||
fprintf(stderr, "interrupted system call\n");
|
||||
continue;
|
||||
}
|
||||
@ -230,21 +230,21 @@ int main(int argc, char **argv)
|
||||
if(FD_ISSET(fileno(stdin), &smask)) {
|
||||
/* data from standard in */
|
||||
int n = read(fileno(stdin), buf, sizeof(buf));
|
||||
if (n < 0) {
|
||||
if(n < 0) {
|
||||
perror("could not read");
|
||||
exit(-1);
|
||||
} else if (n > 0) {
|
||||
} else if(n > 0) {
|
||||
/* because commands might need parameters, lines needs to be
|
||||
separated which means the terminating LF must be sent */
|
||||
/* while(n > 0 && buf[n - 1] < 32) { */
|
||||
/* n--; */
|
||||
/* } */
|
||||
/* while(n > 0 && buf[n - 1] < 32) { */
|
||||
/* n--; */
|
||||
/* } */
|
||||
if(n > 0) {
|
||||
int i;
|
||||
/* fprintf(stderr, "SEND %d bytes\n", n);*/
|
||||
/* write slowly */
|
||||
for (i = 0; i < n; i++) {
|
||||
if (write(fd, &buf[i], 1) <= 0) {
|
||||
for(i = 0; i < n; i++) {
|
||||
if(write(fd, &buf[i], 1) <= 0) {
|
||||
perror("write");
|
||||
exit(1);
|
||||
} else {
|
||||
@ -261,7 +261,7 @@ int main(int argc, char **argv)
|
||||
|
||||
if(FD_ISSET(fd, &smask)) {
|
||||
int i, j, n = read(fd, buf, sizeof(buf));
|
||||
if (n < 0) {
|
||||
if(n < 0) {
|
||||
perror("could not read");
|
||||
exit(-1);
|
||||
}
|
||||
@ -320,8 +320,7 @@ int main(int argc, char **argv)
|
||||
if(index > 0) {
|
||||
if(flags != 2 && mode != MODE_SLIP_HIDE) {
|
||||
/* not overflowed: show packet */
|
||||
print_hex_line("SLIP: ", rxbuf,
|
||||
index > HCOLS ? HCOLS : index);
|
||||
print_hex_line("SLIP: ", rxbuf, index > HCOLS ? HCOLS : index);
|
||||
printf("\n");
|
||||
}
|
||||
lastc = '\0';
|
||||
|
Loading…
Reference in New Issue
Block a user