Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

send several flames,and ncread for respond

Marshall R,
 
Thanks for replying. Well, i am trying to flash an ECU.
The step to being flashing are as follows:
 
1) initialize download
    In this step,i need
0 Kudos
Message 11 of 18
(3,382 Views)
Marshall R,
 
Thanks for replying. Well, i am trying to flash an ECU.
The step to being flashing are as follows:
 
1) initialize download
    In this step,i need to
0 Kudos
Message 12 of 18
(3,382 Views)
Marshall R,
 
Thanks for replying. Well, i am trying to flash an ECU.
The step to being flashing are as follows:
 
1) initialize download
    In this step,i need to send
0 Kudos
Message 13 of 18
(3,382 Views)
Marshall R,
 
Thanks for replying. Well, i am trying to flash an ECU.
The step to being flashing are as follows:
 
1) initialize download
    In this step,i need to send a
0 Kudos
Message 14 of 18
(3,382 Views)

Marshall R,

Thanks for replaying.

I am trying to flash an ECU.  the transmit ID is 0x4f0, and the receive ID is 0x4f1

The flashing steps are as follows

1)Initialize Download-->Send a message 0x913480FFFF88BE,and get positive respond message 0x917480FFFF88BE which indicate that initialize download success. The Last two byte 88BE is the checksum of the 22 flames message that i will send in step 2, to tell ECU that 88BE is the value of checksum that ECU should get when ECU itself will calculate the checksum of 22 flames.

 2)download-->In this step, i need to send all 22 flames of message to ECU. The ECU will only give a positive respond once 22 flames has been finish written. The positive respond would be 0x9176FFFFFFFFFFFF from the ECU,indicate that 22 flames has been received successfully.

3)End of Transfer---> after getting positve respond from ECU (0x9176FFFFFFFFFFFF), i need to send a message to tell ECU that i have finished sending all the data, and then the ECU will calculate checksum of the receive data. Return a message whether the calculated checksum match with the checksum that i send in step 1. But,in my case the ECU calculated checksum of zero. i am wondering would it be that the ECU has interpreted the 22 flames data all are zero? or maybe empty data of 22 flames?

For my understand, if trying to ncRead a respond from bus, but the ECU still not yet respond. Therefore,ncRead will get the previous respond only,until the ECU respond. That why during step 2, i am trying to get the positive respond from ECU, but it will return 2 message of previous respond ( step 1 respond: 0x917480FFFF88BE ), then will receive the desire respond ( 0x9176FFFFFFFFFFFF ).

During sending the 22 flames, the ECU will would no give any respond until the 22th flame send to ECU. my colleague use labview to flash the ECU,it works very well.Even after finish sending all 22 flames of data, the ECU will immediately send a postivie respond. For me,i am trying to use VB6.0,but it doesn`t perform well for sending the 22 flames of data.

 

Thanks,

yeoh

 

 

0 Kudos
Message 15 of 18
(3,382 Views)
I believe you are just getting responses that have been cached by your driver, that is why you are not getting the response you expect right away. The NI-CAN driver will cache a few responses so that you do not have to be constantly looking for new messages being written to the bus. If you have read everything in the buffer, it will hold the last value that was sent.

Since you have a colleague who has working code in LabVIEW, It might be a possibility to create a LabVIEW dll from his code and then call it from VB6. This will save you the pain of writing this code all together.

As for the zero check sum, what is the content of the 22nd frame, what should the check sum be?

Cheers,


Message Edited by MXI Master on 12-31-2007 04:39 PM
-Marshall R
0 Kudos
Message 16 of 18
(3,368 Views)
Happy new year, Marshall R
 
The checksum is the total of the 22 flames data. The value that i expected from ECU is 88BE, but i got zero checksum from ECU. In this case, i would assume that the ECU has received 22 flames of zero data. ECU will calculate the checksum of what its received,in order to ensure that ECU has received the correct data. i am wondering if i have using the wrong mathod to send the information.
 
As for the response, i am thinking the same way too, as the responses have been cached. i have tried to write and read for every flame that i send. i could get the expected respond right away. However,if i read the response once the 22 flames sent completely, i could only get 2 responses of previous response, and then followed by the expected response.
 
 
 
thanks,
yeoh
0 Kudos
Message 17 of 18
(3,364 Views)

Hi,

I had a look to your code and here is what i found:

Your Read Object is configured with a specific timeout period of 10 seconds (NC_DURATION_10SEC). That means you could run into a timeout error if you do not receive a frame within a 10 econd period. You should configure the period to 0 (NC_DURATION_NONE) to avoid this situation for your read object.

Your Write object writes periodic every second (NC_DURATION_1SEC). That would need 22 seconds for your 22 message download. You could configure it faster, every 10 ms for example(NC_DURATION_10MS) but you would need to configure a write queue for at least 22 frames, to not overwrite messages by accident. (AttrIdList(6) = NC_ATTR_WRITE_Q_LEN, AttrValueList(6) = 22)

Then you wrote that you need to initiate the download by writing a frame  and read the response, but before you do that there is a wait and read function. Is there any reason for this additional read?

For your Initialize process i would remove the sleep and wait for the ECU to respond using the wait function. Then i guess you would need one read only, or doi you expect more then one message to arrive?

Status = ncWrite(TxHandle, Len(Transmit), Transmit)
If (CheckStatus(Status, "ncWrite") = True) Then GoTo Error

Status = ncWaitForState(RxHandle, (NC_ST_READ_AVAIL Or NC_ST_ERROR), 10000, State)
If (CheckStatus(Status, "ncWaitForState") = True) Then GoTo Error

The same for your download and read response. Now that your object is sending the frames every 10 ms you should get your response after 2 seconds or earlier.

Next y
Status = ncWaitForState(RxHandle, (NC_ST_READ_AVAIL), 5000, State)
If (CheckStatus(Status, "ncWaitForState") = True) Then GoTo Error
   
Status = ncRead(RxHandle, Len(Receive), Receive)
If (CheckStatus(Status, "ncRead") = True) Then GoTo Error

I didn't see any write for your end message and read of the checksum, but i guess you are still working on it?

Good Luck and a happy new year.

DirkW

0 Kudos
Message 18 of 18
(3,355 Views)