Specify COM port file in java -


in unix operating systems, can access serial ports through files such /dev/ttyusb0 or something. , according question, filenames such com1: can used access serial ports. java alternative such file names? don't want use serial communication liberaries.

edit

what want code this.

string input_port_file_name = linux?"/dev/ttyusb0":"<file name of comport>"  file in = new file(input_port_file_name) 

what want widows alternative device file.

edit on linux machine, , want enable code ported easily!

yes, on linux there access serial port instance through device files /dev/ttys0, /dev/ttyusb0 , others. depends on hardware/chips used communicate , distributions.

if same hardware used in program can partly achieved. when worked serial comm libraries , real physical serial ports in linux used port numbers in config number 3 meant n=3, opens "com"+(1+n) on windows or "/dev/ttys"+n on linux. maybe similar can used accessing port on /dev/ttyusb"+n

but there no grantee port 2 /dev/ttys1 , com2 on same computer after dual boot.

the way not using serial comm libraries hard way , not recommend if want portability in java. recommend different port config depending on operating system.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -