-
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.
Merge pull request #2 from janekbaraniewski/init
Init2
- Loading branch information
Showing
10 changed files
with
178 additions
and
78 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,68 @@ | ||
# ser2net2ser | ||
|
||
> This still needs testing | ||
## Requirements | ||
|
||
- Linux or macOS operating system | ||
- Boost libraries (system, program_options, log_setup, log, date_time) | ||
- CMake for building the project | ||
- Docker (optional) for containerization | ||
|
||
## Building the Project | ||
|
||
Clone the repository and use CMake to build the project: | ||
|
||
```bash | ||
git clone https://github.com/janekbaraniewski/ser2net2ser.git | ||
cd ser2net2ser | ||
make build | ||
``` | ||
|
||
This will compile both the server and client applications. | ||
|
||
## Running the Server | ||
|
||
The server needs to be connected to a serial device. It can be started with the following command: | ||
|
||
```bash | ||
./build/serial_server \ | ||
--device /dev/ttyUSB0 \ | ||
--baud 9600 \ | ||
--port 12345 | ||
``` | ||
|
||
```text | ||
--device: Specifies the serial device. | ||
--baud: Sets the baud rate for the serial device. | ||
--port: TCP port on which the server will listen for incoming connections. | ||
``` | ||
|
||
![server](docs/server.png) | ||
|
||
## Running the Client | ||
|
||
The client should be run on the machine where you want the virtual serial port to be created: | ||
|
||
```bash | ||
sudo ./build/serial_client \ | ||
--server 192.168.1.100 \ | ||
--port 12345 \ | ||
--vsp "tty.usbserial-666" | ||
``` | ||
|
||
```text | ||
--server: IP address of the server. | ||
--port: TCP port on which the server is running. | ||
--vsp: Name of the virtual serial port to be created. | ||
``` | ||
|
||
![client](docs/client.png) | ||
|
||
## Docker Containers | ||
|
||
Dockerfiles for both the server and client are included. Build and run the containers using: | ||
|
||
```bash | ||
make build-images | ||
``` |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,44 @@ | ||
#ifndef CLIENT_H | ||
#define CLIENT_H | ||
|
||
#include <iostream> | ||
#include <array> | ||
#include <fcntl.h> | ||
#include <unistd.h> | ||
#include <termios.h> | ||
|
||
#include <boost/asio.hpp> | ||
#include <boost/program_options.hpp> | ||
#include <boost/log/core.hpp> | ||
#include <boost/log/trivial.hpp> | ||
#include <boost/log/expressions.hpp> | ||
#include <boost/log/utility/setup/file.hpp> | ||
#include <boost/log/utility/setup/console.hpp> | ||
#include <boost/log/utility/setup/common_attributes.hpp> | ||
#include <boost/log/sources/severity_logger.hpp> | ||
#include <boost/log/sources/record_ostream.hpp> | ||
#include <boost/log/support/date_time.hpp> | ||
|
||
#include "logging.h" | ||
#include "VirtualSerialPort.h" | ||
|
||
using namespace boost::asio; | ||
using ip::tcp; | ||
using std::string; | ||
|
||
class SerialClient { | ||
public: | ||
SerialClient(const string& server_ip, unsigned short server_port, const string& vsp_name); | ||
void run(); | ||
|
||
private: | ||
io_service io_service_; | ||
tcp::socket socket_; | ||
std::array<char, 256> buffer_; | ||
VirtualSerialPort vsp_; | ||
|
||
void do_read_write(); | ||
}; | ||
|
||
|
||
#endif // CLIENT_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
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
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