Discussion:
send several flames,and ncread for respond
(too old to reply)
yeoh
2007-12-27 11:10:11 UTC
Permalink
i am new to in-can. i need to send 22 of data flames to ECU,and get the ECU respond. As attached are complete  VB6.0 code.
i use this method to send all 22 data flames., and use ncwaitforstate,ncread to read the ECU respond. But, i couldn`t get it directly,
i need to place about 30seconds delay after the ncwrite, so that i can get the desire respond. i knew that this is not the right way to get the
respond,as the respond are expected return immediatly. i would expect respond from ECU without such a long delay. Anyway one, please advice. Thanks
 
 
 For y = 0 To 21 Step 1                data = List2.List(x)        Data_1 = Mid(data, 1, 2)        Data_2 = Mid(data, 3, 2)        Data_3 = Mid(data, 5, 2)        Data_4 = Mid(data, 7, 2)        Data_5 = Mid(data, 9, 2)        Data_6 = Mid(data, 11, 2)        Data_7 = Mid(data, 13, 2)        Data_8 = Mid(data, 15, 2)                x = x + 1
        Transmit.data(0) = "&H" & Data_1        Transmit.data(1) = "&H" & Data_2        Transmit.data(2) = "&H" & Data_3        Transmit.data(3) = "&H" & Data_4        Transmit.data(4) = "&H" & Data_5        Transmit.data(5) = "&H" & Data_6        Transmit.data(6) = "&H" & Data_7        Transmit.data(7) = "&H" & Data_8           Status = ncWrite(TxHandle, Len(Transmit), Transmit)        wait 30s    Next y
     Status = ncWaitForState(RxHandle, (NC_ST_READ_AVAIL), 2000, State)   If (CheckStatus(Status, "ncWaitForState") = True) Then GoTo Error  
      Status = ncRead(RxHandle, Len(Receive), Receive)   If (CheckStatus(Status, "ncRead") = True) Then GoTo Error  


send several flames.txt:
http://forums.ni.com/attachments/ni/30/3033/1/send several flames.txt
yeoh
2007-12-28 15:10:10 UTC
Permalink
Thanks for replying.
 
i could get the respond by adding more delay. But, one problem occur. i need to read for 3 times,in order to get the desire respond.
As show in attached file. i try to read the respond for 6 times,after 22 flames was sent by using ncwrite. i couldn`t get the desire respond for the first time read, However, the desire respond can only get it after second times of read.  
 
As show are the respond i get after sending 22 flames
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
0x91741780FFFF88BE   --->previous respond for initialize download
0x91741780FFFF88BE  ---->previous respond for initialize download
0x9176FFFFFFFFFFF  ------>desire respond (showing the 22 flames has been written successfully)
 
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
 
After that,i need to send a flames to inform ECU that all the data has finished written. Then, the ECU will calculate the checksum of all data i sent , lastly, will send respond a flame to indicate that the checksum(88BE) has correctly match the flames that i sent during initialize download section.
 
i am wondering whether i am using the correct method to send severals flames, but it works for sending one flame ,and then get a respond immediately.  Please advice.


send 22 flames.txt:
http://forums.ni.com/attachments/ni/30/3040/1/send 22 flames.txt
yeoh
2007-12-28 15:40:11 UTC
Permalink
Thanks for replying.
 
i could get the respond by adding more delay. But, one problem occur. i need to read for 3 times,in order to get the desire respond.
As show in attached file. i try to read the respond for 6 times,after 22 flames was sent by using ncwrite. i couldn`t get the desire respond for the first time read, However, the desire respond can only get it after second times of read.  
 
As show are the respond i get after sending 22 flames
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
0x91741780FFFF88BE   --->previous respond for initialize download
0x91741780FFFF88BE  ---->previous respond for initialize download
0x9176FFFFFFFFFFF  ------>desire respond (showing the 22 flames has been written successfully)
 
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
 
After that,i need to send a flames to inform ECU that all the data has finished written. Then, the ECU will calculate the checksum of all data i sent , lastly, will send respond a flame to indicate that the checksum(88BE) has Not correctly match the flames that i sent during initialize download section.
 
The return checksum from ECU is zero. i am thinking why would the ECU has calculated zero checksum, Is it possible that the 22flames of data was not correctly send ??
 
i am wondering whether i am using the correct method to send severals flames, but it works for sending one flame ,and then get a respond immediately.  Please advice.


send 22 flames.txt:
http://forums.ni.com/attachments/ni/30/3042/1/send 22 flames.txt
yeoh
2007-12-28 23:40:13 UTC
Permalink
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
yeoh
2007-12-28 23:40:10 UTC
Permalink
Marshall R,
 
Thanks for replying. Well, i am trying to flash an ECU.
The step to being flashing are as follows:
 
1) initialize download
  
yeoh
2007-12-28 23:40:10 UTC
Permalink
Marshall R,
 
Thanks for replying. Well, i am trying to flash an ECU.
The step to being flashing are as follows:
 
1) initialize download
   
yeoh
2007-12-28 23:40:12 UTC
Permalink
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
yeoh
2007-12-28 23:40:14 UTC
Permalink
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
yeoh
2007-12-28 23:40:13 UTC
Permalink
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
yeoh
2007-12-28 23:40:15 UTC
Permalink
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
yeoh
2007-12-28 23:40:14 UTC
Permalink
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
yeoh
2007-12-28 23:40:14 UTC
Permalink
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
yeoh
2007-12-29 00:40:08 UTC
Permalink
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

 

 
yeoh
2008-01-01 14:10:04 UTC
Permalink
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
DirkW
2008-01-02 15:40:06 UTC
Permalink
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 ErrorStatus = 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 yStatus = 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

Loading...