<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Nikolay, Mark,<br>
<br>
Am 02.01.2013 19:28, schrieb Nikolay Shishkov:<br>
<blockquote
cite="mid:1357151294.79536.YahooMailNeo@web142603.mail.bf1.yahoo.com"
type="cite">
<div style="color:#000; background-color:#fff; font-family:times
new roman, new york, times, serif;font-size:12pt"><br>
<div style="background-color: transparent; color: rgb(0, 0, 0);
font-size: 16px; font-family: 'times new roman', 'new york',
times, serif; font-style: normal;">
<div style="color: rgb(0, 0, 0); font-family: 'times new
roman', 'new york', times, serif; font-size: 16px;
font-style: normal;"> can_2_soc2 = ((unsigned
int) can_databuffer[4] << 8) + can_databuffer[5];</div>
<div style="color: rgb(0, 0, 0); font-family: 'times new
roman', 'new york', times, serif; font-size: 16px;
font-style: normal;">Initially I got the 5th and 6th array
elements, but noticed that I had it wrong... so I changed to
4th and 5th... </div>
<div style="color: rgb(0, 0, 0); font-family: 'times new
roman', 'new york', times, serif; font-size: 12pt;
font-style: normal;"><br>
</div>
<div style="color: rgb(0, 0, 0); font-family: 'times new
roman', 'new york', times, serif; font-size: 12pt;
font-style: normal;">And finally at the debug sms handler:</div>
<div>
<div> s = stp_i ( s, " SOC=", can_2_soc2 );</div>
<div style="color: rgb(0, 0, 0); font-family: 'times new
roman', 'new york', times, serif; font-size: 12pt;
font-style: normal;"><br>
</div>
<div style="color: rgb(0, 0, 0); font-family: 'times new
roman', 'new york', times, serif; font-size: 12pt;
font-style: normal;">I changed the strings abit and can
see that the new code is running, but do not understand
how come a completely different values are reported - the
value is from can_databuffer[5] and can_databuffer[6].</div>
<div style="color: rgb(0, 0, 0); font-family: 'times new
roman', 'new york', times, serif; font-size: 12pt;
font-style: normal;">So the 301 contains the following
bytes (viewed with PCAN) 00 00 0e 7d 01 b2 0a 4a. </div>
<div style="color: rgb(0, 0, 0); font-family: 'times new
roman', 'new york', times, serif; font-size: 12pt;
font-style: normal;"><span style="font-size: 12pt;
background-color: transparent;">The SOC is supposed to
be in 0E7D (actually it is the DOD), but I am getting
the 0AB2 in the can_2_soc2 value.</span><br>
</div>
</div>
</div>
</div>
</blockquote>
<br>
I don't know PCAN, but the CAN byte numbering normally begins at 0
on the left, so 0e in your example is can_databuffer[2] and 7d is
...[3].<br>
<br>
If you get 0AB2, that would be [6][5] = your initial code?<br>
<br>
Btw: we could solve variable name conflicts between vehicle modules
by introducing some namespace prefix (replacing "can_") like Mark
already did for the functions. I'd shorten that for vars to e.g.
"vrt_" for "vehicle renault twizy", accordingly "vtc_" for the Think
and so on. OK, Mark?<br>
<br>
Regards,<br>
Michael<br>
<br>
<pre class="moz-signature" cols="72">--
Michael Balzer * Paradestr. 8 * D-42107 Wuppertal
Fon 0202 / 272 2201 * Handy 0176 / 206 989 26
</pre>
</body>
</html>