DanielMartensson / Open-SAE-J1939

SAE J1939 protocol free to use for embedded systems or PC with CAN-bus
MIT License
455 stars 164 forks source link

Regarding Proprietary A #31

Closed Navjot0005 closed 11 months ago

Navjot0005 commented 11 months ago

Hi @DanielMartensson... I was studying "Proprietary A.txt" file you last provided me.. I have below some questions please support for that

  1. Shall I copy "Proprietary A.txt" file into my "main.c"?

  2. Do I need to initialise the CAN peripheral in MXCUBE or your library will do by itself?

  3. Do I need to initialise sys_clk or your library will do by itself??

  4. Do I need to make any change in "Request_Proprietary.c" ??

  5. In "Proprietary A.txt" file why do you create two struct as shown below? / Create our J1939 structure with two ECU / J1939 j1939_1 = { 0 }; J1939 j1939_2 = { 0 };

  6. From where do you get these ECU address shown below?? / Set the ECU address / j1939_1.information_this_ECU.this_ECU_address = 0x80; / From 0 to 253 because 254 = error address and 255 = broadcast address / j1939_2.information_this_ECU.this_ECU_address = 0x90;

    / Set Proprietary A for ECU 1 / j1939_1.this_proprietary.proprietary_A.data[0] = 0x48; / H / j1939_1.this_proprietary.proprietary_A.data[1] = 0x65; / e / j1939_1.this_proprietary.proprietary_A.data[2] = 0x6C; / l / j1939_1.this_proprietary.proprietary_A.data[3] = 0x6C; / l / j1939_1.this_proprietary.proprietary_A.data[4] = 0x6F; / o / j1939_1.this_proprietary.proprietary_A.data[5] = 0x20; / / j1939_1.this_proprietary.proprietary_A.data[6] = 0x54; / T / j1939_1.this_proprietary.proprietary_A.data[7] = 0x6F; / o / j1939_1.this_proprietary.proprietary_A.data[8] = 0x20; / / j1939_1.this_proprietary.proprietary_A.data[9] = 0x79; / Y / j1939_1.this_proprietary.proprietary_A.data[10] = 0x6F; / o / j1939_1.this_proprietary.proprietary_A.data[11] = 0x75; / u / j1939_1.this_proprietary.proprietary_A.data[12] = 0x21; / ! / j1939_1.this_proprietary.proprietary_A.data[13] = 0x0; / NULL / j1939_1.this_proprietary.proprietary_A.data[14] = 0x0; / NULL /

  7. Also please explain this too / Also set its length / j1939_1.this_proprietary.proprietary_A.total_bytes = MAX_PROPRIETARY; //What does it mean?? j1939_2.from_other_ecu_proprietary.proprietary_A.total_bytes = MAX_PROPRIETARY;//What does it mean??

    / ECU 2 sending a request to ECU 1 about Proprietary A - which contains manufacturer specific data / SAE_J1939_Send_Request(&j1939_2, 0x80, PGN_PROPRIETARY_A); //What does 0x80 means??

    / Listen for messages - The reason why it looks like this is because ECU 1 and ECU 2 shares the same CAN-bus buffer - In CAN bus application, you don't need this mess / Open_SAE_J1939_Listen_For_Messages(&j1939_1); / ECU 1 is reading the request from ECU 2 / Open_SAE_J1939_Listen_For_Messages(&j1939_2); / ECU 2 read the response from ECU 1 and send back TP_CM with CTS / Open_SAE_J1939_Listen_For_Messages(&j1939_1); / ECU 1 read the TP_CM with CTS and send a RTS back with data / Open_SAE_J1939_Listen_For_Messages(&j1939_2); / ECU 2 read the TP_DT data / Open_SAE_J1939_Listen_For_Messages(&j1939_2); / ECU 2 read the TP_DT data / Open_SAE_J1939_Listen_For_Messages(&j1939_1); / ECU 1 read the ACK from ECU 2 when ECU 2 has read the complete TP_DT message /

