Skip to content

Commit 63ed3ae

Browse files
author
root
committed
SerialImp.c:configure_port: for hidraw devices tcgetattr failure is OK
NeuronRobotics#260 Before this change the error message for opening /dev/hidraw0 was: CommPortIdentifier id = CommPortIdentifier.getPortIdentifier("/dev/hidraw0"); id.open(NRJavaSerialTest.class.getSimpleName(), 5000); → Port /dev/hidraw0 in use by another application Exception in thread "main" gnu.io.PortInUseException: Unknown Owner at gnu.io.CommPortIdentifier.open(CommPortIdentifier.java:476) at test.NRJavaSerialTest.main(NRJavaSerialTest.java:86)
1 parent 7dee6a2 commit 63ed3ae

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/main/c/src/SerialImp.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,11 @@ int configure_port( int fd )
373373

374374
if( fd < 0 ) goto fail;
375375

376-
if( tcgetattr( fd, &ttyset ) < 0 ) goto fail;
376+
errno = 0;
377+
if( tcgetattr( fd, &ttyset ) < 0 ) {
378+
if (errno == EINVAL || errno == ENOTTY) return 0;
379+
goto fail;
380+
}
377381
ttyset.c_iflag = INPCK;
378382
ttyset.c_lflag = 0;
379383
ttyset.c_oflag = 0;

0 commit comments

Comments
 (0)