Skip to content

Commit 95daae2

Browse files
authored
Merge branch 'christiansandberg:master' into feature-asyncio
2 parents ea7dbe5 + 52fbafb commit 95daae2

File tree

6 files changed

+74
-18
lines changed

6 files changed

+74
-18
lines changed

.github/workflows/pythonpackage.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2-
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
33

44
name: Python package
55

6-
on: [push, pull_request]
6+
on:
7+
push:
8+
branches: [ "master" ]
9+
pull_request:
10+
branches: [ "master" ]
711

812
jobs:
913
build:
1014

1115
runs-on: ubuntu-latest
1216
strategy:
17+
fail-fast: false
1318
matrix:
14-
python-version: [3.6, '3.x']
19+
python-version: ['3.x']
1520

1621
steps:
17-
- uses: actions/checkout@v2
22+
- uses: actions/checkout@v3
1823
- name: Set up Python ${{ matrix.python-version }}
19-
uses: actions/setup-python@v1
24+
uses: actions/setup-python@v3
2025
with:
2126
python-version: ${{ matrix.python-version }}
2227
- name: Install dependencies

.github/workflows/pythonpublish.yml

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,39 @@
1-
# This workflows will upload a Python Package using Twine when a release is created
2-
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
1+
# This workflow will upload a Python Package using Twine when a release is created
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
3+
4+
# This workflow uses actions that are not certified by GitHub.
5+
# They are provided by a third-party and are governed by
6+
# separate terms of service, privacy policy, and support
7+
# documentation.
38

49
name: Upload Python Package
510

611
on:
712
release:
8-
types: [created]
13+
types: [published]
14+
15+
permissions:
16+
contents: read
917

1018
jobs:
1119
deploy:
1220

1321
runs-on: ubuntu-latest
1422

1523
steps:
16-
- uses: actions/checkout@v2
24+
- uses: actions/checkout@v3
1725
- name: Set up Python
18-
uses: actions/setup-python@v1
26+
uses: actions/setup-python@v3
1927
with:
2028
python-version: '3.x'
2129
- name: Install dependencies
2230
run: |
2331
python -m pip install --upgrade pip
24-
pip install setuptools wheel build twine
25-
- name: Build and publish
26-
env:
27-
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
28-
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
29-
run: |
30-
python -m build
31-
twine upload dist/*
32+
pip install build
33+
- name: Build package
34+
run: python -m build
35+
- name: Publish package
36+
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
37+
with:
38+
user: __token__
39+
password: ${{ secrets.PYPI_API_TOKEN }}

.readthedocs.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# .readthedocs.yaml
2+
# Read the Docs configuration file
3+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4+
5+
version: 2
6+
7+
build:
8+
os: ubuntu-22.04
9+
tools:
10+
python: "3"
11+
12+
# Build documentation in the docs/ directory with Sphinx
13+
sphinx:
14+
configuration: doc/conf.py
15+
16+
# If using Sphinx, optionally build your docs in additional formats such as PDF
17+
# formats:
18+
# - pdf
19+
20+
# Optionally declare the Python requirements required to build your docs
21+
python:
22+
install:
23+
- method: pip
24+
path: .
25+
- requirements: doc/requirements.txt

canopen/node/local.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ def set_data(
113113
if check_writable and not obj.writable:
114114
raise SdoAbortedError(0x06010002)
115115

116+
# Check length matches type (length of od variable is in bits)
117+
if obj.data_type in objectdictionary.NUMBER_TYPES and (
118+
not 8 * len(data) == len(obj)
119+
):
120+
raise SdoAbortedError(0x06070010)
121+
116122
# Try callbacks
117123
for callback in self._write_callbacks:
118124
callback(index=index, subindex=subindex, od=obj, data=data)

doc/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
sphinx
2+
sphinx-autodoc-typehints

test/test_local.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,16 @@ def test_expedited_download(self):
7171
value = self.local_node.sdo[0x2004].raw
7272
self.assertEqual(value, 0xfeff)
7373

74+
def test_expedited_download_wrong_datatype(self):
75+
# Try to write 32 bit in integer16 type
76+
with self.assertRaises(canopen.SdoAbortedError) as error:
77+
self.remote_node.sdo.download(0x2001, 0x0, bytes([10, 10, 10, 10]))
78+
self.assertEqual(error.exception.code, 0x06070010)
79+
# Try to write normal 16 bit word, should be ok
80+
self.remote_node.sdo.download(0x2001, 0x0, bytes([10, 10]))
81+
value = self.remote_node.sdo.upload(0x2001, 0x0)
82+
self.assertEqual(value, bytes([10, 10]))
83+
7484
def test_segmented_download(self):
7585
self.remote_node.sdo[0x2000].raw = "Another cool device"
7686
value = self.local_node.sdo[0x2000].data

0 commit comments

Comments
 (0)