check if a com port exists by C code

How can we check if a com port exists by C code?
mathematicsAsked:
Who is Participating?
 
ragaMuffinConnect With a Mentor Commented:
com ports are character devices.  As a character device is initialized, its device driver registers itself with the linux kernel by adding an entry into the chrdevs vector of device_struct data structure.  You can call a device and tread it exaclty like a file.  operation on a character device include iseek,read,write,readdir,select,ioctl .... etc.
you can use the open function with O_RDONLY, O_WRONLY, or O_RDWR
do a man on open to get details and header files needed.
0
 
garbouaCommented:
I don't know how to check using c, but they should be under /dev listed as ttys0-ttys3
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.