Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

J1939 vehicle position #553

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

olerem
Copy link
Contributor

@olerem olerem commented Aug 4, 2024

This patch set provide support for the GPSD to J1939 service. I managed to make CmakeList work so far, but i still need help to make Makefile work properly too. How to manage properly gpsd dependecy, currenty i do not know.

Introduce `libj1939_connect_socket` function to handle socket
connections.

Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Introduce `timespec_earliest` to determine the earlier of two given
`timespec` values. This function compares the seconds and nanoseconds
fields of the provided `timespec` structures and returns the earlier
one.

Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
…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 <linux@rempel-privat.de>
@olerem olerem requested review from marckleinebudde and hartkopp and removed request for marckleinebudde August 4, 2024 13:27
@olerem
Copy link
Contributor Author

olerem commented Aug 4, 2024

To make it compile libgps-dev package is required.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have named it timespec_earlier, eh nits.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SocketCAN failed to connect?

uint8_t sid; /* Sequence identifier */
uint8_t source : 4,
reserved : 4;
__le16 date; /* Date in days since January 1, 1970 */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bitfields are not Endianness safe

vp2p->total_satellites = priv->gps_data.satellites_visible;

if (priv->gps_data.set & DOP_SET) {
vp2p->hdop = (uint8_t)(priv->gps_data.dop.hdop * 10);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

casts not needed

nmea2000_sys_time_prepare_data(struct j1939_vp_srv_priv *priv, void *data)
{
struct nmea2000_sys_time_packet *stp =
(struct nmea2000_sys_time_packet *)data;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cast not needed

struct tm tm;

// Get the current time
clock_gettime(CLOCK_REALTIME, &ts);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error handling

@marckleinebudde
Copy link
Member

To make it compile libgps-dev package is required.

We need a cmake option for this.

@marckleinebudde
Copy link
Member

@marckleinebudde
Copy link
Member

marckleinebudde commented Aug 5, 2024

Have a look at https://github.com/marckleinebudde/can-utils/tree/j1939_vehicle_position for a WIP github actions fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants