administrators

It reads the entire buffer in one shot, and some more advanced commands wait for additional input. This could probably be improved upon.

I can send commands as described above using Coolterm on a Mac with the expected result. When I connect the Canbus triple to the ODBII port in my car (Volvo XC70, 2005) I don't see any logging data after sending the command to log data, I tried Bus 1, 2 and 3. Any hints? Is this perhaps the baud rate problem which will be fixed by autodetection?

Try issuing the bus debug command - 0x01 0x10 0x01 (for bus 1).

Trial and error suggests that Status = B is the error state for incorrect baud rate. Status = 0 seems to imply no electrical connection (ie no activity on the bus if it's connected correctly), and Status = 1 is for connected.

Now that I am using cool term I have no problem sending commands. Occasionally the CBT will get pissed off but I have been able to narrow it down and I'm pretty sure it was caused by the bus power cycling even though it has power from the usb.

If you are looking for an easy way to dump decoded id's and messages you can add this code snippet to each of the IF statements that checks for a full RX buffer in the readBus() function.

<code>
Serial.print("busId: ");
Serial.print(msg.busId);
Serial.print(" BusStat: ");
Serial.print(msg.busStatus);
Serial.print(" FrameId: ");
Serial.print(msg.frame_id, HEX);
Serial.print(" msgLen: ");
Serial.print(msg.length);
Serial.print(" Msg: ");
for(int i=0;i<msg.length;i++){
Serial.print(msg.frame_data[i], HEX);
Serial.print(".");
}
Serial.println();
</code>

This is not the best way to go about this but it is quick and dirty. Its just a bunch of print statements. You can paste it in right after the line readQueue.push(msg);

I don't know how this will function if you are using bluetooth but for quick and dirty dumping of formatted id's and messages it works.

after pasting it in, your readBus function will look something like this:

<code>
void readBus( CANBus bus ){
// Abort if readQueue is full
if( readQueue.isFull() ) return;

rx_status = bus.readStatus();

// Check buffer RX0
if( (rx_status & 0x1) == 0x1 ){
Message msg;
msg.busStatus = rx_status;
msg.busId = bus.busId;
bus.readDATA_ff_0( &msg.length, msg.frame_data, &msg.frame_id );
readQueue.push(msg);
Serial.print("busId: ");
Serial.print(msg.busId);
Serial.print(" BusStat: ");
Serial.print(msg.busStatus);
Serial.print(" FrameId: ");
Serial.print(msg.frame_id, HEX);
Serial.print(" msgLen: ");
Serial.print(msg.length);
Serial.print(" Msg: ");
for(int i=0;i<msg.length;i++){
Serial.print(msg.frame_data[i], HEX);
Serial.print(".");
}
Serial.println();
}

// Abort if readQueue is full
if( readQueue.isFull() ) return;

// Check buffer RX1
if( (rx_status & 0x2) == 0x2 ) {
Message msg;
msg.busStatus = rx_status;
msg.busId = bus.busId;
bus.readDATA_ff_1( &msg.length, msg.frame_data, &msg.frame_id );
readQueue.push(msg);
Serial.print("busId: ");
Serial.print(msg.busId);
Serial.print(" BusStat: ");
Serial.print(msg.busStatus);
Serial.print(" FrameId: ");
Serial.print(msg.frame_id, HEX);
Serial.print(" msgLen: ");
Serial.print(msg.length);
Serial.print(" Msg: ");
for(int i=0;i<msg.length;i++){
Serial.print(msg.frame_data[i]);
Serial.print(".");
}
Serial.println();
}

}</code>

I still have problems understanding the serial command syntax
http://docs.canb.us/firmware/api.html says

Send CAN Packet

Send a CAN Packet over the specified Bus. Bus Id should be 1 through 3
Command Bus Id Message ID Data Length
0x02 01 290 00 00 00 00 00 00 00 00 8

  • are all the values hex values? the command in the example is given as 0x02
  • what about the "Message Id" ?, how many byte do I have to send for it? the base frame is 11 bit, that means in hex Its up to 0x7ff - 3 bytes. Do I have to send always three bytes, ebven if Message Id is zero or 1? What about extended frame id with 29bit, which is common in cars.
  • next is data, always eight bytes?
  • last but not least, what is "Length"? Has it to follow the data? As value in hex?

<b>Summary</b>- Sending a CAN frame (as of now) is a sequence of always 14 bytes, is it?

Derek
<i>and the remaining two 16 byte flags are to filter for a specific message id, leave them at 0 to dump everything.
0x03 0x01 0x01 0x0000 0x0000</i>

I think you mean <b>the remaining two 16 bit flags</b>, do you? and the command is seven bytes

administrators

Hey Heinz,

You're correct, thanks. I have to write a lot of this stuff late at night when I'm tired after work. And I'm moving as fast as I can now and make mistakes so thank you for pointing that out!

And yes to your previous post, sending a frame is always 14 bytes.

administrators

Also, as of right now the firmware does not support 29 bit message ids. But the hardware does, it's just a matter of implementing that in the code eventually.

I know that the mcp2515 supports 29bit. It was not clear von the docs if 29bit frame id is implemented or not or not documented.

Derek, what is your opinion about setting up a wiki where we all can contribute and help.

@henk_kuipers‌ I read that Volvo is a bit special in the CANBUS and needs a signal from the K-line to keep awake if you try to access the CANBUS over OBDII. I tried on my V70 and had the samen problem, no data at all. There seems to be the option of connecting to CANBUS direct elsewhere but I don't know enough about Volvo to know where.

Hope to have an other make car this weekend to test the CBT on that one.

<a href="http://forum.canb.us/profile/254/Xag">@Xag </a> Thanks, that is very useful information. I am already using a proprietary Canbus Function Extender so I should be able to figure out the direct connection to the Canbus. Will post an update when I make some progress.

What are some baud rates I could possibly try with a Japanese vehicle (2011 Suzuki Kizashi)?
Is it normal to only get one of the can busses to respond with a status 14 if I am using the OBD-2 plug instead of wiring directly to the CANBus?
In my case only CANBus 2 responds with {"e":"busdgb", "name":"Bus 2", "canctrl":"7", "status":"14", "error":"B", "nextTxBuffer":"2"} after sending a 0x01 0x10 0x02.

<a href="http://forum.canb.us/profile/Xag">@Xag</a> Did a lot of reading, downloading and searching. A good place to get access to the canbus of a Volvo with RTI is the Melbus plug at the back of the RTI DVD player. That's also where the Canbus Function Extender I use from Volvotech is connected. However, I haven't yet figured out the pinout of the Melbus interface, I can't find an exact description. I have downloaded the complete wiring overview of my Volvo XC70 but that hasn't helped me yet, I am more proficient at reading code than wiring diagrams ;-) There are a couple of guys at the svxc.se and swedespeed.com forums that seem to know an awful lot about canbus hacking, when I am really stuck I will ask them.

