[Plugin] USB_Manager/USBIP commands and GUI


SimonF

Recommended Posts

OK - some progress - rebooted and I can now start my VMs but getting:

 

Quote

Following are missing or not loaded: usbip_host module vhci_hcd module.

 

Given that I thought hook edits where automatic now I did not expect this so need to do some further reading (unless some one has a quick answer ?).

 

T

Link to comment
Posted (edited)
3 minutes ago, ccsnet said:

OK - some progress - rebooted and I can now start my VMs but getting:

 

 

Given that I thought hook edits where automatic now I did not expect this so need to do some further reading (unless some one has a quick answer ?).

 

T

Which plugin are you using. Only USB manager auto adds.

 

Do you need the usbip functions? Those messages are not for the hooks file.

Edited by SimonF
Link to comment
3 minutes ago, SimonF said:

Which plugin are you using. Only USB manager auto adds.

 

Do you need the usbip functions?

 

Hi - thanks for coming back to me - USB Manager only as I do not need the IP features.

 

Enable USB on Dashboard and Enable USB Manager Hotplug on VM page are enabled. 

 

Enable USBIP is disabled however I have played with the settings before hand.

 

T

Edited by ccsnet
Link to comment
Posted (edited)
2 minutes ago, ccsnet said:

 

Hi - thanks for coming back to me - USB Manager only as I do not need the IP features.

 

T

Change to enable usbip to disable in settings and those messages will disappear.

image.png.e870703135b3785204834ea2c53053cd.pngcontent://com.android.chrome.FileProvider/images/screenshot/16271305008562117425920.png

Edited by SimonF
Link to comment

Hi Simon - thanks... I found that a reboot was also needed to remove the messages which might have been the bit throwing me off.

 

Thanks again for jumping in to help.

 

Terran

 

PS Love the photo - MK based ?

Link to comment
45 minutes ago, ccsnet said:

Hi @SimonF - one last question - is it possible to map the same USB device to two VMs ie so I can have multiple VMs but shut one down for another and it knows to auto connect eg keyboards and mice ?

 

T

Not possible to have two device maps but you can have one Dev and one port map. Dev is actioned first and they can be for diff vms

Link to comment
Posted (edited)
5 hours ago, ccsnet said:

Hi @SimonF - one last question - is it possible to map the same USB device to two VMs ie so I can have multiple VMs but shut one down for another and it knows to auto connect eg keyboards and mice ?

 

T

I wasn't able to do a screen grab earlier of an example

 

Here is an example of a Ubuntu and Window 10 machines.

 

image.thumb.png.15938c066b65db58e7f971d678020f6d.png

Edited by SimonF
Link to comment
43 minutes ago, SimonF said:

I wasn't able to do a screen grab earlier of an example

 

Here is an example of a Ubuntu and Window 10 machines.

 

image.thumb.png.15938c066b65db58e7f971d678020f6d.png

Thanks @SimonF - really happy with this plug in... well done.

 

T

Link to comment
  • 2 weeks later...

Hi there,

 

I'm very happy about your plugin as I requested usbip 2 years ago ;-)

I can manually connect my device to the unraid server (conected to an RPi with an USB-Serial Adapter) and use it within a docker container.

But I need to configure the USB Port in UNRAID via "stty" before using it.

Long story short .. Is there a way to "mount" that usb device --> configure the ttyUSB device --> start the docker container in that order automatically ?

 

THX

Link to comment
7 hours ago, batesman73 said:

mount

When you say mount do you mean attach button on remote USBIP hosts.

 

Once the dev is attached you could use a udev rule to do the other actions. I could look at an option to run a script when a new device is detected/removed as a future enhancement. 

 

Also can look at an option to auto attach if found.

Link to comment

Hi.

 

thanks for the response.

"mount" does, of course, mean attaching the device.

You're right, UDEV could help to init the configuration. But I still need to attach the device on boot (or start of array/dockers).

I didn't see that option, or is there one.

I think most people using usbip would love to have this option. I belive the most coomon use case would be a usb device connected to RPi (or similar) which ist constantly running and connect it to a server in the closet or basement.

For now I think i will create two scripts for boot and shutdown.

Link to comment
4 hours ago, batesman73 said:

I didn't see that option, or is there one.

There is currently no option. Will have to look at a process to check every x mins as there will not be a event to trigger.

 

Running a process when connected will be more straight forward as I already use udev for the usb devices

 

Not able to look until the weekend.

Link to comment

Hi,

 

it's currently almost running with my 2 scripts.

But if you would include some of the needed steps as described I would appreciate that ;-)

 

Altough it's not related to USBiP ...

One thing I currently don't know is how to change user permissions inside the container for that USB-Device which is mapped inside. Of course I can log into the container and enter CHMOD. But ho can I do that automatically ?

Any hints ?

Link to comment
4 minutes ago, batesman73 said:

Hi,

 

it's currently almost running with my 2 scripts.

But if you would include some of the needed steps as described I would appreciate that ;-)

 

Altough it's not related to USBiP ...

One thing I currently don't know is how to change user permissions inside the container for that USB-Device which is mapped inside. Of course I can log into the container and enter CHMOD. But ho can I do that automatically ?

Any hints ?

