Re 0x0011

Return and security access

I finally returned from some blog laziness, since it took me over one month for a new entry. I did not plan to follow this expectable behavior, but what can I say, I didn’t used CAPL that much recently and also had not so much progress.

In the meantime, I tried to establish some security access functions to my simulation, but the conclusion is, that I‘ missing the right DLL file to include into CANoe, all other solutions would’ve been veeery time  consuming.

Who ever cares about security access (it is, as the name says a function with which e.g. diagnosis functions can be secured, e.g. erase memory functions), can read the following .pdf and is hopefully perfect prepared afterwards:

SN-IND-1-003_SecurityAccess_CANoe

But to just get some additional benefit for you, I prepared a schematic illustration, how security access should work in my opinion:

security_access_schematic

 

Write From file function

To start with another topic, as I described before, I implemented kind of a write-function, that reads a string and writes this to a .txt file (check out ‚ 0x0009 ‚).

Now I want to do the way round and read values from a (.txt) file, that I can use later on. We have the following problem description: we want to send some data to an ECU, some of the data is static, some we want to took from our input-string (lets say this would be value #67 out of our string).

First I tried it with this code:

case  1:    /* write memory */
            if(something);

      glbHandleWrite = openFileRead („test.txt“,0);

      if (glbHandleWrite != 0 && fileGetString(StringLongWrite, elcount(StringLongWrite), glbHandleWrite) != 0)
      {
      SendReq[0] = 0x11;
      SendReq[1] = 0x12;
      SendReq[2] = 0x13;
      SendReq[3] = StringLongWrite[66];  // because first string-value is equal to ‚0‘
      SendRequest(ServicePhys, 4);
      setTimer( TimeOutTimer, TimeOutLong);
      write („data %s“, StringLongWrite);
      break;
      }

      else write(„Data file cannot be opened „);

with the data in dataformat 0x01 0x02 0x03 … in a „test.txt“ file.

Of course this doesn’t worked out, since we need to convert the string "0x01"  (for example) to a number, eg. using the strtol() function.

The working function would be:

if (glbHandleWrite != 0 && fileGetString(StringLongWrite, elcount(StringLongWrite), glbHandleWrite) != 0)

     {

     pos = strtol(StringLongWrite, pos, data[66]);

SendReq[0] = 0x11;

SendReq[1] = 0x12;

SendReq[2] = 0x13;

SendReq[3] = = data[66];

SendRequest(ServicePhys, 4);

or, to put it in a more general way:

on start

message 0x123 msg; 

char StringLongWrite[32] = „0x01 0x02 0x03“; 

long data[2]; 

dword pos = 0;  

pos = strtol(StringLongWrite, pos, data[0]); 

pos = strtol(StringLongWrite, pos, data[1]); 

pos = strtol(StringLongWrite, pos, data[2]);  

write(„0x%02x,0x%02x,0x%02x“, data[0], data[1], data[2]);  

msg.dlc = 8;  msg.byte(0) = 0x42; 

msg.byte(1) = data[0]; 

msg.byte(2) = data[1]; 

msg.byte(3) = data[2];  

output(msg);

}

Thanks sergej from stackoverflow for this hint!

 

 

Re 0x0011

Hinterlasse einen Kommentar