Please support to answer above....Thanks for the support..

DanielMartensson commented 11 months ago
  1. No. You should not copy the complete Proprietary A.txt into your main.c file. Just parts of it.
  2. Yes. This library is just rules how to read the data.
  3. Yes.
  4. No, if you don't need any changes. As long you get transfer the Proprietary A struct between ECU's, you have succeeded to use Open SAE J1939.
  5. Because I talking between two ECU. In your case, you only need one ECU. Notice that's only simulation mode.
  6. You set your own ECU address between 0 and 253. 254 is error address and 255 is broadcast address.
  7. You want to transfer the Proprietary A. It's unique depending on manufacturer. In your case, it's only 8 bytes.
    • 0x80 is the destination address to ECU 1. ECU2 will now send a message to ECU 1.
    • The Open_SAE_J1939_Listen_For_Messages should be inside your while loop in main.c
Navjot0005 commented 11 months ago

@DanielMartensson These are addresses for the charger??

/ Set Proprietary A for ECU 1 / j1939_1.this_proprietary.proprietary_A.data[0] = 0x48; / H / j1939_1.this_proprietary.proprietary_A.data[1] = 0x65; / e / j1939_1.this_proprietary.proprietary_A.data[2] = 0x6C; / l / j1939_1.this_proprietary.proprietary_A.data[3] = 0x6C; / l / j1939_1.this_proprietary.proprietary_A.data[4] = 0x6F; / o / j1939_1.this_proprietary.proprietary_A.data[5] = 0x20; / / j1939_1.this_proprietary.proprietary_A.data[6] = 0x54; / T / j1939_1.this_proprietary.proprietary_A.data[7] = 0x6F; / o / j1939_1.this_proprietary.proprietary_A.data[8] = 0x20; / / j1939_1.this_proprietary.proprietary_A.data[9] = 0x79; / Y / j1939_1.this_proprietary.proprietary_A.data[10] = 0x6F; / o / j1939_1.this_proprietary.proprietary_A.data[11] = 0x75; / u / j1939_1.this_proprietary.proprietary_A.data[12] = 0x21; / ! / j1939_1.this_proprietary.proprietary_A.data[13] = 0x0; / NULL / j1939_1.this_proprietary.proprietary_A.data[14] = 0x0; / NULL /

DanielMartensson commented 11 months ago

These are the data that you want to transfer between ECUs

Navjot0005 commented 11 months ago

@DanielMartensson Ok... Where shall I receive the incoming messages in the library from ECU's???

Navjot0005 commented 11 months ago

@DanielMartensson every incoming messages received in the "Open_SAE_J1939_Listen_For_Messages(&j1939);"???

Navjot0005 commented 11 months ago

@DanielMartensson if it is received in the "Open_SAE_J1939_Listen_For_Messages(&j1939);" have you enabled receive interrupt??

DanielMartensson commented 11 months ago

Yes

Navjot0005 commented 11 months ago

@DanielMartensson if it is received in the "Open_SAE_J1939_Listen_For_Messages(&j1939);" have you enabled receive interrupt??

@DanielMartensson ????

DanielMartensson commented 11 months ago

@DanielMartensson if it is received in the "Open_SAE_J1939_Listen_For_Messages(&j1939);" have you enabled receive interrupt??

@DanielMartensson ????

Yes. It should look like this: https://github.com/DanielMartensson/GoobySoft/blob/4de6ff0660ae916d5b5931a9b317357a278cc63b/GoobySoft/GoobySoft.cpp#L163

  1. You have interupts that reads the raw can-bus message
  2. Then you call the Open_SAE_1939_Read_Messages function in your while-loop.
Navjot0005 commented 11 months ago

@DanielMartensson So that means I have to initialise the all basic parameters. Baudrate... Interuppts Sys_Clock(Internal/External)

DanielMartensson commented 11 months ago

@DanielMartensson So that means I have to initialise the all basic parameters. Baudrate... Interuppts Sys_Clock(Internal/External)

Yes.