|
1 | | -# -*- coding: utf-8 -*- |
| 1 | +#!/usr/bin/env python |
| 2 | +# coding: utf-8 |
| 3 | + |
2 | 4 | """ |
3 | 5 | Ctypes wrapper module for IXXAT Virtual CAN Interface V3 on win32 systems |
| 6 | +
|
4 | 7 | Copyright (C) 2016 Giuseppe Corbelli <giuseppe.corbelli@weightpack.com> |
5 | 8 | """ |
6 | 9 |
|
|
12 | 15 |
|
13 | 16 | from can import CanError, BusABC |
14 | 17 | from can import Message |
15 | | -from can.interfaces.ixxat import constants, structures |
16 | 18 | from can.broadcastmanager import (LimitedDurationCyclicSendTaskABC, |
17 | 19 | RestartableCyclicTaskABC) |
18 | 20 | from can.ctypesutil import CLibrary, HANDLE, PHANDLE |
19 | 21 |
|
| 22 | +from can.interfaces.ixxat import constants, structures |
| 23 | + |
20 | 24 | from .constants import VCI_MAX_ERRSTRLEN |
21 | 25 | from .exceptions import * |
22 | 26 |
|
23 | 27 | __all__ = ["VCITimeout", "VCIError", "VCIDeviceNotFoundError", "IXXATBus", "vciFormatError"] |
24 | 28 |
|
25 | 29 | log = logging.getLogger('can.ixxat') |
26 | 30 |
|
27 | | -if ((sys.version_info.major == 3) and (sys.version_info.minor >= 3)): |
| 31 | +try: |
| 32 | + # since Python 3.3 |
28 | 33 | _timer_function = time.perf_counter |
29 | | -else: |
| 34 | +except AttributeError: |
30 | 35 | _timer_function = time.clock |
31 | 36 |
|
32 | 37 | # Hack to have vciFormatError as a free function, see below |
@@ -203,18 +208,18 @@ def __check_status(result, function, arguments): |
203 | 208 |
|
204 | 209 |
|
205 | 210 | CAN_INFO_MESSAGES = { |
206 | | - constants.CAN_INFO_START: "CAN started", |
207 | | - constants.CAN_INFO_STOP: "CAN stopped", |
208 | | - constants.CAN_INFO_RESET: "CAN reset", |
| 211 | + constants.CAN_INFO_START: "CAN started", |
| 212 | + constants.CAN_INFO_STOP: "CAN stopped", |
| 213 | + constants.CAN_INFO_RESET: "CAN reset", |
209 | 214 | } |
210 | 215 |
|
211 | 216 | CAN_ERROR_MESSAGES = { |
212 | | - constants.CAN_ERROR_STUFF: "CAN bit stuff error", |
213 | | - constants.CAN_ERROR_FORM: "CAN form error", |
214 | | - constants.CAN_ERROR_ACK: "CAN acknowledgment error", |
215 | | - constants.CAN_ERROR_BIT: "CAN bit error", |
216 | | - constants.CAN_ERROR_CRC: "CAN CRC error", |
217 | | - constants.CAN_ERROR_OTHER: "Other (unknown) CAN error", |
| 217 | + constants.CAN_ERROR_STUFF: "CAN bit stuff error", |
| 218 | + constants.CAN_ERROR_FORM: "CAN form error", |
| 219 | + constants.CAN_ERROR_ACK: "CAN acknowledgment error", |
| 220 | + constants.CAN_ERROR_BIT: "CAN bit error", |
| 221 | + constants.CAN_ERROR_CRC: "CAN CRC error", |
| 222 | + constants.CAN_ERROR_OTHER: "Other (unknown) CAN error", |
218 | 223 | } |
219 | 224 | #---------------------------------------------------------------------------- |
220 | 225 |
|
|
0 commit comments