You should be able to change on the host as i.e. chmod xxx /dev/ttyusb.... 

Link to comment

Hi,

 

it's not that the "container" doesn't have access to the device.

I'm using a PHP/Apache container. I think the "www" user doesn't have access to it within the container.

After "chmod 777" within the container  i can then send my command through the device.

However.... Now is everything running as it should. I put "docker exec Apache-PHP bash -c "chmod 777 /dev/ttyUSB0" in my script which I run to connect the device via usbip to unraid an configure the serial port. Just added a few seconds of sleep to it after array starts.

MY hopes would are that it could be possible to enter this already in the template when mapping the device. But I don't know how.

At least when rebooting the server everything starts automatically 🙂

Link to comment
On 8/12/2021 at 9:29 AM, batesman73 said:

Hi,

 

it's not that the "container" doesn't have access to the device.

I'm using a PHP/Apache container. I think the "www" user doesn't have access to it within the container.

After "chmod 777" within the container  i can then send my command through the device.

However.... Now is everything running as it should. I put "docker exec Apache-PHP bash -c "chmod 777 /dev/ttyUSB0" in my script which I run to connect the device via usbip to unraid an configure the serial port. Just added a few seconds of sleep to it after array starts.

MY hopes would are that it could be possible to enter this already in the template when mapping the device. But I don't know how.

At least when rebooting the server everything starts automatically 🙂

Hi 

 

I am only a basic docker users, but can you not add that in the extra parms section in the template? I am guessing you have --device=/dev/ttyUSB0 in there already?

 

image.thumb.png.ff5fdad1a84111597c89c9946c6ec367.png

 

I am looking at adding the auto attach options and thinking on how to link to specific devices, would you be willing to share the info below? also the scripts you have created so I can see the process you are using. PM me the info if you don't want to post here.

 

image.thumb.png.8b52b8a0e27216eb6667b4fa7dde46a4.png

 

 

Link to comment
23 minutes ago, SimonF said:

I am guessing you have --device=/dev/ttyUSB0 in there already?

@batesman73 just a suggestion from my side, actually because it's a little more convenient I think, do it like this if you want to add a device to a contianer:

  1. In the Docker template click on: grafik.png.e5e4d62826ff85515dd016058154455f.png
  2. Change the "Config Type" to: "Device"
  3. (Optional) give it a Name
  4. As value use the device path: "/dev/ttyUSB0"
  5. Click on "Add"
  6. Click on "Apply"
  7. Enjoy

 

grafik.thumb.png.6651efe7b2382a6c446f9d0b5b8e5255.png

 

  • Thanks 1
Link to comment
Posted (edited)
21 minutes ago, ich777 said:

want to add a device to a contianer

I have learnt something new today, didn't know that option existed. Thanks.

 

Any suggestions for the other question about permissions of dev in the container?

Edited by SimonF
  • Like 1
Link to comment
On 8/12/2021 at 9:29 AM, batesman73 said:

Hi,

 

it's not that the "container" doesn't have access to the device.

I'm using a PHP/Apache container. I think the "www" user doesn't have access to it within the container.

After "chmod 777" within the container  i can then send my command through the device.

However.... Now is everything running as it should. I put "docker exec Apache-PHP bash -c "chmod 777 /dev/ttyUSB0" in my script which I run to connect the device via usbip to unraid an configure the serial port. Just added a few seconds of sleep to it after array starts.

MY hopes would are that it could be possible to enter this already in the template when mapping the device. But I don't know how.

At least when rebooting the server everything starts automatically 🙂

Are you using user scripts for the starting at boot?

Link to comment

I tried via extra Parameters AND the ICH 777 suggested way already before. It has the same effect ;-)

However. that doesn't solve my problem. I need to change the permission for the device within the container. Maybe there is way to specify that in another way. but for now I use I like I wrote in my last post.

 

However here's what I use for my personal needs. I know it could be partly solved also via autostart on the (usbip-)servers side but I had some problems in the past so I start/stop the demon and attach it everytime again.

 

Start Script:

#!/bin/bash
modprobe vhci-hcd
ssh root@dietpi 'sudo modprobe usbip_host; sudo usbipd -D; sudo usbip bind -b 1-1.3'
sleep 0.5
/usr/sbin/usbip attach -r dietpi -b 1-1.3
sleep 0.5
stty -F /dev/ttyUSB0 ospeed 300 ispeed 300 -ignpar cs8 -cstopb -echo
sleep 20
docker exec Apache-PHP bash -c "chmod 777 /dev/ttyUSB0"

 

Stop Script:

#!/bin/bash
/usr/sbin/usbip detach -p 00
ssh root@dietpi 'sudo /usr/sbin/usbip unbind -b 1-1.3'

 

Link to comment
36 minutes ago, batesman73 said:

I tried via extra Parameters AND the ICH 777 suggested way already before. It has the same effect ;-)

Exactly, the same effect but more convenient... ;)

 

Don't followed the whole conversation, why do you need to set the permissions, what container is it? Is there some kind of hook that you can execute on the start of the container.

 

Also wouldn't it be much easier to add the user that uses the USB device to the tty group like:

adduser YOURUSER dialout

so you actually don't need to set the permissions?

 

Is the root user the user who needs the serial connection?

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.