speed_t speed_num[] = { B300, B1200, B2400, B4800, B9600, B19200, B38400,
B57600, B115200, B230400, B0 };
speed_t speed_num[] = { B300, B1200, B2400, B4800, B9600, B19200, B38400,
B57600, B115200, B230400, B0 };
- if (tcflush(filedes, TCIFLUSH)) {
- fprintf(stderr,"%s: ",device);
- perror("tcflush");
- exit(1);
- }
- if (tcsetattr(filedes, TCSANOW, &serparams)) {
- fprintf(stderr,"%s: ",device);
- perror("tcsetattr");
- exit(1);
+ if (tcflush(filedes, TCIFLUSH)) {
+ fprintf(stderr,"%s: ",device);
+ perror("tcflush");
+ exit(1);
+ }
+ if (tcsetattr(filedes, TCSANOW, &serparams)) {
+ fprintf(stderr,"%s: ",device);
+ perror("tcsetattr");
+ exit(1);
+ }
this returns the string for the character passed to it
It could be expanded in the future to maybe to string recognitions?
*/
this returns the string for the character passed to it
It could be expanded in the future to maybe to string recognitions?
*/
snprintf(result,256,"%c",c);
}
} else {
snprintf(result,256,"%c",c);
}
} else {
- snprintf(result,256,"0x%02hX ",c);
+ snprintf(result,256,format,c);
}
return result;
}
void outputchar(unsigned char c, int port, int alpha,
}
return result;
}
void outputchar(unsigned char c, int port, int alpha,
- long usec_threshold, long usec_waited)
+ long usec_threshold, long usec_waited, char *name1, char *name2, char *format)
- todisplay=chardecide(c,alpha);
- disp_outputstr(port, todisplay, usec_threshold, usec_waited);
+ todisplay=chardecide(c,alpha,format);
+ disp_outputstr(port, todisplay, usec_threshold, usec_waited, name1, name2);
-void mainloop(int port1, int port2, int silent, int alpha, long usec_threshold)
+void mainloop(int port1, int port2, int silent, int alpha, long usec_threshold, char *name1, char *name2, char *format)
if (FD_ISSET(port1, &rfds)) {
for (rc=read(port1, &c1, 1);
rc>0; rc=read(port1, &c1, 1) ) {
if (FD_ISSET(port1, &rfds)) {
for (rc=read(port1, &c1, 1);
rc>0; rc=read(port1, &c1, 1) ) {
- outputchar(c1,1,alpha,usec_threshold,timediff);
+ outputchar(c1,1,alpha,usec_threshold,timediff,name1,name2,format);
if (FD_ISSET(port2, &rfds)) {
for (rc=read(port2, &c2, 1);
rc>0; rc=read(port2, &c2, 1) ) {
if (FD_ISSET(port2, &rfds)) {
for (rc=read(port2, &c2, 1);
rc>0; rc=read(port2, &c2, 1) ) {
- outputchar(c2,2,alpha,usec_threshold,timediff);
+ outputchar(c2,2,alpha,usec_threshold,timediff,name1,name2,format);
sersniff [-h] [-i DEV | -l PORT] [-o DEV | -c HOST:PORT] [-b BAUD] [-w USEC]
-h This help
-x Show hex characters instead of alpha
sersniff [-h] [-i DEV | -l PORT] [-o DEV | -c HOST:PORT] [-b BAUD] [-w USEC]
-h This help
-x Show hex characters instead of alpha
--i DEVICE Port 1 device (defaults to /dev/ttyS0)
--l PORT Port 1 port for TCP
--o DEVICE Port 2 device (defaults to /dev/ttyS1)
--c HOST:PORT Port 2 host & port to connect to
+-f PRINTF_OPTS printf style options for printing hex characters
+ when '-x' switch is given (default \"<%%02hX>\")
+-i DEVICE Port 1 device (defaults to /dev/ttyS0). Use host:port for
+ TCP.
+-1 PORT1_NAME Port 1 name to be printed (defaults to 'Port1')
+-o DEVICE Port 2 device (defaults to /dev/ttyS1). Use :port for TCP.
+-2 PORT2_NAME Port 2 name to be printed (defaults to 'Port2')
-w USECS How many microsecs to wait before reporting a delay
(default is %d)
-s Silent - don't pass data from port1 <=> port2,
-w USECS How many microsecs to wait before reporting a delay
(default is %d)
-s Silent - don't pass data from port1 <=> port2,
- dev2=strdup(optarg);
- break;
- case 'l':
- listenport=atoi(optarg);
- break;
- case 'c':
- if ((tmpchr=strchr(optarg, ':'))==NULL) {
- printf("Must specify -c option with host:port\n");
- exit(1);
+ if ((tmpchr=strchr(optarg, ':'))!=NULL &&
+ (strchr(optarg, '/')==NULL)) {
+ *tmpchr='\0';
+ connectport=atoi(++tmpchr);
+ connecthost=strdup(optarg);
+ } else {
+ dev2=strdup(optarg);
} else {
disp_outputstatus("Connecting to TCP port.");
port2=opensock(connecthost, connectport);
} else {
disp_outputstatus("Connecting to TCP port.");
port2=opensock(connecthost, connectport);
- mainloop(port1, port2, silent, show_alpha, usec_threshold);
+ mainloop(port1, port2, silent, show_alpha, usec_threshold, name1, name2, format);