Jump to content

Bind USB Serial adapter to a certain mountpoint (Linux)

Hello there,

I have a serial adapter that sometimes disappears or becomes unresponsive, so my script resets it.

I have just found that sometimes it will instead become ttyUSB1 or 2 instead of ttyUSB0, causing my script to keep attempting to reconnect a device that it will never find.

How can I ensure my serial adapter stays on /dev/ttyUSB0?

 

I know I could buy a level shifter and attach that to the Pi (and ttyAMA0?? will not move), but I don't really want to buy one if I can use the serial adapter I already own.

 

Thanks!

UTC/GMT (Except during BST)

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, zhnu said:

Maybe use udevadm to monitor device and on change use given path

Could you give me an example on how to use it? Initial DDG does not show much of use.

I also need this to work on boot or demand with my Python script preferably.

UTC/GMT (Except during BST)

Link to comment
Share on other sites

Link to post
Share on other sites

It might end up being easier to modify the Python script to find all /dev/ttyUSB* devices and then try to connect to each one until successful,

assuming that the left over devices return a failure when you try to open them.

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, Alfihar said:

It might end up being easier to modify the Python script to find all /dev/ttyUSB* devices and then try to connect to each one until successful,

assuming that the left over devices return a failure when you try to open them.

I asked on the RPi fourms as well, and they suggested to use the /dev/serial/by-id ID, which works so far. Thanks!

UTC/GMT (Except during BST)

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×