23

I'm experimenting with the BMW Java SDK on the new BMW 116i Innovation Package. Basic things like turning the lights on and off, starting and stopping the motor work fine. What I'm trying to do now is that to write a carlet which would limit the speed to the maximum configured in the driver profile. Driver identity will be detected as usual via RFID reader.

My problem is that though I can read the speed from the tachometer, I can't really limit the speed. Here's what I've got working so far:

public class SpeenControllingCarlet extends GenericCarlet {

    public void start(final VehicleModel model) throws CarletException {
        RfidReader rfidReader = (RfidReader) model
                .getDevice(Devices.DRIVER_RFID_READER);
        Rfid rfid = rfidReader.getRfid();
        DriverProfile driverProfile = model.getDriverProfileRegistry()
                .getDriverProfile(rfid.toString());
        if (driverProfile == null) {
            return;
        }
        final Double maxAllowedSpeed = Double.valueOf(driverProfile
                .getCustomAttribute("maxAllowedSpeed", "190"));
        Tachometer tachometer = (Tachometer) mode.getDevice(Devices.TACHOMETER);
        tachometer.addSpeedListener(new SpeedListener() {
            public void onSpeedChanged(SpeedChangedEvent speedChangedEvent) {
                if (speedChangedEvent.getCurrentSpeed() > maxAllowedSpeed)
                {
                    Horn horn = (Horn) mode.getDevice(Devices.HORN);
                    horn.beep(440, 2000);
                }

            }
        });
    }
}

This will just beep for two seconds if the driver goes faster than the driver profile allows.

My question is - is there a possibility to actually limit the speed (not just silly beeping)?

lexicore
  • 39,549
  • 12
  • 108
  • 193
  • If this isn't an April Fool's joke, my next car must be JSDK-enabled! – Daniel Vassallo Apr 01 '10 at 00:33
  • 1
    I almost flagged this for deletion, being as we're so close to April 1st (the day the internet turns useless). But, according to http://java.sun.com/developer/technicalArticles/J2ME/TLA.html, apparently there actually is a Java SDK for BMWs. – Will Hartung Apr 01 '10 at 00:37
  • @Will Hartung There is a Java SDK for BMW, but it only allows to control media and positioning devices. – Vladimir Dyuzhev Apr 01 '10 at 00:39
  • 1
    It only allows control of positioning devices -- like the steering wheel? – Gabe Apr 01 '10 at 00:49

4 Answers4

9

How do you slow down using the imperfect human? You brake! Same with BMW SDK:

Brake brake = (Brake) mode.getDevice(Devices.BRAKE);
brake.apply(Brake.TO_THE_METAL);
Jeremy
  • 1
  • 77
  • 324
  • 346
Vladimir Dyuzhev
  • 17,603
  • 9
  • 45
  • 61
7
Wrench wrench = (Wrench) Toolkit.getToolkit().get(Instruments.WRENCH);
wrench.hit(driver);
Pops
  • 28,257
  • 34
  • 127
  • 149
mvmn
  • 2,693
  • 21
  • 28
3

I think (and hope) that this is very likely not possible, and the reasons are that car manufacturers would be in a lot of legal trouble if they allowed "non-core" gadgets like a JVM built into the entertainment/navigation system to interfere with the motor or steering controls. That is a much worse security risk than your average browser exploit.

Fly-by-wire cars are scary enough as it is without end-user/hacker accessible parts.

Thilo
  • 241,635
  • 91
  • 474
  • 626
  • 1
    Third-party tuning requires a special allowance (so-called Bauartgenehmigung/Betriebserlaubnis) and additional insurance. BMW has nothing to do with this. – lexicore Apr 01 '10 at 00:57
  • 1
    Yeah... "botnet" may get the whole new exciting meaning... %) – Vladimir Dyuzhev Apr 01 '10 at 00:58
  • 1
    I think this is a little more (worse) than traditional tuning. I hope that the JVM is not even physically connected to devices that would allow braking or steering. Tuning/hacking aside, if it was, a software bug could cause horrible trouble. I believe that the factory set speed limit (270) must be enforced by motor-internal electronics, a completely separate system from this JVM. Those electronics may be tunable with the right gear, but that is a separate issue. – Thilo Apr 01 '10 at 01:04
3

Your big problem is that you're not taking the current gear ratio into account when you get the engine speed. You're looking at a speed of like 190, while the tach is going to return somewhere between 700 and 7000. You need a function that takes engine RPMs, gear ratio, and tire diameter, and returns actual speed.

Or you could get the car's speed from the speedometer or GPS.

Gabe
  • 79,868
  • 10
  • 131
  • 226
  • 2
    They have German terminology in the API. Tachometer is for speed, engine rotation rate is called RevCounter. – lexicore Apr 01 '10 at 01:05