Skip to content
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

Unexpected Error: FileExistsError #106

Closed
noduritoto opened this issue Jul 30, 2024 · 4 comments
Closed

Unexpected Error: FileExistsError #106

noduritoto opened this issue Jul 30, 2024 · 4 comments

Comments

@noduritoto
Copy link

Note: for general support questions, please use the discussions tab. This is the template for bugs in ble-serial.
Make sure you have completely read the README, searched through the issues and discussions.

Describe the bug
I met a error about 'Unexpected Error: FileExistsError'
How can I fix it?

Log messages
The full output of ble-serial -v (with your usual parameters like -d).
If it is related to BLE chracteristics please also run ble-scan -d with you device address.

Put the result into code blocks (wrap with triple backticks) to get proper formatting:
$ble-serial -d 12345678989

your log could be here

$ble-serial -d 12345678989
14:08:06.889 | ERROR | main.py: Unexpected Error: FileExistsError(17, 'File exists')
14:08:06.889 | WARNING | main.py: Shutdown initiated
14:08:06.890 | INFO | main.py: Shutdown complete.

Setup (please complete the following information):

  • OS: MacOS Sonoma
  • Bluetooth Hardware: [e.g. HM-10, Intel AX200 Bluetooth Adapter]
  • BlueZ Version: [Output of bluetoothctl -v, Linux only]
  • Python Version: [from python3 -V]
  • ble-serial and dependency versions: [from pip3 list]

Additional Context
Tricks for reproducing the issue? Results from other things you have already tried? Ideas what might be the cause, etc.

@MrCocoDev
Copy link

I'm not the author, but if you use the --port parameter to change the port you can circumvent this error. I am not sure why the virtual port isn't being cleaned up automatically.

@Jakeler
Copy link
Owner

Jakeler commented Jul 31, 2024

Hi, you can delete the file if you are sure no ble-serial is running, in the console simply: rm /tmp/ttyBLE

It gets auto cleaned on a usual shutdown, but maybe the process was hard killed before, then it can't run the cleanup routine.

The tip from @MrCocoDev for using a different path should work as well.

@MrCocoDev
Copy link

MrCocoDev commented Jul 31, 2024

I think if you add:

                try:
                    self.uart = UART(args.port, loop, args.mtu)
                except OSError as e:
                    # This check might be hype specific to MacOS, not sure
                    if "FileExistsError(17, 'File exists')" in repr(e):
                        raise ValueError(
                            f"Port {args.port} already exists. "
                            f"Please specify a new port or clean "
                            f"up the old port, if it is safe to do so."
                        ) from e 

You could add a lot of clarity around this issue. I happened to figure it out from an unrelated SO and a good guess, but I imagine a lot of users will just give up in frustration.

Either way, thanks for such an awesome library!

@Jakeler
Copy link
Owner

Jakeler commented Nov 25, 2024

Good idea @MrCocoDev , thanks for the contribution!
It's added now in the UART class.

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

No branches or pull requests

3 participants