-
-
Notifications
You must be signed in to change notification settings - Fork 106
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
SocketcandMedia Media class added for socketcand functionality #306
Conversation
in init function
the old implimentation to a new one
added another error check for socketcand and CAN FD at same time
to file as well
_InterfaceParameters instead of separately in the FD and classic subclasses
This reverts commit d9f8267.
library functionality. It runs on Python-CAN like the interfaces in the PythonCANMedia class, but because it has extra variables (host and port), it is not very clean to just add socketcand to PythonCANMedia.
Hello, can't tell why the read the docs build failed. Maybe because I added new files? |
Regarding testing, it might be useful to take a look at the following forum post: https://forum.opencyphal.org/t/development-setup-pycyphal-ubuntu/1844 As it relates to your question:
(You can also select a subset of tests to be run, see link above: Section 3, Step 5) If you have any questions regarding the setup: feel free to ask them in the forum post! :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand how it's built correctly, we no longer need the _construct_socketcand handler, the classic/FD differentiation (set the fd
flag in the constructor when creating ThreadSafeBus), and the auxiliary types like PythonCANBusOptions and _InterfaceParameters. Removing these should simplify the implementation quite a bit.
Please format the code correctly using Black (more on this in CONTRIBUTING.md).
The old Yakut examples with --transport
should be removed because this is no longer the recommended usage pattern.
This fixes the unnecessary pieces left from the pythonCANMedia class, such as the FD vs Classic dataclasses, Can Bus Options, and the constructor class. It also updates the way parameters are inputed to be all in the iface_name param like 'socketcand:can:host:port'
Please try adding a simple integration test for this media implementation. You can make a new test case similar to the SocketCAN test that starts a local socketcand daemon and connects to it. |
Added unit test and changed spec string to be parsed in _transport_factory fixed formatting issues that did not pass Black guidelines Removed unecessary params S Updated version of the socketcandMedia class. This fixes the unnecessary pieces left from the pythonCANMedia class, such as the FD vs Classic dataclasses, Can Bus Options, and the constructor class. It also updates the way parameters are inputed to be all in the iface_name param like 'socketcand:can:host:port' SocketcandMedia Media class added for socketcand library functionality. It runs on Python-CAN like the interfaces in the PythonCANMedia class, but because it has extra variables (host and port), it is not very clean to just add socketcand to PythonCANMedia.
You should now be able to run the test suite by pushing a commit with the |
Test environment now properly builds and breaks down socketcand Tests use rx_a and rx_b for proper communication
Simply connect to any of the existing ones.
…On Wed, Aug 30, 2023, 03:49 wiboticanders ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In tests/transport/can/media/_socketcand.py
<#306 (comment)>:
> + if sys.platform.startswith("linux"):
+ import resource # pylint: disable=import-error
+
+ _logger.info("Limiting process memory usage to %.1f GiB", MEMORY_LIMIT / GIBIBYTE)
+ resource.setrlimit(resource.RLIMIT_AS, (MEMORY_LIMIT, MEMORY_LIMIT))
+
+ # Set up virtual SocketCAN interfaces.
+ execute("sudo", "modprobe", "can")
+ execute("sudo", "modprobe", "can_raw")
+ execute("sudo", "modprobe", "vcan")
+ execute("sudo", "ip", "link", "add", "dev", "vcan3", "type", "vcan", ensure_success=False)
+ execute("sudo", "ip", "link", "set", "vcan3", "mtu", 72) # Enable both Classic CAN and CAN FD.
+ execute("sudo", "ip", "link", "set", "up", "vcan3")
Should I change it so that it adds one more vcan instance for mine to
connect too? or simply connect to one of the ones previously instantiated
—
Reply to this email directly, view it on GitHub
<#306 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAZFIZD4D4U43L6ITNJ6E23XX2EX7ANCNFSM6AAAAAA2GWWAAM>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
These steps are highly platform-dependent so they are better moved to the
workflow file. Currently I can't even run the test on my PC because I'm
using not an APT-based distro.
…On Wed, Aug 30, 2023, 04:05 wiboticanders ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In tests/transport/can/media/_socketcand.py
<#306 (comment)>:
> + # build and install socketcand
+ execute("sudo", "apt-get", "install", "-y", "autoconf")
+ execute("git", "clone", "https://github.com/linux-can/socketcand.git")
+ execute("./autogen.sh", cwd="socketcand")
+ execute("./configure", cwd="socketcand")
+ execute("make", cwd="socketcand")
+ execute("sudo", "make", "install", cwd="socketcand")
I might be mistaken but for local testing GH workflow isn't used, and nox
is. So I think it would make more sense for me to put it in the nox file so
that it can be run. I also thought it may be possible to put it the
conftest.py file. Do you have a preference on any of these
—
Reply to this email directly, view it on GitHub
<#306 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAZFIZBUNMLGQRFXO4RYEU3XX2GV5ANCNFSM6AAAAAA2GWWAAM>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
So possibly something like this within workflow:
name: Setup socketcand
run: |
sudo apt-get install -y autoconf
git clone https://github.com/linux-can/socketcand.git
cd socketcand
./autogen.sh
./configure
make
sudo make install
shell: bash
And then within the actual unit test I can run the daemon and take it down.
On Tue, Aug 29, 2023 at 6:16 PM Pavel Kirienko ***@***.***>
wrote:
… These steps are highly platform-dependent so they are better moved to the
workflow file. Currently I can't even run the test on my PC because I'm
using not an APT-based distro.
On Wed, Aug 30, 2023, 04:05 wiboticanders ***@***.***> wrote:
> ***@***.**** commented on this pull request.
> ------------------------------
>
> In tests/transport/can/media/_socketcand.py
> <#306 (comment)>:
>
> > + # build and install socketcand
> + execute("sudo", "apt-get", "install", "-y", "autoconf")
> + execute("git", "clone", "https://github.com/linux-can/socketcand.git")
> + execute("./autogen.sh", cwd="socketcand")
> + execute("./configure", cwd="socketcand")
> + execute("make", cwd="socketcand")
> + execute("sudo", "make", "install", cwd="socketcand")
>
> I might be mistaken but for local testing GH workflow isn't used, and
nox
> is. So I think it would make more sense for me to put it in the nox file
so
> that it can be run. I also thought it may be possible to put it the
> conftest.py file. Do you have a preference on any of these
>
> —
> Reply to this email directly, view it on GitHub
> <#306 (comment)>,
> or unsubscribe
> <
https://github.com/notifications/unsubscribe-auth/AAZFIZBUNMLGQRFXO4RYEU3XX2GV5ANCNFSM6AAAAAA2GWWAAM>
> .
> You are receiving this because you were mentioned.Message ID:
> ***@***.***>
>
—
Reply to this email directly, view it on GitHub
<#306 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BA63ESEBHSL4EPSC2KR4FI3XX2H5ZANCNFSM6AAAAAA2GWWAAM>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Also modified docs of SocketcandMedia, and updated socketcandMedia test to only start the daemon instead of building socketcand, setting up a vcan, and then running the daemon, now socketcand is installed in workflow and we use an existing vcan set up previously. I also added some error handling for running the socketcand daemon and made sure to kill the process correctly
I put #test in my commit message, but it seems like it's still skipping the test and release tests. Also, assuming all works correctly in the workflow file, this should be close to a finalized and working version |
I think it should work now. |
Co-authored-by: Pavel Kirienko <[email protected]>
Commit #[00baae9] revealed an error in the breakdown when the test fails. I was going through suggestions on the github site and not locally, and I thought it was all changes to the docs, so I committed the suggestions. One slipped past me that was a change to the interface return, which in turn broke the unit test because the returns did not match anymore. The problem stems from the way I collecting stderr and stdout after the yield, the communicate function never ended. So, that commit will not stop testing until whatever timeouts you have in place stop it. My apologies for overlooking that issue and pushing it, but I can't seem to stop it with my permissions so it has been running for a few hours. |
In the previous commit it was mostly doc updates, but one changed the socketcandmedia interface_name return. I forgot to update the unit test assertions to match this, so in the CI testing it resulted in a never ending loop. The issue stemmed from the way Popen gets stderr and stdout with the communicate method, but only after the yield statement. It does not respond to the kill() and instead runs forever, so I replaced it with just a kill. Although you lose a little bit of info, the socketcand instance gets checked before the unit test is done in the fixture, and from there the daemon is very robust and will not stop unless you force kill it or terminate it. So I think this is the best solution, you still get output from errors within the unit test as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please bump the minor version number in _version.py
and drop a line in the changelog.
So new version should be 1.16.0? |
Also made small tweaks based on code change requests, removed some redundacy, slightly changed docs.
Although this runs on PythonCAN, changing the PythonCANMedia class to function with socketcand is not very clean because socketcand has 2 additional variables compared to all the other PythonCAN compatible interfaces on pycyphal.
Socketcand can be referenced here: https://github.com/linux-can/socketcand , it is used for remote CAN access of udp socket. As far as copyright goes, because this is very similar to the PythonCANMedia class and I reused code from it I believe that the copyright still applies.