Fix serialdump code style
This commit is contained in:
parent
a8f392ffa7
commit
5c65a07c56
|
@ -1,4 +1,5 @@
|
|||
#define _GNU_SOURCE
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <termios.h>
|
||||
|
@ -9,15 +10,16 @@
|
|||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <signal.h>
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define BAUDRATE B115200
|
||||
#define BAUDRATE_S "115200"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifdef linux
|
||||
#define MODEMDEVICE "/dev/ttyS0"
|
||||
#else
|
||||
#define MODEMDEVICE "/dev/com1"
|
||||
#endif /* linux */
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define SLIP_END 0300
|
||||
#define SLIP_ESC 0333
|
||||
#define SLIP_ESC_END 0334
|
||||
|
@ -38,9 +40,11 @@
|
|||
#define MODE_SLIP_AUTO 6
|
||||
#define MODE_SLIP 7
|
||||
#define MODE_SLIP_HIDE 8
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
static unsigned char rxbuf[2048];
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
usage(int result)
|
||||
{
|
||||
|
@ -54,7 +58,7 @@ usage(int result)
|
|||
printf(" (see man page for strftime() for format description)\n");
|
||||
return result;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
print_hex_line(char *prefix, unsigned char *outbuf, int index)
|
||||
{
|
||||
|
@ -82,13 +86,13 @@ print_hex_line(char *prefix, unsigned char *outbuf, int index)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
intHandler(int sig)
|
||||
{
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
|
@ -174,8 +178,6 @@ main(int argc, char **argv)
|
|||
}
|
||||
fprintf(stderr, "connecting to %s (%s)", device, speedname);
|
||||
|
||||
|
||||
|
||||
#ifndef O_SYNC
|
||||
#define O_SYNC 0
|
||||
#endif
|
||||
|
@ -184,7 +186,7 @@ main(int argc, char **argv)
|
|||
/* Some systems do not support certain parameters (e.g. raspbian)
|
||||
* Just do some random testing. Not sure whether there is a better way
|
||||
* of doing this. */
|
||||
if(fd < 0 && errno == EINVAL){
|
||||
if(fd < 0 && errno == EINVAL) {
|
||||
fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY | O_SYNC);
|
||||
}
|
||||
#else
|
||||
|
@ -241,7 +243,7 @@ main(int argc, char **argv)
|
|||
index = 0;
|
||||
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) {
|
||||
fprintf(stderr, "interrupted system call\n");
|
||||
|
|
Loading…
Reference in New Issue