View previous topic :: View next topic |
Author |
Message |
gokul
Joined: 26 Oct 2016 Posts: 5
|
Extracting a key from CAN bus |
Posted: Wed Oct 26, 2016 7:25 am |
|
|
Hello,
Last edited by gokul on Wed Oct 26, 2016 9:33 am; edited 1 time in total |
|
|
newguy
Joined: 24 Jun 2004 Posts: 1907
|
|
Posted: Wed Oct 26, 2016 8:13 am |
|
|
I've been working with CAN systems for about 15 years now and I have no idea what you're asking or talking about, particularly the "data is 60 byte" part. A CAN packet transfers 8 bytes. The new multirate CAN spec can transfer more but that's so new that there are very few processors on the market that can handle the multirate standard. I'm not aware of any PICs with it built-in. |
|
|
RF_Developer
Joined: 07 Feb 2011 Posts: 839
|
|
Posted: Wed Oct 26, 2016 8:17 am |
|
|
CAN works by messages. Each message must have an identifier, either 11 bit or 29 bit. Yours use 11 bits, which is fine, but you will need to know what the identifier is.
Each message can only have up to 8 bytes. That's all. So, you cannot send 60 bytes in a single message; it must be split up, probably into eight messages, each with a different identifier, or possibly more with a data byte used as a sequence number to tell you which of the 60 bytes of the key the message contains.
You need a PIC with CAN, such as the PIC18F46K80, or similar, and a CAN level interface IC, such as the MCP2551 or the newer MCP2561 or 2562. CCS C provides good firmware support for these, making the code fairly simple. That hardware and firmware will be able to do a lot more than just receive the key, it will be able to send and receive any CAN messages. |
|
|
gokul
Joined: 26 Oct 2016 Posts: 5
|
A better way of explaining my problem |
Posted: Wed Oct 26, 2016 8:24 am |
|
|
Yes, you are correct.
I would like to know two things
1) if there is a way can I extract this code without knowing the Identifiers?
2) If I know the identifiers then how will this key be incorporated with the identifier?? Usually identifiers have numbers but this has special characters. |
|
|
gokul
Joined: 26 Oct 2016 Posts: 5
|
@Newguy |
Posted: Wed Oct 26, 2016 8:25 am |
|
|
I have sent you a private message. |
|
|
newguy
Joined: 24 Jun 2004 Posts: 1907
|
|
Posted: Wed Oct 26, 2016 8:28 am |
|
|
The identifier can be anything. You said it was 11 bits, so it can range from 0x000 - 0x7FF.
I have to ask you: what is a special character? Hint: If you look up the ascii codes, what do the special characters translate to in hex? |
|
|
gokul
Joined: 26 Oct 2016 Posts: 5
|
|
Posted: Wed Oct 26, 2016 8:31 am |
|
|
Lets say I have 9 messages under one ID (say 0X58F)
Last edited by gokul on Wed Oct 26, 2016 9:33 am; edited 1 time in total |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9225 Location: Greensville,Ontario
|
|
Posted: Wed Oct 26, 2016 9:11 am |
|
|
Maybe it's just my 'old school math' but I get 198 bytes of data.
Considering this data is ASCII...
msg 0 consists of 00.10.20.30.40.50.60.7
1+(7*3)
that's 22 bytes of data, where 'H' is the first 0, and 1st 'D' is 0.1,2nd 'D' is 0.2,etc.
Perhaps I'm missing something ?
I'd use some form of 'data monitor' to capture the data stream to confirm the ACTUAL data being sent to you.
Jay |
|
|
gokul
Joined: 26 Oct 2016 Posts: 5
|
|
Posted: Wed Oct 26, 2016 9:23 am |
|
|
The CAN-ID 0x58F has a 1 Byte Multiplexer (Byte 0) – so there are 7 Bytes from the 8 Databytes left for transporting real Information
This is what I interpreted. Am I right???
how do i progress??
Last edited by gokul on Wed Oct 26, 2016 9:32 am; edited 1 time in total |
|
|
RF_Developer
Joined: 07 Feb 2011 Posts: 839
|
|
Posted: Wed Oct 26, 2016 9:26 am |
|
|
gokul wrote: | I have 9 messages under one ID (say 0X58F)
Each message is in the format HDDDDDDD
Each message comes from a Mux
It looks like this
1. Message 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7
2. Message 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7
3. Message 2 2.1 2.2 2.3 2.4 2.5 2.6 2.7
4. Message 3 3.1 3.2 3.3 3.4 3.5 3.6 3.7
5. Message 4 4.1 4.2 4.3 4.4 4.5 4.6 4.7
6. Message 5 5.1 5.2 5.3 5.4 5.5 5.6 5.7
7. Message 6 6.1 6.2 6.3 6.4 6.5 6.6 6.7
8. Message 7 7.1 7.2 7.3 7.4 7.5 7.6 7.7
9. Message 8 8.1 8.2 8.3 8.4 0xAA 0xAA 0xAA
|
This is the second scenario I mentioned: you have nine messages, all with the same ID 0x58F. The first byte of each message is a sequence number, from 0 to 9. The other bytes are part of the key. The first message, with sequence number 0, has the first seven bytes of the key, message sequence one has the next seven, and so on. There are eight full messages, with seven bytes each, i.e. 56 bytes, and one, the ninth, with the remaining four bytes. All straightforward enough.
Now, there is something to think about: CAN does not ensure messages are sent in sequence. They can be sent, and thus received, in any order. So, you must make sure you have received all nine messages before you use the key.
At this point, this is all just simple CAN (Yes, this is simple!), but it's nothing specific to CCS C. I've already shown enough to get a generic solution sorted. So, unless you can show us how CCS C is involved, I will not give anymore help, and I doubt anyone else will either. |
|
|
|