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

Problem with read multiframe package #9

Closed KnightRUS closed 2 years ago

KnightRUS commented 2 years ago

i tryed to send for example DM35 (50 bytes) from PCAN-Explorer (from 0xF9 - PCANExplorer to 0x80 - GD32F105 board). PCAN sends 18ec80f9 8 10 32 00 08 ff 00 9f 00 (RTS frame). Your src send back 18ecf980 8 11 32 00 08 ff 00 9f 00 (CTS frame) and transfer stopped....strange i read this manual https://www.simmasoftware.com/j1939-presentation.pdf (36 page) and i see that CTS have different structure than yours. also it has different structure of ACK frame (at end of the message) i change your CTS message to (18ecf980 8 11 32 01 ff ff 00 9f 00) and PCAN Explorer now send data transfer frames

where is truth?)

DanielMartensson commented 2 years ago

i tryed to send for example DM35 (50 bytes)

OpenSAEJ1939 does not have support for DM35. But it's very easy to implement.

18ec80f9 8 10 32 00 08 ff 00 9f 00 (RTS frame)

You are sending ID = 0x18EC80F9 where 80 is the destination address and F9 is the source address e.g PCAN module.

Your src send back 18ecf980 8 11 32 00 08 ff 00 9f 00 (CTS frame) and transfer stopped....strange

CTS means clear to send. https://github.com/DanielMartensson/Open-SAE-J1939/blob/88337acb9c1d436e56f655e6e6ee6d03d0755db0/Src/SAE_J1939/SAE_J1939-21_Transport_Layer/Transport_Protocol_Connection_Management.c#L28

Only use RTS when you want to send to a specific device. Only use BAM if you want to send all data to all devicies at the same time.

Follow this function https://github.com/DanielMartensson/Open-SAE-J1939/blob/88337acb9c1d436e56f655e6e6ee6d03d0755db0/Src/SAE_J1939/SAE_J1939-21_Transport_Layer/Transport_Protocol_Data_Transfer.c#L80

Question: How many packages do you want to recieve?

DanielMartensson commented 2 years ago

8 10 32 00 08 ff 00 9f 00

