forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bottom part of serial port support on Unix (dotnet/corefx#29033)
* bottom part of serial port support * small cleanup * feedback from reviews * remove previous changes to System.Native * feedback from review * use consistently int32_t * update names and types based on feedback * feedback from kasper3 Commit migrated from dotnet/corefx@83753bc
- Loading branch information
Showing
9 changed files
with
621 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/libraries/Native/Unix/System.IO.Ports.Native/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
project(System.IO.Ports.Native C) | ||
|
||
add_library(System.IO.Ports.Native | ||
SHARED | ||
pal_termios.c | ||
pal_serial.c | ||
${VERSION_FILE_PATH} | ||
) | ||
|
||
add_library(System.IO.Ports.Native-Static | ||
STATIC | ||
pal_termios.c | ||
pal_serial.c | ||
${VERSION_FILE_PATH} | ||
) | ||
|
||
# Disable the "lib" prefix and override default name | ||
set_target_properties(System.IO.Ports.Native-Static PROPERTIES PREFIX "") | ||
set_target_properties(System.IO.Ports.Native-Static PROPERTIES OUTPUT_NAME System.IO.Ports.Native CLEAN_DIRECT_OUTPUT 1) | ||
|
||
install_library_and_symbols (System.IO.Ports.Native) | ||
install (TARGETS System.IO.Ports.Native-Static DESTINATION .) |
16 changes: 16 additions & 0 deletions
16
src/libraries/Native/Unix/System.IO.Ports.Native/pal_serial.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
#include "pal_types.h" | ||
#include <fcntl.h> | ||
#include <errno.h> | ||
#include <pal_serial.h> | ||
|
||
/* Open device file in non-blocking mode and without controlling terminal */ | ||
intptr_t SystemIoPortsNative_SerialPortOpen(const char * name) | ||
{ | ||
intptr_t result; | ||
while ((result = open(name, O_RDWR | O_NOCTTY | O_CLOEXEC | O_NONBLOCK)) < 0 && errno == EINTR); | ||
return result; | ||
} |
9 changes: 9 additions & 0 deletions
9
src/libraries/Native/Unix/System.IO.Ports.Native/pal_serial.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
#include "pal_types.h" | ||
#include "pal_compiler.h" | ||
|
||
DLLEXPORT intptr_t SystemIoPortsNative_SerialPortOpen(const char * name); | ||
|
Oops, something went wrong.