##
# ecutools: IoT Automotive Tuning, Diagnostics & Analytics
# Copyright (C) 2014 Jeremy Hahn
#
# This program 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 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

module Ecutools
  class J2534Error < StandardError; end
end

module Ecutools::J2534::Error

  STATUS_NOERROR                  = 0x00000000
  ERR_NOT_SUPPORTED               = 0x00000001
  ERR_INVALID_CHANNEL_ID          = 0x00000002
  ERR_PROTOCOL_ID_NOT_SUPPORTED   = 0x00000003
  ERR_NULL_PARAMETER              = 0x00000004
  ERR_IOCTL_VALUE_NOT_SUPPORTED   = 0x00000005
  ERR_FLAG_NOT_SUPPORTED          = 0x00000006
  ERR_FAILED                      = 0x00000007
  ERR_DEVICE_NOT_CONNECTED        = 0x00000008
  ERR_TIMEOUT                     = 0x000000
  ERR_INVALID_MSG                 = 0x0000000A
  ERR_TIME_INTERVAL_NOT_SUPPORTED = 0x0000000B
  ERR_EXCEEDED_LIMIT              = 0x0000000C
  ERR_INVALID_MSG_ID              = 0x0000000D
  ERR_DEVICE_IN_USE               = 0x0000000E
  ERR_IOCTL_ID_NOT_SUPPORTED      = 0x0000000F
  ERR_BUFFER_EMPTY                = 0x00000010
  ERR_BUFFER_FULL                 = 0x00000011
  ERR_BUFFER_OVERFLOW             = 0x00000012
  ERR_PIN_NOT_SUPPORTED           = 0x00000013
  ERR_RESOURCE_CONFLICT           = 0x00000014
  ERR_MSG_PROTOCOL_ID             = 0x00000015
  ERR_INVALID_FILTER_ID           = 0x00000016
  ERR_MSG_NOT_ALLOWED             = 0x00000017
  ERR_NOT_UNIQUE                  = 0x00000018
  ERR_BAUDRATE_NOT_SUPPORTED      = 0x00000019
  ERR_INVALID_DEVICE_ID           = 0x0000001A
  ERR_DEVICE_NOT_OPEN             = 0x0000001B
  ERR_NULL_REQUIRED               = 0x0000001C
  ERR_FILTER_TYPE_NOT_SUPPORTED   = 0x0000001D
  ERR_IOCTL_PARAM_ID_NOT_SUPPORTED= 0x0000001E
  ERR_VOLTAGE_IN_USE              = 0x0000001F
  ERR_PIN_IN_USE                  = 0x00000020
  ERR_INIT_FAILED                 = 0x00000021
  ERR_OPEN_FAILED                 = 0x00000022
  ERR_BUFFER_TOO_SMALL            = 0x00000023
  ERR_LOG_CHAN_NOT_ALLOWED        = 0x00000024
  ERR_SELECT_TYPE_NOT_SUPPORTED   = 0x00000025
  ERR_CONCURRENT_API_CALL         = 0x00000026

  ERROR = {
    STATUS_NOERROR => 'STATUS_NOERROR',
    ERR_NOT_SUPPORTED => 'ERR_NOT_SUPPORTED',
    ERR_INVALID_CHANNEL_ID => 'ERR_INVALID_CHANNEL_ID',
    ERR_PROTOCOL_ID_NOT_SUPPORTED => 'ERR_PROTOCOL_ID_NOT_SUPPORTED',
    ERR_NULL_PARAMETER => 'ERR_NULL_PARAMETER',
    ERR_IOCTL_VALUE_NOT_SUPPORTED => 'ERR_IOCTL_VALUE_NOT_SUPPORTED',
    ERR_FLAG_NOT_SUPPORTED => 'ERR_FLAG_NOT_SUPPORTED',
    ERR_FAILED => 'ERR_FAILED',
    ERR_DEVICE_NOT_CONNECTED => 'ERR_DEVICE_NOT_CONNECTED',
    ERR_TIMEOUT   => 'ERR_TIMEOUT',
    ERR_INVALID_MSG => 'ERR_INVALID_MSG',
    ERR_TIME_INTERVAL_NOT_SUPPORTED => 'ERR_TIME_INTERVAL_NOT_SUPPORTED',
    ERR_EXCEEDED_LIMIT => 'ERR_EXCEEDED_LIMIT',
    ERR_INVALID_MSG_ID => 'ERR_INVALID_MSG_ID',
    ERR_DEVICE_IN_USE => 'ERR_DEVICE_IN_USE',
    ERR_IOCTL_ID_NOT_SUPPORTED => 'ERR_IOCTL_ID_NOT_SUPPORTED',
    ERR_BUFFER_EMPTY => 'ERR_BUFFER_EMPTY',
    ERR_BUFFER_FULL => 'ERR_BUFFER_FULL',
    ERR_BUFFER_OVERFLOW => 'ERR_BUFFER_OVERFLOW',
    ERR_PIN_NOT_SUPPORTED => 'ERR_PIN_NOT_SUPPORTED',
    ERR_RESOURCE_CONFLICT => 'ERR_RESOURCE_CONFLICT',
    ERR_MSG_PROTOCOL_ID => 'ERR_MSG_PROTOCOL_ID',
    ERR_INVALID_FILTER_ID => 'ERR_INVALID_FILTER_ID',
    ERR_MSG_NOT_ALLOWED => 'ERR_MSG_NOT_ALLOWED',
    ERR_NOT_UNIQUE => 'ERR_NOT_UNIQUE',
    ERR_BAUDRATE_NOT_SUPPORTED => 'ERR_BAUDRATE_NOT_SUPPORTED',
    ERR_INVALID_DEVICE_ID => 'ERR_INVALID_DEVICE_ID',
    ERR_DEVICE_NOT_OPEN => 'ERR_DEVICE_NOT_OPEN',
    ERR_NULL_REQUIRED => 'ERR_NULL_REQUIRED',
    ERR_FILTER_TYPE_NOT_SUPPORTED => 'ERR_FILTER_TYPE_NOT_SUPPORTED',
    ERR_IOCTL_PARAM_ID_NOT_SUPPORTED => 'ERR_IOCTL_PARAM_ID_NOT_SUPPORTED',
    ERR_VOLTAGE_IN_USE => 'ERR_VOLTAGE_IN_USE',
    ERR_PIN_IN_USE => 'ERR_PIN_IN_USE',
    ERR_INIT_FAILED => 'ERR_INIT_FAILED',
    ERR_OPEN_FAILED => 'ERR_OPEN_FAILED',
    ERR_BUFFER_TOO_SMALL => 'ERR_BUFFER_TOO_SMALL',
    ERR_LOG_CHAN_NOT_ALLOWED => 'ERR_LOG_CHAN_NOT_ALLOWED',
    ERR_SELECT_TYPE_NOT_SUPPORTED => 'ERR_SELECT_TYPE_NOT_SUPPORTED',
    ERR_CONCURRENT_API_CALL => 'ERR_CONCURRENT_API_CALL'
  }

  def self.[](key)
    ERROR[key]
  end
end
