On 21.10.2010 18:15, Marc Kleine-Budde wrote:
> On 10/21/2010 05:32 PM, Oliver Hartkopp wrote:
>>> Gerhard, do you have any reference, how a possible DLC values in RTR frames
>>> can be used?
>>
>> The BOSCH CAN Spec says about RTR frames:
>>
>> There is no DATA FIELD, independent of the values of the DATA LENGTH CODE
>
> Does the controller send any data bits over the wire? My can network is
> remote, so I cannot hook up a scope.
As Kurt already wrote: No.
>
>> which may be signed any value within the admissible range 0...8. The value is
>> the DATA LENGTH CODE of the corresponding DATA FRAME.
>>
>> So indeed this needs to by fixed in the sja1000:
>>
>> - always read CAN-identifier _and_ DLC
>
> ACK
>
>> - copy CAN data on behalf of the RTR bit
>
> What do you mean?
> I think when receiving an RTR message the data bytes can be ignored,
> thus we don't copy it in the driver.
That's what i meant.
RTR bit set -> no copy of CAN data[] -> CAN data[] remains zero initialized.
The sja1000 driver needs to be changed like this then:
diff --git a/drivers/net/can/sja1000/sja1000.c
b/drivers/net/can/sja1000/sja1000.c
index 0a8de01..6942b2c 100644
--- a/drivers/net/can/sja1000/sja1000.c
+++ b/drivers/net/can/sja1000/sja1000.c
@@ -346,13 +346,13 @@ static void sja1000_rx(struct net_device *dev)
| (priv->read_reg(priv, REG_ID2) >> 5);
}
- if (fi & FI_RTR) {
+ cf->can_dlc = get_can_dlc(fi & 0x0F);
+
+ if (fi & FI_RTR)
id |= CAN_RTR_FLAG;
- } else {
- cf->can_dlc = get_can_dlc(fi & 0x0F);
+ else
for (i = 0; i < cf->can_dlc; i++)
cf->data[i] = priv->read_reg(priv, dreg++);
- }
cf->can_id = id;
_______________________________________________
Socketcan-core mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/socketcan-core