You are sending: Control byte = 0x8 (Not supported. Please write in it here: https://github.com/DanielMartensson/Open-SAE-J1939/blob/main/Src/SAE_J1939/SAE_J1939_Enums/Enum_Control_Byte.h) Message size: 0x32 << 8 | 0x10 = 12816 bytes. Wow...that's way to much! Number of packages = 0x0 (Zero packages?) PGN number 0x00 << 16 | 0x9f << 8 | 0x00 = 0x09F00 (Please add it here https://github.com/DanielMartensson/Open-SAE-J1939/blob/main/Src/SAE_J1939/SAE_J1939_Enums/Enum_PGN.h)

KnightRUS commented 2 years ago

i tryed to send for example DM35 (50 bytes)

OpenSAEJ1939 does not have support for DM35. But it's very easy to implement.

18ec80f9 8 10 32 00 08 ff 00 9f 00 (RTS frame)

You are sending ID = 0x18EC80F9 where 80 is the destination address and F9 is the source address e.g PCAN module.

Your src send back 18ecf980 8 11 32 00 08 ff 00 9f 00 (CTS frame) and transfer stopped....strange

CTS means clear to send.

https://github.com/DanielMartensson/Open-SAE-J1939/blob/88337acb9c1d436e56f655e6e6ee6d03d0755db0/Src/SAE_J1939/SAE_J1939-21_Transport_Layer/Transport_Protocol_Connection_Management.c#L28 / When we answer with CTS, it means we are going to send the Transport Protocol Data Transfer package / - but its wrong. CTS mean we ready to get Data Transfer ...... First: Transmit a RTS message to the specific address that says:

  1. I‟m about to send the following PGN in multiple packets.
  2. I‟m sending X amount of data.
  3. I‟m sending Y number of packets.
  4. I can send Z number of packets at once. • Second: Wait for CTS: CTS says:
  5. I can receive M number of packets at once.
  6. Start sending with sequence number N. • Third: Send data. Then repeat steps starting with #2. When all data sent, wait for ACK. ....

Only use RTS when you want to send to a specific device. Only use BAM if you want to send all data to all devicies at the same time.

Follow this function

https://github.com/DanielMartensson/Open-SAE-J1939/blob/88337acb9c1d436e56f655e6e6ee6d03d0755db0/Src/SAE_J1939/SAE_J1939-21_Transport_Layer/Transport_Protocol_Data_Transfer.c#L80

Question: How many packages do you want to recieve?

i wait 8 frames with 50 bytes

KnightRUS commented 2 years ago

8 10 32 00 08 ff 00 9f 00

You are sending: Control byte = 0x8 (Not supported. Please write in it here: https://github.com/DanielMartensson/Open-SAE-J1939/blob/main/Src/SAE_J1939/SAE_J1939_Enums/Enum_Control_Byte.h) Message size: 0x32 << 8 | 0x10 = 12816 bytes. Wow...that's way to much! Number of packages = 0x0 (Zero packages?) PGN number 0x00 << 16 | 0x9f << 8 | 0x00 = 0x09F00 (Please add it here https://github.com/DanielMartensson/Open-SAE-J1939/blob/main/Src/SAE_J1939/SAE_J1939_Enums/Enum_PGN.h)

sorry its my fault. 8 meand dls (it is not part of data bytes) in all examples in my issue(

DanielMartensson commented 2 years ago

i tryed to send for example DM35 (50 bytes)

OpenSAEJ1939 does not have support for DM35. But it's very easy to implement.

18ec80f9 8 10 32 00 08 ff 00 9f 00 (RTS frame)

You are sending ID = 0x18EC80F9 where 80 is the destination address and F9 is the source address e.g PCAN module.

Your src send back 18ecf980 8 11 32 00 08 ff 00 9f 00 (CTS frame) and transfer stopped....strange

CTS means clear to send. https://github.com/DanielMartensson/Open-SAE-J1939/blob/88337acb9c1d436e56f655e6e6ee6d03d0755db0/Src/SAE_J1939/SAE_J1939-21_Transport_Layer/Transport_Protocol_Connection_Management.c#L28

/ When we answer with CTS, it means we are going to send the Transport Protocol Data Transfer package / - but its wrong. CTS mean we ready to get Data Transfer ...... First: Transmit a RTS message to the specific address that says:

  1. I‟m about to send the following PGN in multiple packets.
  2. I‟m sending X amount of data.
  3. I‟m sending Y number of packets.
  4. I can send Z number of packets at once. • Second: Wait for CTS: CTS says:
  5. I can receive M number of packets at once.
  6. Start sending with sequence number N. • Third: Send data. Then repeat steps starting with MCP2515 support #2. When all data sent, wait for ACK. ....

Only use RTS when you want to send to a specific device. Only use BAM if you want to send all data to all devicies at the same time. Follow this function https://github.com/DanielMartensson/Open-SAE-J1939/blob/88337acb9c1d436e56f655e6e6ee6d03d0755db0/Src/SAE_J1939/SAE_J1939-21_Transport_Layer/Transport_Protocol_Data_Transfer.c#L80

Question: How many packages do you want to recieve?

i wait 8 frames with 50 bytes

Please. Show me your C code.

KnightRUS commented 2 years ago

so here is your code /*

commented section was yours and below is my section - it works.

KnightRUS commented 2 years ago

please look at https://www.simmasoftware.com/j1939-presentation.pdf (36 page) other parts of my code and yours dont matter. problem in structure of cts frame

DanielMartensson commented 2 years ago

I think this software does not follow the standard. https://github.com/DanielMartensson/Open-SAE-J1939/blob/main/Src/Documentation/Pictures/SAE%20J1939%20Resources/TCI%20%20SENSE%2042%20Version%203.0-25-108.pdf

See page 32 / 108

KnightRUS commented 2 years ago

i cant find RTS CTS structure in your pdf (tell me page please). i only found work with BAM (your source works fine with BAM)

DanielMartensson commented 2 years ago

RTS and CTS is a control byte. Only a number.

KnightRUS commented 2 years ago

RTS and CTS is a control byte. Only a number.

I'm sorry, I'm in a hurry and therefore I write nonsense))) i mean that i dont found decription for Transport_Protocol PGN (0xEC). in your documentation i found only with control byte = BAM description

KnightRUS commented 2 years ago

as you can see in my documentation we have 3 descriptions of 0xEC PGN. for BAM for RTS for CTS. And CTS very different

DanielMartensson commented 2 years ago

RTS and CTS is a control byte. Only a number.

I'm sorry, I'm in a hurry and therefore I write nonsense))) i mean that i dont found decription for Transport_Protocol PGN (0xEC). in your documentation i found only with control byte = BAM description

Here is my documention: https://github.com/DanielMartensson/Open-SAE-J1939/blob/main/Src/Documentation/Open%20SAE%20J1939.pdf

OpenSAEJ1939 have support for BAM, RTS and CTS.

KnightRUS commented 2 years ago

so in this documentation you write that you support BAM, RTS and CTS but in https://github.com/DanielMartensson/Open-SAE-J1939/blob/main/Src/Documentation/Pictures/SAE%20J1939%20Resources/TCI%20%20SENSE%2042%20Version%203.0-25-108.pdf (also yours) i see words "ONLY BAM IS SUPPORTED" page 32

DanielMartensson commented 2 years ago

so in this documentation you write that you support BAM, RTS and CTS but in https://github.com/DanielMartensson/Open-SAE-J1939/blob/main/Src/Documentation/Pictures/SAE%20J1939%20Resources/TCI%20%20SENSE%2042%20Version%203.0-25-108.pdf (also yours) i see words "ONLY BAM IS SUPPORTED" page 32

It's not my documention. I only upload it as reference where I get my SAEJ1939 standard from. It's difficult to get free documents about J1939, and if I found some documention, it's most likely a list of numbers I have to work with.

KnightRUS commented 2 years ago

Anyway i will continue to adapt you sorce for my needs. i just want to tell that peak-system software dont work with your 0xEC CTS realisation. And i show you that docementation that i found helps me to fix this problem. Thanks for source

DanielMartensson commented 2 years ago

Do they follow the right standard? Because all documents that I have about SAE J1939, follows the same standard.