Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
33acc0d
Modify pulse init value with duty_cycle instead of 0
Sagah123 Oct 16, 2026
6683848
Fix PWM duty cycle being overwritten on init
Sagah123 Oct 17, 2026
33beac9
Add changeset and apply clangformat
Sagah123 Oct 17, 2026
6f8c60b
Implement get_ccrx and add it to .Pulse initialization in pwm and dua…
Sagah123 Oct 17, 2026
0de3a89
Update TimerWrapper.hpp
Sagah123 Oct 17, 2026
8936ec3
Change method's name and location
Sagah123 Oct 17, 2026
17dc11c
resolve merge conflict
Sagah123 Oct 17, 2026
420c280
Merge branch 'development' of https://github.com/Hyperloop-UPV/ST-LIB…
Sagah123 Oct 21, 2026
0c77e89
Initial commit
Sagah123 Oct 21, 2026
ac73f61
a lot of stuff to do
Sagah123 Oct 21, 2026
484556f
feat: add ProtectionMessage over raw lwIP TCP
Sagah123 Oct 21, 2026
d1d8c14
Delete useless pointer
Sagah123 Oct 22, 2026
0e6e526
Add subseconds and comments
Sagah123 Oct 22, 2026
95fcee2
Merge remote-tracking branch 'origin/development' into feat/adjv3-pro…
Sagah123 Oct 22, 2026
5086b87
Add comments and subseconds'
Sagah123 Oct 22, 2026
367603f
Change IP to the recommended one
Sagah123 Oct 23, 2026
7fb805f
Modify hardcoded IP and Port to argumentos of a function. Add better …
Sagah123 Oct 23, 2026
c040c24
Add changeset for ADJV3 protections
Sagah123 Oct 23, 2026
41a53e5
Revert c_cpp_properties and add inline to template
Sagah123 Oct 23, 2026
60e4734
Add make raw make() private (FoolProof) and read value at send time
Sagah123 Oct 23, 2026
c31f790
test
Sagah123 Oct 23, 2026
13fc4b7
Change make implementation and modify structure names
Sagah123 Oct 28, 2026
3576a24
Merge branch 'ADJv3' into feat/adjv3-protections
Sagah123 Nov 6, 2026
99acab0
Merge branch 'ADJv3' of https://github.com/Hyperloop-UPV/ST-LIB into …
Sagah123 Nov 6, 2026
772b8f1
fix(Diagnostics): mark unused forward_target with [[maybe_unused]]
Sagah123 Nov 6, 2026
dfc0ee9
Fix bug with control station
Sagah123 Nov 6, 2026
79c6281
Add last_order_id
Sagah123 Nov 6, 2026
32703bc
Merge branch 'ADJv3' into feat/adjv3-protections
Sagah123 Nov 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Inc/HALAL/Models/Packets/Order.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
class Order : public Packet {
public:
string* remote_ip;
static inline uint16_t last_order_ip = 0;
static map<uint16_t, Order*> orders;
virtual void set_callback(void (*callback)(void)) = 0;
virtual void process() = 0;
Expand Down
7 changes: 5 additions & 2 deletions Inc/ST-LIB_HIGH/Protections/ProtectionMessages.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@ struct ProtectionADJv3Packet {
};

public:
static Package
make(uint16_t measurement_id, Protections::RuleKind protection, Protections::SampleEncoding value_size);
static Package make(
uint16_t measurement_id,
Protections::RuleKind protection,
Protections::SampleEncoding value_size
);
static bool tcp_client_init(const char* ip, uint16_t port);
static bool tcp_client_send(Package& pack, const void* value);

Expand Down
41 changes: 24 additions & 17 deletions Src/HALAL/Services/Communication/Ethernet/LWIP/TCP/ServerSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
*
* Created on: Nov 23, 2022
* Author: stefa
* Edited on: Nov 6, 2026
* Editor: aleks
*/
#ifdef STLIB_ETH
#include "HALAL/Services/Communication/Ethernet/LWIP/TCP/ServerSocket.hpp"
#include "HALAL/Services/Communication/Ethernet/LWIP/TCP/TcpOrderStreamParser.hpp"
#include "ErrorHandler/ErrorHandler.hpp"
#include "lwip/priv/tcp_priv.h"
#include "ST-LIB_HIGH/Protections/ProtectionMessages.hpp"
#ifdef HAL_ETH_MODULE_ENABLED

uint8_t ServerSocket::priority = 1;
Expand Down Expand Up @@ -202,6 +205,10 @@ void ServerSocket::close() {
rx_stream_buffer.clear();
state = CLOSED;

ST_LIB::ProtectionADJv3Packet::tpcb =
nullptr; // Protection from hard Fault (idk how it works by the moment)
ST_LIB::ProtectionADJv3Packet::is_connected = false;

auto listener_it = listening_sockets.find(local_port);
if (listener_it != listening_sockets.end() && listener_it->second == this) {
listening_sockets.erase(listener_it);
Expand Down Expand Up @@ -362,43 +369,43 @@ bool ServerSocket::is_listening() const { return state == ServerSocket::ServerSt

err_t ServerSocket::accept_callback(
void* arg,
struct tcp_pcb* incomming_control_block,
struct tcp_pcb* incoming_control_block,
err_t error
) {
if (error != ERR_OK || incomming_control_block == nullptr) {
if (incomming_control_block != nullptr) {
tcp_abort(incomming_control_block);
if (error != ERR_OK || incoming_control_block == nullptr) {
if (incoming_control_block != nullptr) {
tcp_abort(incoming_control_block);
}
return error;
}

ServerSocket* server_socket = static_cast<ServerSocket*>(arg);
if (server_socket == nullptr) {
auto it = listening_sockets.find(incomming_control_block->local_port);
auto it = listening_sockets.find(incoming_control_block->local_port);
if (it == listening_sockets.end()) {
tcp_abort(incomming_control_block);
tcp_abort(incoming_control_block);
return ERR_ABRT;
}
server_socket = it->second;
}

server_socket->state = ACCEPTED;
server_socket->client_control_block = incomming_control_block;
server_socket->remote_ip = IPV4(incomming_control_block->remote_ip);
server_socket->client_control_block = incoming_control_block;
server_socket->remote_ip = IPV4(incoming_control_block->remote_ip);
server_socket->rx_packet_buffer = {};
server_socket->rx_stream_buffer.clear();
server_socket->rx_stream_buffer.reserve(TcpOrderStreamParser::MAX_RX_STREAM_BUFFER_BYTES);

tcp_setprio(incomming_control_block, priority);
tcp_nagle_disable(incomming_control_block);
ip_set_option(incomming_control_block, SOF_REUSEADDR);
tcp_setprio(incoming_control_block, priority);
tcp_nagle_disable(incoming_control_block);
ip_set_option(incoming_control_block, SOF_REUSEADDR);

tcp_arg(incomming_control_block, server_socket);
tcp_recv(incomming_control_block, receive_callback);
tcp_sent(incomming_control_block, send_callback);
tcp_err(incomming_control_block, error_callback);
tcp_poll(incomming_control_block, poll_callback, 1);
config_keepalive(incomming_control_block, server_socket);
tcp_arg(incoming_control_block, server_socket);
tcp_recv(incoming_control_block, receive_callback);
tcp_sent(incoming_control_block, send_callback);
tcp_err(incoming_control_block, error_callback);
tcp_poll(incoming_control_block, poll_callback, 1);
config_keepalive(incoming_control_block, server_socket);

if (server_socket->server_control_block != nullptr) {
tcp_arg(server_socket->server_control_block, nullptr);
Expand Down
6 changes: 2 additions & 4 deletions Src/HALAL/Services/Diagnostics/DiagnosticSinks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,10 @@ class DiagnosticTransportOrder final : public Order {

class OrderProtocolDiagnosticSink final : public DiagnosticSink {
public:
explicit OrderProtocolDiagnosticSink(const char* ip = "192.168.0.9", uint16_t port = 31) {
ST_LIB::ProtectionADJv3Packet::tcp_client_init(ip, port);
}
explicit OrderProtocolDiagnosticSink(const char* ip = "192.168.0.9", uint16_t port = 31) {}
bool publish(const DiagnosticRecord& record) override {
auto package = ST_LIB::ProtectionADJv3Packet::make(
1234,
Order::last_order_ip,
record.payload.protection.rule_kind,
record.payload.protection.sample_encoding
);
Expand Down
11 changes: 7 additions & 4 deletions Src/ST-LIB_HIGH/Protections/ProtectionMessages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ namespace ST_LIB {
struct tcp_pcb* ProtectionADJv3Packet::tpcb = nullptr;
bool ProtectionADJv3Packet::is_connected = false;

ProtectionADJv3Packet::Package
ProtectionADJv3Packet::make(uint16_t measurement_id, Protections::RuleKind prot, Protections::SampleEncoding valueSize) {
ProtectionADJv3Packet::Package ProtectionADJv3Packet::make(
uint16_t measurement_id,
Protections::RuleKind prot,
Protections::SampleEncoding valueSize
) {
// Bit packing of protection into 3 most significant bits of id (Look adjv3 format)
uint8_t numericValueSize;
switch (valueSize)
{
switch (valueSize) {
case Protections::SampleEncoding::BOOL:
numericValueSize = 1;
break;
Expand Down Expand Up @@ -82,6 +84,7 @@ bool ProtectionADJv3Packet::tcp_client_init(const char* ip, uint16_t port) {
tpcb = nullptr;
return false;
}
tcp_output(tpcb);
return true;
}
bool ProtectionADJv3Packet::tcp_client_send(
Expand Down
Loading