Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 747
  • Last Modified:

check if a com port exists by C code

How can we check if a com port exists by C code?
0
mathematics
Asked:
mathematics
1 Solution
 
garbouaCommented:
I don't know how to check using c, but they should be under /dev listed as ttys0-ttys3
0
 
ragaMuffinCommented:
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

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now