//
// Copyright (c) 1999-2004 Darius Rad
//
// This file is part of the OpenOtto project.
//
// OpenOtto is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//

/// \file
/// \brief OBD2 address manipulation routines


#include <linux/types.h>
#include <assert.h>

#include <otto/packet.h>


static const char _ID_[] __attribute__ ((unused)) =
"$Id: adr.c,v 1.6 2004/07/05 23:25:06 alpha Exp $";


int
otto_physical_adr_lookup(
  unsigned char adr,
  char *desc,
  size_t size
)
{
  assert(desc != NULL);

  if( /*(adr >= 0x00) &&*/ (adr <= 0x0f) ) {
    // Powertrain; integration/manufacturer expansion
  } else if( (adr >= 0x10) && (adr <= 0x17) ) {
    // Engine controllers
  } else if( (adr >= 0x18) && (adr <= 0x1f) ) {
    // Transmission controllers
  } else if( (adr >= 0x20) && (adr <= 0x27) ) {
    // Chassis; integration/manufacturer expansion
  } else if( (adr >= 0x28) && (adr <= 0x2f) ) {
    // Brake controllers
  } else if( (adr >= 0x30) && (adr <= 0x37) ) {
    // Steering controllers
  } else if( (adr >= 0x38) && (adr <= 0x3f) ) {
    // Suspension controllers
  } else if( (adr >= 0x40) && (adr <= 0x57) ) {
    // Body; integration/manufacturer expansion
  } else if( (adr >= 0x58) && (adr <= 0x5f) ) {
    // Restraints
  } else if( (adr >= 0x60) && (adr <= 0x6f) ) {
    // Driver information/displays
  } else if( (adr >= 0x70) && (adr <= 0x7f) ) {
    // Lighting
  } else if( (adr >= 0x80) && (adr <= 0x8f) ) {
    // Entertainmen/audio
  } else if( (adr >= 0x90) && (adr <= 0x97) ) {
    // Personal communications
  } else if( (adr >= 0x98) && (adr <= 0x9f) ) {
    // Climate control (HVAC)
  } else if( (adr >= 0xa0) && (adr <= 0xbf) ) {
    // Convenience (doors, seats, windows, etc.)
  } else if( (adr >= 0xc0) && (adr <= 0xc7) ) {
    // Security
  } else if( adr == 0xc8 ) {
    // Utility connection services (FN#1)
  } else if( adr == 0xc9 ) {
    // AC to AC conversion (FN#2)
  } else if( adr == 0xca ) {
    // AC to DC conversion (FN#3)
  } else if( adr == 0xcb ) {
    // Energy storage management (FN#4)
  } else if( (adr >= 0xcc) && (adr <= 0xcf) ) {
    // Future expansion
  } else if( (adr >= 0xd0) && (adr <= 0xef) ) {
    // Manufacturer specific
  } else if( (adr >= 0xf0) && (adr <= 0xfd) ) {
    // Off-board testers/diagnostic toos
  } else if( adr == 0xfe ) {
    // All nodes
  } else if( adr == 0xff ) {
    // Null node
  }

  return(0);
}     


