HDLController

class hdlcontroller.hdlcontroller.HDLController(read_func: Callable[[], bytes], write_func: Callable[[bytes], Optional[int]], sending_timeout: Timeout = 2.0, window: int = 3, frames_queue_size: int = 0, fcs_nack: bool = True)[source]

An HDLC controller based on python4yahdlc.

class Receiver(read_func: Callable[[], bytes], write_func: Callable[[bytes], Optional[int]], send_lock: allocate_lock, senders_list: Dict[SequenceNumber, Sender], frames_received: Queue, callback: Optional[Callable[[bytes], None]] = None, fcs_nack: bool = True)[source]

Thread used to receive HDLC frames.

join(timeout: Optional[Timeout] = None)[source]

Stops the current thread.

run()[source]

Method representing the thread’s activity.

You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.

class Sender(write_func: Callable[[bytes], Optional[int]], send_lock: allocate_lock, data: bytes, seq_no: SequenceNumber, timeout: Timeout = 2.0, callback: Optional[Callable[[bytes], None]] = None)[source]

Thread used to send HDLC frames.

ack_received() None[source]

Informs the sender that the related ACK frame has been received. As a consequence, the current thread is being stopped.

join(timeout: Optional[Timeout] = None) None[source]

Stops the current thread.

nack_received() None[source]

Informs the sender that an NACK frame has been received. As a consequence, the data frame is being resent.

run() None[source]

Method representing the thread’s activity.

You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.

get_data() bytes[source]

Gets the next frame received.

This method will block until a new data frame is available.

get_senders_number() int[source]

Returns the number of active senders.

send(data: bytes) None[source]

Sends a new data frame.

This method will block until a new room is available for a new sender. This limit is determined by the size of the window.

set_receive_callback(callback: Callable[[bytes], None]) None[source]

Sets the receive callback function.

This method has to be called before starting the HDLC controller.

set_send_callback(callback: Callable[[bytes], None]) None[source]

Sets the send callback function.

If the HDLC controller has already been started, the new callback function will be taken into account for the next data frames to be sent.

set_sending_timeout(sending_timeout: Timeout) None[source]

Sets the sending timeout.

start() None[source]

Starts HDLC controller’s threads.

stop() None[source]

Stops HDLC controller’s threads.