-
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.
- Loading branch information
1 parent
c6fe15b
commit a8f2dc7
Showing
34 changed files
with
2,695 additions
and
355 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,14 @@ | ||
name: Build | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: xanderhendriks/action-build-stm32cubeide@v10.0 | ||
with: | ||
project-path: '.' | ||
project-target: './Debug' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#include "read_buffer.h" | ||
|
||
ReadBuffer::ReadBuffer() : index(0), size(0), bytes{0U} { | ||
} | ||
|
||
void ReadBuffer::set_data(uint8_t *src1, const uint32_t src2) { | ||
this->bytes = src1; | ||
this->size = src2; | ||
} | ||
|
||
uint32_t ReadBuffer::get_size() const { | ||
return index; | ||
} | ||
|
||
uint32_t ReadBuffer::get_max_size() const { | ||
return size; | ||
} | ||
|
||
bool ReadBuffer::peek(uint8_t &byte) const { | ||
bool result = this->index < this->size; | ||
if (result) { | ||
byte = this->bytes[this->index]; | ||
} | ||
|
||
return result; | ||
} | ||
|
||
bool ReadBuffer::advance() { | ||
const bool result = this->index < this->size; | ||
if (result) { | ||
++this->index; | ||
} | ||
return result; | ||
} | ||
|
||
bool ReadBuffer::advance(const uint32_t src) { | ||
this->index += src; | ||
const bool result = this->index < this->size; | ||
if (result) { | ||
this->index = this->size; | ||
} | ||
|
||
return result; | ||
} | ||
|
||
bool ReadBuffer::pop(uint8_t &byte) { | ||
bool result = this->index < this->size; | ||
if (result) { | ||
byte = this->bytes[this->index]; | ||
++this->index; | ||
} | ||
|
||
return result; | ||
} |
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,71 @@ | ||
#ifndef LIGHT_DETECTOR_READ_BUFFER_H | ||
#define LIGHT_DETECTOR_READ_BUFFER_H | ||
|
||
#include <stdio.h> | ||
#include "ReadBufferInterface.h" | ||
|
||
/** | ||
* Represents read buffer implementation for protocol buffers serialization. | ||
*/ | ||
class ReadBuffer : public EmbeddedProto::ReadBufferInterface { | ||
public: | ||
ReadBuffer(); | ||
|
||
virtual ~ReadBuffer() = default; | ||
|
||
/** | ||
* Sets given buffer data. | ||
* | ||
* @param src1 - given buffer source. | ||
* @param src2 - given buffer source size. | ||
*/ | ||
void set_data(uint8_t *src1, uint32_t src2); | ||
|
||
/** | ||
* @see EmbeddedProto::ReadBufferInterface | ||
*/ | ||
[[nodiscard]] uint32_t get_size() const override; | ||
|
||
/** | ||
* @see EmbeddedProto::ReadBufferInterface | ||
*/ | ||
[[nodiscard]] uint32_t get_max_size() const override; | ||
|
||
/** | ||
* @see EmbeddedProto::ReadBufferInterface | ||
*/ | ||
bool peek(uint8_t &byte) const override; | ||
|
||
/** | ||
* @see EmbeddedProto::ReadBufferInterface | ||
*/ | ||
bool advance() override; | ||
|
||
/** | ||
* @see EmbeddedProto::ReadBufferInterface | ||
*/ | ||
bool advance(const uint32_t N) override; | ||
|
||
/** | ||
* @see EmbeddedProto::ReadBufferInterface | ||
*/ | ||
bool pop(uint8_t &byte) override; | ||
|
||
private: | ||
/** | ||
* Represents current size of the buffer. | ||
*/ | ||
uint32_t index; | ||
|
||
/** | ||
* Represents max size of the buffer. | ||
*/ | ||
uint32_t size; | ||
|
||
/** | ||
* Represents current buffer data. | ||
*/ | ||
uint8_t *bytes; | ||
}; | ||
|
||
#endif //LIGHT_DETECTOR_READ_BUFFER_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,49 @@ | ||
#ifndef _DEMO_WRITE_BUFFER_H_ | ||
#define _DEMO_WRITE_BUFFER_H_ | ||
|
||
#include "write_buffer.h" | ||
|
||
//WriteBuffer() | ||
// : bytes_used_(0), | ||
// bytes_{0U} { | ||
// | ||
//} | ||
// | ||
//virtual ~WriteBuffer() = default; | ||
// | ||
//void clear() override { | ||
//bytes_used_ = 0; | ||
//} | ||
// | ||
//uint32_t get_size() const override { | ||
//return bytes_used_; | ||
//} | ||
// | ||
//uint32_t get_max_size() const override { | ||
//return BUFFER_SIZE; | ||
//} | ||
// | ||
//uint32_t get_available_size() const override { | ||
//return -bytes_used_; | ||
//} | ||
// | ||
//bool push(const uint8_t byte) override { | ||
//bool result = BUFFER_SIZE > bytes_used_; | ||
//if (result) { | ||
//bytes_[bytes_used_] = byte; | ||
//++bytes_used_; | ||
//} | ||
//return result; | ||
//} | ||
// | ||
//bool push(const uint8_t *bytes, const uint32_t length) override { | ||
//bool result = BUFFER_SIZE >= (bytes_used_ + length); | ||
//if (result) { | ||
//memcpy(bytes_ + bytes_used_, bytes, length); | ||
//bytes_used_ += length; | ||
//} | ||
//return result; | ||
//} | ||
|
||
|
||
#endif // _DEMO_WRITE_BUFFER_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,82 @@ | ||
#ifndef LIGHT_DETECTOR_WRITE_BUFFER_H | ||
#define LIGHT_DETECTOR_WRITE_BUFFER_H | ||
|
||
#include <WriteBufferInterface.h> | ||
#include <stdio.h> | ||
#include <cstring> | ||
|
||
/** | ||
* Represents write buffer implementation for protocol buffers serialization. | ||
* | ||
* @tparam BUFFER_SIZE | ||
*/ | ||
template<uint32_t BUFFER_SIZE> | ||
class WriteBuffer : public EmbeddedProto::WriteBufferInterface { | ||
public: | ||
WriteBuffer(); | ||
|
||
virtual ~WriteBuffer() = default; | ||
|
||
/** | ||
* @see EmbeddedProto::WriteBufferInterface | ||
*/ | ||
void clear() override; | ||
|
||
/** | ||
* @see EmbeddedProto::WriteBufferInterface | ||
*/ | ||
[[nodiscard]] uint32_t get_size() const override { | ||
return bytes_used; | ||
} | ||
|
||
/** | ||
* @see EmbeddedProto::WriteBufferInterface | ||
*/ | ||
[[nodiscard]] uint32_t get_max_size() const override { | ||
return BUFFER_SIZE; | ||
} | ||
|
||
/** | ||
* @see EmbeddedProto::WriteBufferInterface | ||
*/ | ||
[[nodiscard]] uint32_t get_available_size() const override { | ||
return -bytes_used; | ||
} | ||
|
||
/** | ||
* @see EmbeddedProto::WriteBufferInterface | ||
*/ | ||
bool push(const uint8_t byte) override { | ||
bool result = BUFFER_SIZE > bytes_used; | ||
if (result) { | ||
bytes[bytes_used] = byte; | ||
++bytes_used; | ||
} | ||
return result; | ||
} | ||
|
||
/** | ||
* @see EmbeddedProto::WriteBufferInterface | ||
*/ | ||
bool push(const uint8_t *bytes, const uint32_t length) override { | ||
bool result = BUFFER_SIZE >= (bytes_used + length); | ||
if (result) { | ||
memcpy(bytes, bytes + bytes_used, length); | ||
bytes_used += length; | ||
} | ||
return result; | ||
} | ||
|
||
private: | ||
/** | ||
* Represents amount of currently used bytes by buffer. | ||
*/ | ||
uint32_t bytes_used; | ||
|
||
/** | ||
* Represents current buffer data. | ||
*/ | ||
uint8_t bytes[BUFFER_SIZE]; | ||
}; | ||
|
||
#endif //LIGHT_DETECTOR_WRITE_BUFFER_H |
Oops, something went wrong.