[Ovmsdev] Leaf Development

Tom Parker tom at carrott.org
Thu Feb 25 19:24:19 HKT 2016


On 02/25/2016 10:17 PM, Thor wrote:
> nice!
>
> Sorry can't help with the developing, since it's not my field of 
> programming.
> But have you considered setting up a donation for leaf development? 
> there has been a demand for leaf-alternative a long time, and the devs 
> here that worked on it have left.
> One of the devs Jermey has no leaf no more, so no pushing for the 
> leaf. It's very important that the leaf development now pushes forward 
> to get somewhere and not halt before we get there.
Donations of sleep would be helpful, but difficult to arrange.

I expect I'll have remote climate control working in the next couple of 
weeks. https://carmanuals2.com/brand/nissan/leaf-2012-372 looks like the 
TCU (AV Page 64) and charger (VC page 24) use different signals to wake 
up the VCU (charger is 5v, TCU is 12v). I can't promise much more than 
remote climate control, monitoring of the battery temperature and 
discovering the source of a clicking relay every 20 seconds or so (I've 
only seen the clicking relay once, so not sure what is causing that).

> How will your code be with the new hardware that is comming?
Looking at the leaf support, the CAN setup and the CAN transmit code is 
obviously hardware dependent. Is there an abstracted CAN tx function 
lurking somewhere? Something like a sendCanMsg(id, length, data) 
function? I get that might be difficult on the PIC with the limited 
stack, but a macro ought to work if that is a problem.

Unless we do a run of special OVMSv2 boards, the Gen 1 Leaf is going to 
need some fiddly hardware mods for remote control to work. We should add 
exposed GPIO with suitable over voltage etc protection to the OVMS v3 
wish list if it isn't there already. I'm thinking I'll use one of the 
spare pins on the diag connector on my v2 module so I don't have squeeze 
another connector onto the case.
> Anyways. I did a poll last year on how many that where interested in 
> changing to a opensource alternative for carwings/nissan connect. and 
> like 30-40 said yes. I estimate that atleast 60 leafs are interested 
> in norway.
>
> ps: I think the number for opensource alternative might be even higher 
> now after the Nissan disaster:
> http://www.troyhunt.com/2016/02/controlling-vehicle-features-of-nissan.html?m=1
>        I tested the security hole yesterday, and it was wide open. 
> today it's partialy closed. look at the response time before nissan 
> acted on it. it's a disaster.
>
Saw that, what were they thinking? Nissan updated the server & app last 
month was that worldwide? Is the problem with the new system or the old 
one? Did the old software require credentials? If so, why on earth 
didn't they carry them over (I see some people have been grumbling about 
having to re-register).

I haven't looked too closely at the OVMS security other than to note RC4 
and MD5 are pretty old primitives, and I'd have to look a lot closer at 
how and why HMAC MD5 is used to comment further. I'm not up on the state 
of SMS source authentication, is it easy to spoof a source address, or 
does that really require spoofing the cell network itself which probably 
means being close to the car? I also wouldn't rule out sniffing the 
password from an SMS going over the air, but I guess that's not a threat 
we're going to face very often.

As an aside, the following python script might be useful when invoked 
like so

$ download.py https://carmanuals2.com/brand/nissan/leaf-2012-372 
https://carmanuals2.com/nissan/

#! /usr/bin/python3

from html.parser import HTMLParser
import os.path
import re
import requests
import sys

start_url = sys.argv[1]
book_parent = sys.argv[2]

def get_book(book_url):
   book_id = book_url.split("-")[-1]
   download_url = "https://carmanuals2.com/d/" + book_id
   filename = book_url[len(book_parent):] + ".pdf"
   if os.path.exists(filename):
     print("Skipping", download_url, "as", filename, "exists")
     return
   print("Saving", download_url, "to", filename)
   with open(filename, 'wb') as handle:
     r = requests.get(download_url, stream=True)

     if not r.ok:
       raise ValueError(r.response_code)

     for block in r.iter_content(1024):
         handle.write(block)

class MyHTMLParser(HTMLParser):
   def handle_starttag(self, tag, attrs):
     if tag == "a":
       book_url = list(filter(lambda x: x[0] == 'href', attrs))[0][1]
       if re.match(".*-[0-9]+$", book_url):
         if book_url.startswith(book_parent):
           print(book_url)
           get_book(book_url)

r = requests.get(start_url)
parser = MyHTMLParser()
parser.feed(r.text)

And the following terrible shell script, when run in the directory 
containing the pdf files will rename the relevant ones so they link 
together properly:

#! /bin/bash

for F in *
do
         TITLE=`pdfinfo $F | grep Title | cut -c 17-`
         if [[ $TITLE == *Config* ]]
         then
                 NAME=`echo $TITLE | cut -d '(' -f 2 | cut -d '.' -f 1`
                 echo $F $TITLE $NAME.pdf
                 mv $F $NAME.pdf
         fi
done



More information about the OvmsDev mailing list