-
-
Notifications
You must be signed in to change notification settings - Fork 345
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable Host access to physical COM ports (#2326)
This PR extends the Host serial port emulation to include local physical devices using the `--device` command-line option. For example: ``` make run HOST_UART_OPTIONS="--uart=0 --device=/dev/ttyUSB0" ``` The `--device` option must follow the `--uart` option. Another example: ``` make run HOST_UART_OPTIONS="--uart=0 --device=/dev/ttyUSB0 --uart=1 --device=/dev/ttyUSB1" ``` The port is opened when `uart_init` gets called. The default baud rate is whatever the application has requested. This can be overridden as follows: ``` make run HOST_UART_OPTIONS="--uart=0 --device=/dev/ttyUSB0 --baud=921600" ```
- Loading branch information
Showing
14 changed files
with
346 additions
and
81 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#pragma once | ||
|
||
#include "seriallib/lib/serialib.h" | ||
|
||
class SerialDevice : public serialib | ||
{ | ||
}; |
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,4 @@ | ||
COMPONENT_SUBMODULES += seriallib | ||
|
||
COMPONENT_SRCDIRS := seriallib/lib | ||
COMPONENT_INCDIRS := . |
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 @@ | ||
diff --git a/lib/serialib.cpp b/lib/serialib.cpp | ||
index 8dbe52f..dc25811 100644 | ||
--- a/lib/serialib.cpp | ||
+++ b/lib/serialib.cpp | ||
@@ -135,7 +135,7 @@ char serialib::openDevice(const char *Device,const unsigned int Bauds) | ||
case 115200 : dcbSerialParams.BaudRate=CBR_115200; break; | ||
case 128000 : dcbSerialParams.BaudRate=CBR_128000; break; | ||
case 256000 : dcbSerialParams.BaudRate=CBR_256000; break; | ||
- default : return -4; | ||
+ default : dcbSerialParams.BaudRate=Bauds; | ||
} | ||
// 8 bit data | ||
dcbSerialParams.ByteSize=8; | ||
@@ -609,7 +609,7 @@ int serialib::available() | ||
// Device errors | ||
DWORD commErrors; | ||
// Device status | ||
- COMSTAT commStatus; | ||
+ COMSTAT commStatus{}; | ||
// Read status | ||
ClearCommError(hSerial, &commErrors, &commStatus); | ||
// Return the number of pending bytes |
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
Oops, something went wrong.