Skip to content

Commit 634b920

Browse files
committed
Release 1.4.2
Includes a few fixes to the can_logger configuration. Tests that require CAN hardware are now skipped by default.
1 parent 341f027 commit 634b920

File tree

7 files changed

+20
-9
lines changed

7 files changed

+20
-9
lines changed

bin/can_logger.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import datetime
1919
import argparse
2020
import time
21+
import socket
2122

2223
import can
2324

@@ -35,7 +36,7 @@
3536

3637
parser.add_argument('-c', '--channel', help='''Most backend interfaces require some sort of channel.
3738
For example with the serial interface the channel might be a rfcomm device: "/dev/rfcomm0"
38-
With the socketcan interfaces valid channel examples include: "can0", "vcan0"''', default=can.rc['channel'])
39+
With the socketcan interfaces valid channel examples include: "can0", "vcan0"''')
3940

4041
parser.add_argument('-i', '--interface', dest="interface",
4142
help='''Specify the backend CAN interface to use. If left blank,
@@ -56,7 +57,7 @@
5657

5758
can_filters = []
5859
if len(results.filter) > 0:
59-
print('we have filter/s', results.filter)
60+
print('Adding filter/s', results.filter)
6061
for filt in results.filter:
6162
if ':' in filt:
6263
_ = filt.split(":")

can/interfaces/interface.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def __new__(cls, other, channel=None, *args, **kwargs):
2222
if can.rc['interface'] == 'socketcan':
2323
can.rc['interface'] = choose_socketcan_implementation()
2424

25-
if 'interface' not in can.rc or 'channel' not in can.rc:
25+
if 'interface' not in can.rc or 'channel' not in can.rc or can.rc['interface'] is None:
2626
can.log.debug("Loading default configuration")
2727
# Load defaults
2828
can.rc = load_config()

can/interfaces/socketcan_native.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,12 @@ def __init__(self, channel, **kwargs):
299299
socket.CAN_RAW_FILTER,
300300
struct.pack(can_filter_fmt, *filter_data),
301301
)
302+
if channel is None:
303+
# We know we are socketcan, a channel "should" have
304+
# been given but we can assume "can0"
305+
log.warn("Channel not given. Falling back to using 'can0'")
306+
channel = 'can0'
307+
302308
bindSocket(self.socket, channel)
303309
super(SocketscanNative_Bus, self).__init__()
304310

doc/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
# The short X.Y version.
6767
version = '1.4'
6868
# The full version, including alpha/beta/rc tags.
69-
release = '1.4'
69+
release = '1.4.2'
7070

7171
# The language for content autogenerated by Sphinx. Refer to documentation
7272
# for a list of supported languages.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from setuptools import setup, find_packages
66

7-
__version__ = "1.4.1"
7+
__version__ = "1.4.2"
88

99
import logging
1010
logging.basicConfig(level=logging.WARNING)

test/j1939_test.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,16 @@ def testTooLongAMessage(self):
7575
with self.assertRaises(AssertionError):
7676
j1939.PDU(arbitration_id=self.arbitration_id, data=data)
7777

78+
79+
@unittest.skipIf('interface' not in can.rc, "Need a CAN interface")
7880
class J1939BusTest(unittest.TestCase):
7981

8082
def testCreateBus(self):
8183
self.bus = j1939.Bus(channel=can_interface)
8284
self.bus.shutdown()
8385

84-
86+
@unittest.skipIf('interface' not in can.rc, "Need a CAN interface")
8587
class NetworkJ1939Test(unittest.TestCase):
86-
8788
"""
8889
8990
"""
@@ -114,6 +115,7 @@ def _testSendingLongMessage(self):
114115
sleep(0.050)
115116
self.bus.send(m)
116117

118+
@unittest.expectedFailure
117119
def testReceivingLongMessage(self):
118120

119121
data = [1, 2, 3, 4, 5, 6, 7, 8]

test/network_test.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
import can
1818

1919
channel = 'vcan0'
20-
can.rc['interface'] = 'socketcan_ctypes'
20+
#can.rc['interface'] = 'socketcan_ctypes'
2121

22-
unittest.skipIf('interface' not in can.rc, "Need a CAN interface")
22+
@unittest.skipIf('interface' not in can.rc, "Need a CAN interface")
2323
class ControllerAreaNetworkTestCase(unittest.TestCase):
2424
"""
2525
This test ensures that what messages go in to the bus is what comes out.
@@ -67,6 +67,8 @@ def _testProducer(self):
6767
self.producer()
6868
logging.debug("producer test complete")
6969

70+
71+
7072
def testProducerConsumer(self):
7173
logging.debug("testing producer/consumer")
7274
ready = threading.Event()

0 commit comments

Comments
 (0)