slcanpty: remove redundant asc2nibble()

asc2nibble() is already defined in lib.h. Include lib.h in slcnpty.c
so that asc2nibble() does not need to be redefined a second time and
adjust the Makefile accordingly.

Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Link: https://lore.kernel.org/all/20221114163848.3398-2-mailhol.vincent@wanadoo.fr
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
pull/387/head
Vincent Mailhol 2022-11-15 01:38:43 +09:00 committed by Marc Kleine-Budde
parent 71a0156bd5
commit 4c9f046615
3 changed files with 5 additions and 16 deletions

View File

@ -33,6 +33,7 @@ set(PROGRAMS_CANLIB
cansequence
log2asc
log2long
slcanpty
)
set(PROGRAMS_J1939
@ -58,7 +59,6 @@ set(PROGRAMS
isotptun
slcan_attach
slcand
slcanpty
)
add_executable(can-calc-bit-timing

View File

@ -119,6 +119,7 @@ canplayer.o: lib.h
cansend.o: lib.h
log2asc.o: lib.h
log2long.o: lib.h
slcanpty.o: lib.h
j1939acd.o: libj1939.h
j1939cat.o: libj1939.h
j1939spy.o: libj1939.h
@ -135,6 +136,7 @@ cansend: cansend.o lib.o
cansequence: cansequence.o lib.o
log2asc: log2asc.o lib.o
log2long: log2long.o lib.o
slcanpty: slcanpty.o lib.o
j1939acd: j1939acd.o libj1939.o
j1939cat: j1939cat.o libj1939.o
j1939spy: j1939spy.o libj1939.o

View File

@ -43,27 +43,14 @@
#include <linux/can/raw.h>
#include <linux/sockios.h>
#include "lib.h"
/* maximum rx buffer len: extended CAN frame with timestamp */
#define SLC_MTU (sizeof("T1111222281122334455667788EA5F\r")+1)
#define DEVICE_NAME_PTMX "/dev/ptmx"
#define DEBUG
static int asc2nibble(char c)
{
if ((c >= '0') && (c <= '9'))
return c - '0';
if ((c >= 'A') && (c <= 'F'))
return c - 'A' + 10;
if ((c >= 'a') && (c <= 'f'))
return c - 'a' + 10;
return 16; /* error */
}
/* read data from pty, send CAN frames to CAN socket and answer commands */
int pty2can(int pty, int socket, struct can_filter *fi,
int *is_open, int *tstamp)