Skip to content

Commit 95aae6b

Browse files
authored
Merge pull request #626 from SamantazFox/patch-1
J1939: VP1/VP2 PG fixes
2 parents bf5fe73 + 90383a0 commit 95aae6b

2 files changed

Lines changed: 23 additions & 11 deletions

File tree

j1939_vehicle_position/j1939_vehicle_position_cmn.h

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ struct j1939_vp_err_msg {
5151
#define J1939_VP1_PRIO_DEFAULT 6
5252
#define J1939_VP1_MAX_TRANSFER_LENGH \
5353
sizeof(struct j1939_vp1_packet)
54-
#define J1939_VP1_REPETITION_RATE_MS 5000
54+
#define J1939_VP1_REPETITION_RATE_MS 1000
5555
#define J1939_VP1_JITTER_MS 500
5656

5757
/**
@@ -63,17 +63,17 @@ struct j1939_vp_err_msg {
6363
* - Data Length: 4 bytes
6464
* - Resolution: 10^-7 deg/bit
6565
* - Offset: -210 degrees
66-
* - Range: -210 to +211.1008122 degrees
67-
* - Operating Range: -210 degrees (SOUTH) to +211.108122 degrees
66+
* - Range: -210 to +211.10081215 degrees
67+
* - Operating Range: -210 degrees (SOUTH) to +211.1081215 degrees
6868
* (NORTH)
6969
*
7070
* @longitude: Raw longitude position of the vehicle
7171
* - SPN: 585
7272
* - Data Length: 4 bytes
7373
* - Resolution: 10^-7 deg/bit
7474
* - Offset: -210 degrees
75-
* - Range: -210 to +211.1008122 degrees
76-
* - Operating Range: -210 degrees (WEST) to +211.108122 degrees
75+
* - Range: -210 to +211.10081215 degrees
76+
* - Operating Range: -210 degrees (WEST) to +211.1081215 degrees
7777
* (EAST)
7878
*
7979
* This structure defines each component of the Vehicle Position as described in
@@ -142,42 +142,48 @@ j1939_vp1_set_longitude(struct j1939_vp1_packet *packet, int32_t longitude)
142142
/**
143143
* struct j1939_vp2_packet - Represents the PGN 64502 Vehicle
144144
* Position 2 packet
145-
* FIXME: current packet layout is guessed based on limited information:
146-
* https://www.isobus.net/isobus/pGNAndSPN/10801?type=PGN
147145
*
148146
* @total_satellites: Total number of satellites in view
149147
* - SPN: 8128
150148
* - Data Length: 1 byte
149+
* - Range: 0 to 250
151150
*
152151
* @hdop: Horizontal dilution of precision
153152
* - SPN: 8129
154153
* - Data Length: 1 byte
155154
* - Resolution: 0.1
155+
* - Range: 0.0 to 25.0
156156
*
157157
* @vdop: Vertical dilution of precision
158158
* - SPN: 8130
159159
* - Data Length: 1 byte
160160
* - Resolution: 0.1
161+
* - Range: 0.0 to 25.0
161162
*
162163
* @pdop: Position dilution of precision
163164
* - SPN: 8131
164165
* - Data Length: 1 byte
165166
* - Resolution: 0.1
167+
* - Range: 0.0 to 25.0
166168
*
167169
* @tdop: Time dilution of precision
168170
* - SPN: 8132
169171
* - Data Length: 1 byte
170172
* - Resolution: 0.1
173+
* - Range: 0.0 to 25.0
171174
*
172175
* This structure defines each component of the Vehicle Position 2 as described
173176
* in PGN 64502.
174177
*/
175178
struct j1939_vp2_packet {
176179
uint8_t total_satellites; /* SPN 8128 */
177-
uint8_t hdop; /* SPN 8129 */
178-
uint8_t vdop; /* SPN 8130 */
179-
uint8_t pdop; /* SPN 8131 */
180-
uint8_t tdop; /* SPN 8132 */
180+
uint8_t hdop; /* SPN 8129 */
181+
uint8_t vdop; /* SPN 8130 */
182+
uint8_t pdop; /* SPN 8131 */
183+
uint8_t tdop; /* SPN 8132 */
184+
uint8_t unused5; /* Always 0xFF */
185+
uint8_t unused6; /* Always 0xFF */
186+
uint8_t unused7; /* Always 0xFF */
181187
} __attribute__((__packed__));
182188

183189
/**

j1939_vehicle_position/j1939_vehicle_position_srv.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,12 @@ static int j1939_vp2_get_data(struct j1939_vp_srv_priv *priv,
270270
j1939_vp2_set_pdop(vp2p, pdop);
271271
j1939_vp2_set_tdop(vp2p, tdop);
272272

273+
/* This PG's last 3 bytes are not assigned and hence must be set
274+
* to 0xFF as per J1939-71, section 5.2 */
275+
vp2p->unused5 = 0xFF;
276+
vp2p->unused6 = 0xFF;
277+
vp2p->unused7 = 0xFF;
278+
273279
return 0;
274280
}
275281

0 commit comments

Comments
 (0)