-
Notifications
You must be signed in to change notification settings - Fork 714
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
base: master
Are you sure you want to change the base?
Conversation
Introduce `libj1939_connect_socket` function to handle socket connections. Signed-off-by: Oleksij Rempel <[email protected]>
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 <[email protected]>
…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]>
To make it compile libgps-dev package is required. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 */ |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error handling
We need a cmake option for this. |
https://github.com/marckleinebudde/can-utils/actions/runs/10246077261/job/28342432051#step:4:125 I think there's a header file missing. |
Have a look at https://github.com/marckleinebudde/can-utils/tree/j1939_vehicle_position for a WIP github actions fix. |
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.