119 auto &buf = msg->buf_;
122 buf.head()->get_read_pointer(buf.skip(), &p, &available);
123 if (buf.size() == 0 || *p !=
':')
131 can_buf->
set_done(msg->done_->new_child());
134 const char *text_packet =
nullptr;
135 string assembled_packet;
136 if (available == buf.size())
139 text_packet = (
const char *)p;
143 buf.append_to(&assembled_packet);
144 text_packet = assembled_packet.c_str();
148 string debug(text_packet, buf.size());
149 LOG(
INFO,
"Failed to parse gridconnect packet: '%s'",
Destructable * create_gc_to_legacy_can_bridge(DirectHubInterface< uint8_t[]> *gc_hub, CanHubFlow *can_hub)
Creates a bridge between a gridconnect-based DirectHub and an old style CAN hub flow.
DataBufferPool g_direct_hub_kbyte_pool(1024)
This object forwards allocations to mainBufferPool.
StateFlow< Buffer< CanHubData >, QList< 1 > > CanHubPort
Base class for a port to an CAN hub that is implemented as a stateflow.
#define STATE(_fn)
Turns a function name into an argument to be supplied to functions expecting a state.
A BarrierNotifiable allows to create a number of child Notifiable and wait for all of them to finish.
BarrierNotifiable * new_child()
Call this for each child task.
void set_done(BarrierNotifiable *done)
Specifies that a given BarrierNotifiable must be called when the Buffer is deallocated (unreffed to z...
Base class for all QMember types that hold data in an expandable format.
void unref()
Decrement count.
T * data()
get a pointer to the start of the data.
Proxy Pool that can allocate DataBuffer objects of a certain size.
void alloc(DataBuffer **result)
Get a free item out of the pool with untyped data of the size specified in the constructor.
Specialization of the Buffer class that is designed for storing untyped data arrays.
Base class of everything with a virtual destructor.
Interface for a the central part of a hub.
virtual MessageAccessor< T > * mutable_message()=0
Accessor to fill in the message payload.
virtual void register_port(DirectHubPort< T > *port)=0
Adds a port to this hub.
virtual void enqueue_send(Executable *caller)=0
Signals that the caller wants to send a message to the hub.
virtual void unregister_port(DirectHubPort< T > *port)=0
Synchronously removes a port from this hub.
virtual void do_send()=0
Sends a message to the hub.
Interface for a downstream port of a hub (aka a target to send data to).
MessageType * alloc()
Synchronously allocates a message buffer from the pool of this flow.
void register_port(port_type *port)
Adds a new port.
void unregister_port(port_type *port)
Removes a previously added port.
Empty class that can be used as a pointer for identifying where a piece of data came from.
Bridge component that converts the outgoing CAN packets into gridconnect format and enqueues them int...
HubSource * me_
The source pointer we need to use for sending messages to the target hub.
BarrierNotifiable * pktDone_
Done notifiable from the source packet.
LinkedDataBufferPtr buf_
Output buffer of gridconnect bytes that will be sent to the GC DirectHub.
void send(MessageAccessor< uint8_t[]> *msg) override
GC to binary path.
bool inlineComplete_
True if the send completed inline.
CanHubFlow * sourceHub_
Hub where we get the input data from (registered).
Action do_send()
Handles the callback from the direct hub when it is ready for us to send the message.
uint16_t packetSize_
Number of bytes this gridconnect packet is.
DirectHubInterface< uint8_t[]> * targetHub_
Where to send the target data.
Action entry() override
Handles the next CAN packet that we need to send.
bool inlineRun_
True while we are calling the target hub send method.
static constexpr unsigned MIN_GC_FREE
Minimum amount of free bytes in the current send buffer in order to use it for gridconnect rendering.
A class that keeps ownership of a chain of linked DataBuffer references.
uint8_t * data_write_pointer()
LinkedDataBufferPtr transfer_head(size_t len)
Transfers the ownership of the prefix of this buffer.
void append_empty_buffer(DataBuffer *buf)
Adds an empty buffer to the end of this buffer chain.
void data_write_advance(size_t len)
Advances the tail pointer after a write occurred into the tail.
Return type for a state flow callback.
Action wait()
Wait for an asynchronous call.
Action wait_and_call(Callback c)
Wait for resource to become available before proceeding to next state.
Action exit()
Terminates the processing of this flow.
State flow with a given typed input queue.
void release() OVERRIDE
Unrefs the current buffer.
void send(MessageType *msg, unsigned priority=UINT_MAX) OVERRIDE
Sends a message to the state flow for processing.
#define LOG(level, message...)
Conditionally write a message to the logging output.
static const int INFO
Loglevel that is printed by default, reporting some status information.