Okay, made some progress today. The problem I had was getting no data from the CANBUS. The connection to the CBT was fine but issuing CMD 03010100000000 returned nothing (well an ACSII ".") I thought it could be CANBUS speed related.

After looking on this page:
http://docs.canb.us/firmware/main.html

There is a part "How the firmware works" were it says:
// Setup CAN Busses
CANBus1.begin();
CANBus1.baudConfig(125);
CANBus1.setRxInt(true);
CANBus1.setMode(NORMAL);

In the current Arduino program it's some kind of subrouting to (i guess) an auto-detect but that's not working for me.

Look for the line: CANBus1.baudConfig(cbt_settings.busCfg[0].baud);
I replaced it with 500 to get a fixed rate and that got me data from line 1

The next problem to solve is how to save the HEX data. For some reason or another CoolTerm only seems to be saving the ASCII part which is unusable to me.

ˇ
⁄G�������
�eˇˇ����
-�����
(
ı=Ñ~�P�˛

You get the idea....

Anybody got any tips for me how to save HEX (which I see on the screen) to the file? I tried both Text Editor on my Mac and Notepad on Windows XP but both save the same. Do I need another program to convert this again?

I need the HEX format so I can load it in Excel for comparison.

Update. Got Realterm which is supposed to be able to capture Hex to file..nope, not the current one, the checkbox is simply gone. Went back to version 2.0.0.57 where there is a checkbox and got my first file with Hex data. Now going to have a try at analyzing it in Excel.

I'm not sure why you want the whole output in Hex, but I think CoolTerm may be able to do it for you. There is a Hexadecimal option for capturing data in Options > Receive > Capture format [Hexadecimal].

However, it looks like there is an alternative if you are OK with JSON format by removing the comments before this line of code in SerialCommands.h.

#define JSON_OUT

Once you do that, it give you a JSON format like this:

{"packet": {"status":"1","channel":"Bus 1","length":"8","id":"50","timestamp":"247444","payload":["1","0","F","1","AA","55","AA","55"]}}
{"packet": {"status":"1","channel":"Bus 1","length":"8","id":"50","timestamp":"247456","payload":["1","0","F","1","AA","55","AA","55"]}}
{"packet": {"status":"1","channel":"Bus 1","length":"8","id":"39E","timestamp":"247470","payload":["0","0","0","7F","0","10","0","0"]}}
{"packet": {"status":"1","channel":"Bus 1","length":"8","id":"50","timestamp":"247474","payload":["1","0","F","1","AA","55","AA","55"]}}
{"packet": {"status":"1","channel":"Bus 1","length":"8","id":"50","timestamp":"247486","payload":["1","0","F","1","AA","55","AA","55"]}}
{"packet": {"status":"1","channel":"Bus 1","length":"8","id":"508","timestamp":"247490","payload":["0","AA","55","AA","55","AA","55","AA"]}}

[I'm not sure if this changes how the BT output works. It looks like the else statement of the #ifdef JSON_OUT does some BT stuff. Maybe someone can help explain this.]

Tanks, I'll have a look. I could use a better method.

I'm trying to learn what CANbus messages are going over the line. The current output is from contact on but engine not running. Want to eventually filter these out so I can start identifying messages when I press buttons or send commands from the manufacturers tool.

Any other way going about this?

Hey Xag, can you share your settings in Realterm? I'd prefer to use it also, but unable to get any display data back from the CB unit no matter what settings I try...

I'm away from home this week so can't look now. I use the regular settings 9600/8/1/N. Where do you get stuck?

Connection seems to be opening, but when I try to SEND simple hex commands like 0x0101, not seeing any replies as would in coolterm. Tried several display settings with no luck.

  • 61
    Posts
  • 47705
    Views

Looks like your connection to CANBus Triple was lost, please wait while we try to reconnect.