
Originally Posted by
Lukeyson
The J2534 support and 12MB speed gives it a future as a serious tool. However I'd have to find out if it gives me low-level access to the CAN bus directly, rather than just through the J2534 API.
The J2534-1 API gives you low-level access to the CAN network. You get variable baud rates, at least the standard medium speed 125k/250k, highspeed 500k, and up to 1M. Also, access to parameters like the bit sample point and sync jump width if you need those. Is there anything else you'd need that it doesn't provide?
I took a break at work this morning and wrote a sample "sniffer" program in C to demonstrate.
Code:
// Open a handle to the PassThru device and connect to CAN on pins 6 & 14
errcode = PassThruOpen(NULL, &DeviceID);
errcode = PassThruConnect(DeviceID, CAN, 0, 500000, &ChannelID);
// Add a "pass all" filter because J2534-1 blocks everything by default
Mask.ProtocolID = CAN;
Mask.TxFlags = 0;
Mask.Data[0] = 0x0;
Mask.Data[1] = 0x0;
Mask.Data[2] = 0x0;
Mask.Data[3] = 0x0;
Mask.DataSize = 4;
Pattern.ProtocolID = CAN;
Pattern.TxFlags = 0;
Pattern.Data[0] = 0x0;
Pattern.Data[1] = 0x0;
Pattern.Data[2] = 0x0;
Pattern.Data[3] = 0x0;
Pattern.DataSize = 4;
errcode = PassThruStartMsgFilter(ChannelID, PASS_FILTER, &Mask, &Pattern, NULL, &filterID);
while (1)
{
// Try to read 100 messages
numMsgs = 100;
errcode = PassThruReadMsgs(ChannelID, Msg, &numMsgs, 10);
if (errcode == ERR_BUFFER_OVERFLOW)
{
// Getting here means you've dropped a packet. If so,
// try to read more messages at once
}
// Log to disk instead of writing to the Windows GUI if speed is critical
dbug_printmsg(Msg, "pMsg", numMsgs, 0);
}
Bookmarks