Skip to content

Commit

Permalink
j1939-vehicle-position-srv: Introduce J1939 and NMEA 2000 Vehicle Pos…
Browse files Browse the repository at this point in the history
…ition Server

This patch adds `j1939-vehicle-position-srv`, a server for sending
vehicle position data over CAN using J1939 or NMEA 2000 protocols. It
retrieves GPS data from gpsd or simulates data if gpsd is unavailable.
By default, it operates in J1939 profile but can switch to NMEA 2000
with the `-p nmea2000` option.

Usage Examples:
1. With gpsd:
   j1939acd -r 64-95 -c /tmp/1122334455667789.jacd 1122334455667789 vcan0 &
   j1939-vehicle-position-srv -i vcan0 -n 0x1122334455667789

2. In simulation mode without gpsd:
   j1939-vehicle-position-srv -i vcan0 -s -p nmea2000

Signed-off-by: Oleksij Rempel <[email protected]>
  • Loading branch information
olerem committed Dec 29, 2024
1 parent 93e7b02 commit 2638b39
Show file tree
Hide file tree
Showing 4 changed files with 2,942 additions and 1 deletion.
20 changes: 20 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ set(PROGRAMS_J1939_TIMEDATE
j1939-timedate-cli
)

set(PROGRAMS_J1939_VEHICLE_POSITION
j1939-vehicle-position-srv
)

set(PROGRAMS_ISOBUSFS
isobusfs-srv
isobusfs-cli
Expand Down Expand Up @@ -190,6 +194,22 @@ if(NOT ANDROID)
j1939-timedate-srv
DESTINATION ${CMAKE_INSTALL_BINDIR})

set(PUBLIC_HEADER_J1939_VEHICLE_POSITION
j1939_vehicle_position/j1939_vehicle_position_cmn.h
)

add_executable(j1939-vehicle-position-srv
j1939_vehicle_position/j1939_vehicle_position_srv.c
)

target_link_libraries(j1939-vehicle-position-srv
PRIVATE can j1939 gps
)

install(TARGETS
j1939-vehicle-position-srv
DESTINATION ${CMAKE_INSTALL_BINDIR})

endif()

add_library(can STATIC
Expand Down
15 changes: 14 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ PROGRAMS_J1939_TIMEDATE := \
j1939-timedate-srv \
j1939-timedate-cli

PROGRAMS_J1939_VEHICLE_POSITION := \
j1939-vehicle-position-srv

PROGRAMS_ISOBUSFS := \
isobusfs-srv \
isobusfs-cli
Expand Down Expand Up @@ -98,6 +101,7 @@ PROGRAMS_SLCAN := \
PROGRAMS := \
$(PROGRAMS_CANGW) \
$(PROGRAMS_J1939_TIMEDATE) \
$(PROGRAMS_J1939_VEHICLE_POSITION) \
$(PROGRAMS_ISOBUSFS) \
$(PROGRAMS_ISOTP) \
$(PROGRAMS_J1939) \
Expand Down Expand Up @@ -126,7 +130,8 @@ endif
all: $(PROGRAMS)

clean:
rm -f $(PROGRAMS) *.o mcp251xfd/*.o isobusfs/*.o j1939_timedate/*.o
rm -f $(PROGRAMS) *.o mcp251xfd/*.o isobusfs/*.o j1939_timedate/*.o \
j1939_vehicle_position/*.o

install:
mkdir -p $(DESTDIR)$(PREFIX)/bin
Expand All @@ -153,6 +158,8 @@ isobusfs_srv.o: lib.h libj1939.h
isobusfs_c.o: lib.h libj1939.h
j1939_timedate_srv.o: lib.h libj1939.h
j1939_timedate_cli.o: lib.h libj1939.h
j1939_vehicle_position_srv.o: lib.h libj1939.h

canframelen.o: canframelen.h

asc2log: asc2log.o lib.o
Expand Down Expand Up @@ -182,6 +189,12 @@ j1939-timedate-cli: lib.o \
j1939_timedate/j1939_timedate_cli.o
$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@

j1939-vehicle-position-srv: \
lib.o \
libj1939.o \
j1939_vehicle_position/j1939_vehicle_position_srv.o \
$(CC) $(LDFLAGS) $^ $(LDLIBS) -lgps -o $@

isobusfs-srv: lib.o \
libj1939.o \
isobusfs/isobusfs_cmn.o \
Expand Down
Loading

0 comments on commit 2638b39

Please sign in to comment.