Welcome to pyneovi’s documentation!¶
Overview¶
pyneovi is a Python wrapper around the API provided by Intrepid Control Systems for communicating with their NeoVI range of devices.
There are three layers to pyneovi and application code can be written against any of them:
- API wrapper layer. This is a Python wrapper around the API provided by ICS in their DLL/shared object. Code written against this will primarily use the neovi module, which contains the function wrappers and associated constants. Additionally, some constants are defined in the can module and structures are defined in the structures module.
- neoVI device layer. This provides a more Pythonic implementation of the API based around objects representing neoVI devices. Code written against this will primarily use the neodevice module.
- ECU layer. This shifts the focus to the devices being interacted with, providing objects representing ECUs on the network. Code written against this will primarily use the neoVI device layer to set up the interface plus the neodevice module.
The API wrapper layer and the neoVI device layer may both be used as provided. The ECU layer, however, requires additional information about the ECUs being communicated with. This may be provided by the application code directly, but it will usually be preferable to construct a “vehicle spec” file. This describes the networks provided by the vehicle, the ECUs on those networks, and the signals made available by the ECUs. ECUs and signals may then be identified by their names rather than addresses and conversion of the values read from the ECU will be performed automatically. The spec module is used to create a vehicle spec.
Submodules¶
neovi.can module¶
neovi.ecu module¶
neovi.neodevice module¶
neovi.neovi module¶
neovi.spec module¶
This module provides classes and functions to allow a network specification to be created for use with pyneovi. A network specification defines the valid networks for a given model of vehicle, along with the ECUs on those networks and the identifiers and signals made available by the ECUs.
Below is an example of a simple network specification. Only the medium speed CAN bus is defined and only a single ECU is associated with that network. The ECU provides four identifiers, each made up of a single signal.
from neovi.spec import *
from neovi.neovi import NETID_MSCAN, BitRate
import json
networks = {NETID_MSCAN: {'bitrate': BitRate.BR_125000}}
hvac_ecu = ECU(NETID_MSCAN, 0x456, 'HVAC')
hvac_identifiers = [
Identifier('Blower Speed Output', 0x9601, [Signal(units='%', m=100./255.)], READ_WRITE),
Identifier('External Ambient Temperature', 0x9628, [Signal(units='Deg C', m=0.25)], READ_WRITE),
Identifier('Left Solar Radiation Sensor', 0x9734, [Signal(units='W', m=10, max_val=1250)]),
Identifier('Cabin Temperature', 0x97A5, [Signal(units='Deg C', length=16, m=0.01, b=-100, min_val=-50, max_val=100)]),
]
ECUs = {
'HVAC': {'ecu': hvac_ecu, 'identifiers': hvac_identifiers}
}
output_file = open('vehicle.spec', 'wt')
json.dump({'networks': networks, 'ECUs': ECUs}, output_file, cls=PyNeoViJSONEncoder)
output_file.close()
-
exception
neovi.spec.
NonByteBoundarySignalError
¶ Bases:
exceptions.Exception
-
exception
neovi.spec.
ValueTooLargeError
¶ Bases:
exceptions.Exception
-
exception
neovi.spec.
UnsupportedValueTypeError
¶ Bases:
exceptions.Exception
-
neovi.spec.
prepend_zeroes
(values, final_length)¶
-
class
neovi.spec.
Signal
(self, name='value', signal_type=ANALOG, value_type=UNSIGNED_INT, start=0, length=8, min=None, max=None, units='', m=1, b=0, description='')¶ Represents a signal. An
spec.Identifier
will contain one or more signals.Parameters: - name (str) – The name of this signal.
- signal_type (int) – The type of signal. Currently, only
spec.ANALOG
is supported. - value_type (int) – The type of value returned for the signal.
Currently only
spec.UNSIGNED_INT
is supported. - start (int) – The bit within the identifier’s aggregate value at which this signal starts.
- length (int) – The length in bits of this signal.
- min_val (float) – The minimum value for this signal. This is not enforced and is for reference only. If not specified then b is used as the default value.
- max_val (float) – The minimum value for this signal. This is not enforced and is for reference only. If not specified then (255. * m) + b is used as the default value.
- units (str) – The units of the signal once converted.
- m (float) – The slope for conversion of the signal into engineering units.
- b (float) – The offset for conversion of the signal into engineering units.
- description (str) – A human-readable description of the signal.
Raises: NonByteBoundarySignalError – If length or start are not integer multiples of 8.
-
decode_signal_bytes
(signal_bytes)¶ Converts the individual data bytes into the final value for the signal.
Parameters: signal_bytes (list of ints) – The bytes received from the ECU. Returns: Tuple of final value and the units of the signal. Raises: UnsupportedValueTypeError – If the signal is of a type that is currently unsupported.
-
encode_value
(value)¶ Converts a value into the individual data bytes required for transmission.
Parameters: value (float/int) – The value for conversion.
Raises: - UnsupportedValueTypeError – If the signal is of a type that is currently unsupported.
- ValueTooLargeError – If the value does not fit into the number of bits specified for the signal.
-
class
neovi.spec.
Identifier
(self, name, data_id, signals = [], io_type = READ)¶ Represents an identifier (an example of which would be “Blower Speed Output” in a HVAC ECU). The value of an identifier can consist of multiple individual signals but often there is only a single signal associated with an identifier.
Parameters: - name (str) – The name of the identifier.
- data_id (int) – The address (internal to the ECU) with which this identifier is associated.
- signals (list of spec.Signal) – The signals that form this identifier.
- io_type (int) – Allowed IO for this identifier:
spec.READ
,spec.WRITE
,spec.READ_WRITE
.
-
get_data_id_bytes
()¶ Returns: The data_id as individual bytes. Used when constructing a message.
-
class
neovi.spec.
ECU
(network, address, short_desc='', long_desc='')¶ Represents an ECU for the purpose of building a network specification. Note that if you need an object that allows you to communicate with the ECU then you’re looking for
ecu.ECU
.Parameters: - network (int) – The network to transmit on. See NETID_* in
neovi
. - address (int) – The address of the ECU.
- short_desc (str) – A short name for the ECU (e.g. “HVAC”).
- long_desc (str) – A long description for the ECU (e.g. including model number or other information).
-
get_network
()¶
-
get_request_id
()¶
-
get_response_id
()¶
- network (int) – The network to transmit on. See NETID_* in
-
class
neovi.spec.
PyNeoViJSONEncoder
(skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, encoding='utf-8', default=None)¶ Bases:
json.encoder.JSONEncoder
Can be passed to json.dump as the cls parameter to handle the additional object types defined here.
-
default
(o)¶
-
-
neovi.spec.
from_json
(json_object)¶ Can be passed to json.load as the object_hook parameter to handle the additional object types defined here.
neovi.structures module¶
- Classes provided by this module:
-
neovi.structures.
array_equal
(a1, a2)¶
-
neovi.structures.
format_array
(array)¶
-
neovi.structures.
get_status_bits_set
(msg)¶
-
class
neovi.structures.
NeoDevice
¶ Bases:
_ctypes.Structure
-
DeviceType
¶ Structure/Union member
-
Handle
¶ Structure/Union member
-
MaxAllowedClients
¶ Structure/Union member
-
NumberOfClients
¶ Structure/Union member
-
SerialNumber
¶ Structure/Union member
-
-
class
neovi.structures.
icsSpyMessage
¶ Bases:
_ctypes.Structure
-
AckBytes
¶ Structure/Union member
-
ArbIDOrHeader
¶ Structure/Union member
-
ColorID
¶ Structure/Union member
-
Data
¶ Structure/Union member
-
DescriptionID
¶ Structure/Union member
-
MessagePieceID
¶ Structure/Union member
-
MiscData
¶ Structure/Union member
-
NetworkID
¶ Structure/Union member
-
NodeID
¶ Structure/Union member
-
NumberBytesData
¶ Structure/Union member
-
NumberBytesHeader
¶ Structure/Union member
-
Protocol
¶ Structure/Union member
-
StatusBitField
¶ Structure/Union member
-
StatusBitField2
¶ Structure/Union member
-
TimeHardware
¶ Structure/Union member
-
TimeHardware2
¶ Structure/Union member
-
TimeStampHardwareID
¶ Structure/Union member
-
TimeStampSystemID
¶ Structure/Union member
-
TimeSystem
¶ Structure/Union member
-
TimeSystem2
¶ Structure/Union member
-
Value
¶ Structure/Union member
-
-
class
neovi.structures.
spyFilterLong
¶ Bases:
_ctypes.Structure
-
ByteDataLSB
¶ Structure/Union member
-
ByteDataLength
¶ Structure/Union member
-
ByteDataMSB
¶ Structure/Union member
-
ByteDataMaskLSB
¶ Structure/Union member
-
ByteDataMaskMSB
¶ Structure/Union member
-
ExpectedLength
¶ Structure/Union member
-
FrameMaster
¶ Structure/Union member
-
Header
¶ Structure/Union member
-
HeaderLength
¶ Structure/Union member
-
HeaderMask
¶ Structure/Union member
-
MiscData
¶ Structure/Union member
-
MiscDataMask
¶ Structure/Union member
-
NetworkID
¶ Structure/Union member
-
NodeID
¶ Structure/Union member
-
Status2Mask
¶ Structure/Union member
-
Status2Value
¶ Structure/Union member
-
StatusMask
¶ Structure/Union member
-
StatusValue
¶ Structure/Union member
-
bStuff2
¶ Structure/Union member
-
bUseArbIdRangeFilter
¶ Structure/Union member
-
-
class
neovi.structures.
CAN_SETTINGS
¶ Bases:
_ctypes.Structure
-
BRP
¶ Structure/Union member
-
Baudrate
¶ Structure/Union member
-
Mode
¶ Structure/Union member
-
NetworkType
¶ Structure/Union member
-
SetBaudrate
¶ Structure/Union member
-
TqProp
¶ Structure/Union member
-
TqSeg1
¶ Structure/Union member
-
TqSeg2
¶ Structure/Union member
-
TqSync
¶ Structure/Union member
-
auto_baud
¶ Structure/Union member
-
-
class
neovi.structures.
SWCAN_SETTINGS
¶ Bases:
_ctypes.Structure
-
BRP
¶ Structure/Union member
-
Baudrate
¶ Structure/Union member
-
Mode
¶ Structure/Union member
-
NetworkType
¶ Structure/Union member
-
SetBaudrate
¶ Structure/Union member
-
TqProp
¶ Structure/Union member
-
TqSeg1
¶ Structure/Union member
-
TqSeg2
¶ Structure/Union member
-
TqSync
¶ Structure/Union member
-
auto_baud
¶ Structure/Union member
-
high_speed_auto_switch
¶ Structure/Union member
-
-
class
neovi.structures.
LIN_SETTINGS
¶ Bases:
_ctypes.Structure
-
Baudrate
¶ Structure/Union member
-
MasterResistor
¶ Structure/Union member
-
Mode
¶ Structure/Union member
-
brgh
¶ Structure/Union member
-
spbrg
¶ Structure/Union member
-
-
class
neovi.structures.
ISO9141_KEYWORD2000__INIT_STEP
¶ Bases:
_ctypes.Structure
-
k
¶ Structure/Union member
-
l
¶ Structure/Union member
-
time_500us
¶ Structure/Union member
-
-
class
neovi.structures.
ISO9141_KEYWORD2000_SETTINGS
¶ Bases:
_ctypes.Structure
-
Baudrate
¶ Structure/Union member
-
brgh
¶ Structure/Union member
-
chksum_enabled
¶ Structure/Union member
-
init_step_count
¶ Structure/Union member
-
init_steps
¶ Structure/Union member
-
p2_500us
¶ Structure/Union member
-
p3_500us
¶ Structure/Union member
-
p4_500us
¶ Structure/Union member
-
spbrg
¶ Structure/Union member
-
-
class
neovi.structures.
UART_SETTINGS
¶ Bases:
_ctypes.Structure
-
Baudrate
¶ Structure/Union member
-
bOptions
¶ Structure/Union member
-
brgh
¶ Structure/Union member
-
flow_control
¶ Structure/Union member
-
parity
¶ Structure/Union member
-
reserved_1
¶ Structure/Union member
-
spbrg
¶ Structure/Union member
-
stop_bits
¶ Structure/Union member
-
-
class
neovi.structures.
STextAPISettings
¶ Bases:
_ctypes.Structure
-
Reserved0
¶ Structure/Union member
-
Reserved1
¶ Structure/Union member
-
Reserved2
¶ Structure/Union member
-
Reserved3
¶ Structure/Union member
-
Reserved4
¶ Structure/Union member
-
can1_options
¶ Structure/Union member
-
can1_rx_id
¶ Structure/Union member
-
can1_tx_id
¶ Structure/Union member
-
can2_options
¶ Structure/Union member
-
can2_rx_id
¶ Structure/Union member
-
can2_tx_id
¶ Structure/Union member
-
can3_options
¶ Structure/Union member
-
can3_rx_id3
¶ Structure/Union member
-
can3_tx_id3
¶ Structure/Union member
-
can4_options
¶ Structure/Union member
-
can4_rx_id4
¶ Structure/Union member
-
can4_tx_id4
¶ Structure/Union member
-
network_enables
¶ Structure/Union member
-
-
class
neovi.structures.
SFireSettings
¶ Bases:
_ctypes.Structure
-
ain_sample_period
¶ Structure/Union member
-
ain_threshold
¶ Structure/Union member
-
can1
¶ Structure/Union member
-
can2
¶ Structure/Union member
-
can3
¶ Structure/Union member
-
can4
¶ Structure/Union member
-
cgi_baud
¶ Structure/Union member
-
cgi_chksum_enable
¶ Structure/Union member
-
cgi_enable_reserved
¶ Structure/Union member
-
cgi_rx_ifs_bit_times
¶ Structure/Union member
-
cgi_tx_ifs_bit_times
¶ Structure/Union member
-
fast_init_network_enables_1
¶ Structure/Union member
-
fast_init_network_enables_2
¶ Structure/Union member
-
iso15765_separation_time_offset
¶ Structure/Union member
-
iso9141_kwp_enable_reserved
¶ Structure/Union member
-
iso9141_kwp_settings
¶ Structure/Union member
-
iso9141_kwp_settings2
¶ Structure/Union member
-
iso9141_kwp_settings_3
¶ Structure/Union member
-
iso9141_kwp_settings_4
¶ Structure/Union member
-
iso_msg_termination
¶ Structure/Union member
-
iso_msg_termination_2
¶ Structure/Union member
-
iso_msg_termination_3
¶ Structure/Union member
-
iso_msg_termination_4
¶ Structure/Union member
-
iso_parity
¶ Structure/Union member
-
iso_parity_2
¶ Structure/Union member
-
iso_parity_3
¶ Structure/Union member
-
iso_parity_4
¶ Structure/Union member
-
iso_tester_pullup_enable
¶ Structure/Union member
-
lin1
¶ Structure/Union member
-
lin2
¶ Structure/Union member
-
lin3
¶ Structure/Union member
-
lin4
¶ Structure/Union member
-
lsftcan
¶ Structure/Union member
-
misc_io_analog_enable
¶ Structure/Union member
-
misc_io_initial_ddr
¶ Structure/Union member
-
misc_io_initial_latch
¶ Structure/Union member
-
misc_io_on_report_events
¶ Structure/Union member
-
misc_io_report_period
¶ Structure/Union member
-
network_enabled_on_boot
¶ Structure/Union member
-
network_enables
¶ Structure/Union member
-
network_enables_2
¶ Structure/Union member
-
perf_en
¶ Structure/Union member
-
pwm_man_timeout
¶ Structure/Union member
-
pwr_man_enable
¶ Structure/Union member
-
swcan
¶ Structure/Union member
-
text_api
¶ Structure/Union member
-
uart
¶ Structure/Union member
-
uart2
¶ Structure/Union member
-
-
class
neovi.structures.
SVCAN3Settings
¶ Bases:
_ctypes.Structure
-
can1
¶ Structure/Union member
-
can2
¶ Structure/Union member
-
iso15765_separation_time_offset
¶ Structure/Union member
-
misc_io_initial_ddr
¶ Structure/Union member
-
misc_io_initial_latch
¶ Structure/Union member
-
misc_io_on_report_events
¶ Structure/Union member
-
misc_io_report_period
¶ Structure/Union member
-
network_enabled_on_boot
¶ Structure/Union member
-
network_enables
¶ Structure/Union member
-
perf_en
¶ Structure/Union member
-
-
class
neovi.structures.
APIFirmwareInfo
¶ Bases:
_ctypes.Structure
-
iAppMajor
¶ Structure/Union member
-
iAppMinor
¶ Structure/Union member
-
iBoardRevMajor
¶ Structure/Union member
-
iBoardRevMinor
¶ Structure/Union member
-
iBootLoaderVersionMajor
¶ Structure/Union member
-
iBootLoaderVersionMinor
¶ Structure/Union member
-
iMainFirmChkSum
¶ Structure/Union member
-
iMainFirmDateDay
¶ Structure/Union member
-
iMainFirmDateHour
¶ Structure/Union member
-
iMainFirmDateMin
¶ Structure/Union member
-
iMainFirmDateMonth
¶ Structure/Union member
-
iMainFirmDateSecond
¶ Structure/Union member
-
iMainFirmDateYear
¶ Structure/Union member
-
iManufactureDay
¶ Structure/Union member
-
iManufactureMonth
¶ Structure/Union member
-
iManufactureYear
¶ Structure/Union member
-
iType
¶ Structure/Union member
-