Skip to content

Commit 23d928e

Browse files
committed
general cleanup of the can/interfaces/*/* modules
1 parent 102be0d commit 23d928e

29 files changed

Lines changed: 307 additions & 240 deletions
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1+
#!/usr/bin/env python
2+
# coding: utf-8
3+
4+
"""
5+
"""
6+
17
from can.interfaces.ics_neovi.neovi_bus import NeoViBus

can/interfaces/ics_neovi/neovi_bus.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#!/usr/bin/env python
2+
# coding: utf-8
3+
14
"""
25
ICS NeoVi interface module.
36

can/interfaces/ixxat/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
# -*- coding: utf-8 -*-
1+
#!/usr/bin/env python
2+
# coding: utf-8
3+
24
"""
35
Ctypes wrapper module for IXXAT Virtual CAN Interface V3 on win32 systems
6+
47
Copyright (C) 2016 Giuseppe Corbelli <giuseppe.corbelli@weightpack.com>
58
"""
69

can/interfaces/ixxat/canlib.py

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
# -*- coding: utf-8 -*-
1+
#!/usr/bin/env python
2+
# coding: utf-8
3+
24
"""
35
Ctypes wrapper module for IXXAT Virtual CAN Interface V3 on win32 systems
6+
47
Copyright (C) 2016 Giuseppe Corbelli <giuseppe.corbelli@weightpack.com>
58
"""
69

@@ -12,21 +15,23 @@
1215

1316
from can import CanError, BusABC
1417
from can import Message
15-
from can.interfaces.ixxat import constants, structures
1618
from can.broadcastmanager import (LimitedDurationCyclicSendTaskABC,
1719
RestartableCyclicTaskABC)
1820
from can.ctypesutil import CLibrary, HANDLE, PHANDLE
1921

22+
from can.interfaces.ixxat import constants, structures
23+
2024
from .constants import VCI_MAX_ERRSTRLEN
2125
from .exceptions import *
2226

2327
__all__ = ["VCITimeout", "VCIError", "VCIDeviceNotFoundError", "IXXATBus", "vciFormatError"]
2428

2529
log = logging.getLogger('can.ixxat')
2630

27-
if ((sys.version_info.major == 3) and (sys.version_info.minor >= 3)):
31+
try:
32+
# since Python 3.3
2833
_timer_function = time.perf_counter
29-
else:
34+
except AttributeError:
3035
_timer_function = time.clock
3136

3237
# Hack to have vciFormatError as a free function, see below
@@ -203,18 +208,18 @@ def __check_status(result, function, arguments):
203208

204209

205210
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",
209214
}
210215

211216
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",
218223
}
219224
#----------------------------------------------------------------------------
220225

can/interfaces/ixxat/constants.py

Lines changed: 47 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,48 @@
1-
# -*- coding: utf-8 -*-
1+
#!/usr/bin/env python
2+
# coding: utf-8
3+
24
"""
35
Ctypes wrapper module for IXXAT Virtual CAN Interface V3 on win32 systems
6+
47
Copyright (C) 2016 Giuseppe Corbelli <giuseppe.corbelli@weightpack.com>
58
"""
69

7-
FALSE = 0
8-
TRUE = 1
10+
FALSE = 0
11+
TRUE = 1
912

10-
INFINITE = 0xFFFFFFFF
13+
INFINITE = 0xFFFFFFFF
1114

1215
VCI_MAX_ERRSTRLEN = 256
1316

1417
# Bitrates
15-
CAN_BT0_10KB = 0x31
16-
CAN_BT1_10KB = 0x1C
17-
CAN_BT0_20KB = 0x18
18-
CAN_BT1_20KB = 0x1C
19-
CAN_BT0_50KB = 0x09
20-
CAN_BT1_50KB = 0x1C
21-
CAN_BT0_100KB = 0x04
22-
CAN_BT1_100KB = 0x1C
23-
CAN_BT0_125KB = 0x03
24-
CAN_BT1_125KB = 0x1C
25-
CAN_BT0_250KB = 0x01
26-
CAN_BT1_250KB = 0x1C
27-
CAN_BT0_500KB = 0x00
28-
CAN_BT1_500KB = 0x1C
29-
CAN_BT0_800KB = 0x00
30-
CAN_BT1_800KB = 0x16
31-
CAN_BT0_1000KB = 0x00
32-
CAN_BT1_1000KB = 0x14
18+
CAN_BT0_10KB = 0x31
19+
CAN_BT1_10KB = 0x1C
20+
CAN_BT0_20KB = 0x18
21+
CAN_BT1_20KB = 0x1C
22+
CAN_BT0_50KB = 0x09
23+
CAN_BT1_50KB = 0x1C
24+
CAN_BT0_100KB = 0x04
25+
CAN_BT1_100KB = 0x1C
26+
CAN_BT0_125KB = 0x03
27+
CAN_BT1_125KB = 0x1C
28+
CAN_BT0_250KB = 0x01
29+
CAN_BT1_250KB = 0x1C
30+
CAN_BT0_500KB = 0x00
31+
CAN_BT1_500KB = 0x1C
32+
CAN_BT0_800KB = 0x00
33+
CAN_BT1_800KB = 0x16
34+
CAN_BT0_1000KB = 0x00
35+
CAN_BT1_1000KB = 0x14
3336

3437
# Facilities/severities
35-
SEV_INFO = 0x40000000
36-
SEV_WARN = 0x80000000
37-
SEV_ERROR = 0xC0000000
38-
SEV_MASK = 0xC0000000
39-
SEV_SUCCESS = 0x00000000
38+
SEV_INFO = 0x40000000
39+
SEV_WARN = 0x80000000
40+
SEV_ERROR = 0xC0000000
41+
SEV_MASK = 0xC0000000
42+
SEV_SUCCESS = 0x00000000
4043

41-
RESERVED_FLAG = 0x10000000
42-
CUSTOMER_FLAG = 0x20000000
44+
RESERVED_FLAG = 0x10000000
45+
CUSTOMER_FLAG = 0x20000000
4346

4447
STATUS_MASK = 0x0000FFFF
4548
FACILITY_MASK = 0x0FFF0000
@@ -102,12 +105,12 @@
102105
VCI_E_WRONG_FLASHFWVERSION = SEV_VCI_ERROR | 0x001A
103106

104107
# Controller status
105-
CAN_STATUS_TXPEND = 0x01
106-
CAN_STATUS_OVRRUN = 0x02
107-
CAN_STATUS_ERRLIM = 0x04
108-
CAN_STATUS_BUSOFF = 0x08
109-
CAN_STATUS_ININIT = 0x10
110-
CAN_STATUS_BUSCERR = 0x20
108+
CAN_STATUS_TXPEND = 0x01
109+
CAN_STATUS_OVRRUN = 0x02
110+
CAN_STATUS_ERRLIM = 0x04
111+
CAN_STATUS_BUSOFF = 0x08
112+
CAN_STATUS_ININIT = 0x10
113+
CAN_STATUS_BUSCERR = 0x20
111114

112115
# Controller operating modes
113116
CAN_OPMODE_UNDEFINED = 0x00
@@ -128,18 +131,18 @@
128131

129132
# Information supplied in the abData[0] field of info frames
130133
# (CANMSGINFO.Bytes.bType = CAN_MSGTYPE_INFO).
131-
CAN_INFO_START = 1
132-
CAN_INFO_STOP = 2
133-
CAN_INFO_RESET = 3
134+
CAN_INFO_START = 1
135+
CAN_INFO_STOP = 2
136+
CAN_INFO_RESET = 3
134137

135138
# Information supplied in the abData[0] field of info frames
136139
# (CANMSGINFO.Bytes.bType = CAN_MSGTYPE_ERROR).
137-
CAN_ERROR_STUFF = 1 # stuff error
138-
CAN_ERROR_FORM = 2 # form error
139-
CAN_ERROR_ACK = 3 # acknowledgment error
140-
CAN_ERROR_BIT = 4 # bit error
141-
CAN_ERROR_CRC = 6 # CRC error
142-
CAN_ERROR_OTHER = 7 # other (unspecified) error
140+
CAN_ERROR_STUFF = 1 # stuff error
141+
CAN_ERROR_FORM = 2 # form error
142+
CAN_ERROR_ACK = 3 # acknowledgment error
143+
CAN_ERROR_BIT = 4 # bit error
144+
CAN_ERROR_CRC = 6 # CRC error
145+
CAN_ERROR_OTHER = 7 # other (unspecified) error
143146

144147
# acceptance code and mask to reject all CAN IDs
145148
CAN_ACC_MASK_NONE = 0xFFFFFFFF

can/interfaces/ixxat/exceptions.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
# -*- coding: utf-8 -*-
1+
#!/usr/bin/env python
2+
# coding: utf-8
3+
24
"""
35
Ctypes wrapper module for IXXAT Virtual CAN Interface V3 on win32 systems
6+
47
Copyright (C) 2016 Giuseppe Corbelli <giuseppe.corbelli@weightpack.com>
58
"""
69

can/interfaces/ixxat/structures.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
# -*- coding: utf-8 -*-
1+
#!/usr/bin/env python
2+
# coding: utf-8
3+
24
"""
35
Ctypes wrapper module for IXXAT Virtual CAN Interface V3 on win32 systems
6+
47
Copyright (C) 2016 Giuseppe Corbelli <giuseppe.corbelli@weightpack.com>
58
"""
69

can/interfaces/kvaser/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1+
#!/usr/bin/env python
2+
# coding: utf-8
3+
4+
"""
5+
"""
6+
17
from can.interfaces.kvaser.canlib import *

can/interfaces/kvaser/argument_parser.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
#!/usr/bin/env python
2+
# coding: utf-8
3+
4+
"""
5+
TODO: Where is this used? Is this used?
6+
"""
17

28
def add_to_parser(parser):
39
parser.add_argument("-c", "--channel", type=str, dest="channel",

can/interfaces/kvaser/canlib.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# -*- coding: utf-8 -*-
1+
#!/usr/bin/env python
2+
# coding: utf-8
3+
24
"""
35
Contains Python equivalents of the function and constant
46
definitions in CANLIB's canlib.h, with some supporting functionality

0 commit comments

Comments
 (0)