Skip to content

Commit 905c540

Browse files
committed
✨ feat(serial): readByte method without his implementation
1 parent 24ea099 commit 905c540

File tree

4 files changed

+41
-51
lines changed

4 files changed

+41
-51
lines changed

docs/index.rst

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -23,38 +23,3 @@ Features
2323
* Support for various baud rates and communication parameters
2424
* Modern C++17 implementation
2525
* Exception-based error handling
26-
27-
Quick Start
28-
-----------
29-
30-
Here's a simple example of how to use libserial:
31-
32-
.. code-block:: cpp
33-
34-
#include <libserial/serial.hpp>
35-
#include <iostream>
36-
37-
int main() {
38-
try {
39-
libserial::Serial serial("/dev/ttyUSB0");
40-
serial.open();
41-
serial.write("Hello, World!");
42-
43-
std::string response = serial.read();
44-
std::cout << "Received: " << response << std::endl;
45-
46-
serial.close();
47-
} catch (const libserial::SerialException& e) {
48-
std::cerr << "Error: " << e.what() << std::endl;
49-
return 1;
50-
}
51-
52-
return 0;
53-
}
54-
55-
.. Indices and tables
56-
.. ==================
57-
58-
.. * :ref:`genindex`
59-
.. * :ref:`modindex`
60-
.. * :ref:`search`

docs/installation.rst

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Prerequisites
1010
To build libserial from source, you'll need:
1111

1212
* CMake (version 3.10 or higher)
13-
* A C++14 compatible compiler (GCC 5.4+ or Clang 3.4+)
13+
* A C++17 compatible compiler (GCC 5.4+ or Clang 3.4+)
1414
* Git (for cloning the repository)
1515

1616
For documentation generation (optional):
@@ -28,8 +28,8 @@ Building the Library
2828

2929
.. code-block:: bash
3030
31-
git clone https://github.com/NestorDP/libserial.git
32-
cd libserial
31+
git clone https://github.com/NestorDP/cppserial.git
32+
cd cppserial
3333
3434
2. Create a build directory:
3535

@@ -69,28 +69,37 @@ You can customize the build with various CMake options:
6969
# Install to a custom location
7070
cmake -DCMAKE_INSTALL_PREFIX=/usr/local ..
7171
72-
Package Installation
73-
--------------------
72+
# Enable testing
73+
cmake -DBUILD_TESTING=ON ..
7474
75-
Ubuntu/Debian
76-
~~~~~~~~~~~~~
75+
# Enable coverage reports
76+
cmake -DENABLE_COVERAGE=ON ..
7777
78-
.. code-block:: bash
78+
# Enable documentation generation
79+
cmake -DBUILD_DOCUMENTATION=ON ..
80+
81+
.. Package Installation
82+
.. --------------------
83+
84+
.. Ubuntu/Debian
85+
.. ~~~~~~~~~~~~~
86+
87+
.. .. code-block:: bash
7988
80-
sudo apt update
81-
sudo apt install libserial-dev
89+
.. sudo apt update
90+
.. sudo apt install libserial-dev
8291
83-
(Note: Package availability depends on your distribution)
92+
.. (Note: Package availability depends on your distribution)
8493
85-
From Binary Releases
86-
~~~~~~~~~~~~~~~~~~~~~
94+
.. From Binary Releases
95+
.. ~~~~~~~~~~~~~~~~~~~~~
8796
88-
Download the latest release from the `GitHub releases page <https://github.com/NestorDP/libserial/releases>`_ and follow the installation instructions provided with the release.
97+
.. Download the latest release from the `GitHub releases page <https://github.com/NestorDP/cppserial/releases>`_ and follow the installation instructions provided with the release.
8998
9099
Verifying Installation
91100
----------------------
92101

93-
To verify that libserial is installed correctly, create a simple test program:
102+
To verify that cppserial is installed correctly, create a simple test program:
94103

95104
.. code-block:: cpp
96105
@@ -106,5 +115,5 @@ Compile and run:
106115

107116
.. code-block:: bash
108117
109-
g++ -std=c++14 test.cpp -lserial -o test
118+
g++ -std=c++17 test.cpp -lserial -o test
110119
./test

include/libserial/serial.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,18 @@ void write(std::shared_ptr<std::string> data);
119119
*/
120120
size_t read(std::shared_ptr<std::string> buffer, size_t max_length);
121121

122+
/**
123+
* @brief Read a single byte from the serial port
124+
*
125+
* Reads one byte from the serial port and stores it in the provided buffer.
126+
*
127+
* @param buffer Shared pointer to string where the byte will be stored
128+
* @return Number of bytes actually read (1 if successful, 0 on error)
129+
* @throws SerialException if read operation fails
130+
* @throws SerialException if buffer is null
131+
*/
132+
void readByte([[maybe_unused]] std::shared_ptr<std::string> buffer);
133+
122134
/**
123135
* @brief Reads data until a specific terminator character is found
124136
*

src/serial.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ size_t Serial::read(std::shared_ptr<std::string> buffer, size_t max_length) {
6868
return static_cast<size_t>(bytes_read);
6969
}
7070

71+
void Serial::readByte([[maybe_unused]] std::shared_ptr<std::string> buffer) {
72+
// Implementation can be added here if needed
73+
}
74+
7175
size_t Serial::readUntil(std::shared_ptr<std::string> buffer, char terminator) {
7276
if (!buffer) {
7377
throw SerialException("Null pointer passed to readUntil function");

0 commit comments

Comments
 (0)