Skip to content

Add new SYSTEC interface with docu #466

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jan 7, 2019
Merged

Conversation

idaniel86
Copy link
Contributor

No description provided.

@hardbyte
Copy link
Owner

Thanks for the PR! As a heads up it can take a while to get newly contributed interfaces reviewed and merged in - although after a brief look this looks great. Not often docs come from the start!

Any how I'll try spend a few hours this weekend or next but if anyone else wants to do a code review please jump in.

@idaniel86
Copy link
Contributor Author

I have checked the failed checks. The issue is that the driver library was not installed as described in the documentation. My question is, should there be an ImportError thrown when configuration detection is executed and the library was not found? Or an empy configuration should be returned? Or?

Copy link
Owner

@hardbyte hardbyte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks good to merge once the C.I system approves.

Initializes the device with the corresponding serial or device number.

:param int or None serial: Serial number of the USB-CANmodul.
:param int device_number: Device number (0 – 254, or :const:`ANY_MODULE` for the first device).
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an encoding error here.

ucanbus.py                  35 WARNING  Cannot load SYSTEC ucan library: Non-ASCII character '\xe2' in file C:\projects\python-can\can\interfaces\systec\ucan.py on line 350, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details (ucan.py, line 349)

@staticmethod
def _detect_available_configs():
configs = {}
for index, is_used, hw_info_ex, init_info in Ucan.enumerate_hardware():
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This static method has to work even if Ucan isn't defined

@hardbyte
Copy link
Owner

Personally I like the approach in serial.py:

try:
    import serial
except ImportError:
    logger.warning("You won't be able to use the serial can backend without "
                   "the serial module installed!")
    serial = None

@codecov
Copy link

codecov bot commented Dec 24, 2018

Codecov Report

Merging #466 into develop will increase coverage by 0.58%.
The diff coverage is 67.26%.

@@             Coverage Diff             @@
##           develop     #466      +/-   ##
===========================================
+ Coverage    63.29%   63.88%   +0.58%     
===========================================
  Files           57       63       +6     
  Lines         4784     5615     +831     
===========================================
+ Hits          3028     3587     +559     
- Misses        1756     2028     +272

@idaniel86
Copy link
Contributor Author

Hi, what is the "Codecov Report"? It has something to do with unittesting?

@hardbyte
Copy link
Owner

hardbyte commented Dec 30, 2018

Yeah codecov measures how much code was executed by the ci system (travis-ci). For this PR travis ran these unit tests and pushed the code coverage to https://codecov.io/gh/hardbyte/python-can/pull/466/diff

In this case as the interface has no unittests it just shows the lines with definitions as green - i.e. what lines were imported before the except Exception as ex in ucanbus.py was triggered.

It isn't a required check before merging, just applies a gentle pressure to encourage tested code! We ensure the core of python-can is well tested, but as the interfaces are all individual contributions they are tested at different levels.

If you're willing it certainly would be better to add a few tests that don't require hardware (or the usbcan.dll). The Kvaser interface does this with mocking.

@idaniel86
Copy link
Contributor Author

idaniel86 commented Jan 3, 2019

I have tried to add tests for the interface. The interface is only for Windows platform, it fails on the CI, cause the structures use wintypes and some of them also WINFUNCTYPEs which do not exist under Linux. Any ideas how to fix this?

@idaniel86
Copy link
Contributor Author

Ok, I have added a workaround to allow the Unix based testing system use the interface for testing purposes.

@hardbyte hardbyte merged commit b2a7bde into hardbyte:develop Jan 7, 2019
@hardbyte
Copy link
Owner

hardbyte commented Jan 7, 2019

Thanks for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants