Relative Content

Tag Archive for clinuxdebianraspbian

using access to check usb port by path fails because of port0 suffix

I want to be able to check if there is something plugged into a specific USB port in a C program. Currently i used “ls /dev/serial/by-path” to get the path to the device. I hardcoded the path in the program and use the “access” function with F_OK to check if it exists. this works fine when i tested it with one device but when i tried another device it fails because “-port0” gets added at the end of the path when this device is plugged in.