pe.handler

Packet Engine Receive Handler Helpers

Helper implementations for ReceiveHandler that assist in building chains of more specialized helpers, and in debugging said chains.

Classes

MultiReceiveHandler

A receive handler that builds a chain of receive handlers.

DebugReceiveHandler

A receive handler that logs each method call along with its arguments.

Module Contents

class pe.handler.MultiReceiveHandler

Bases: pe.ReceiveHandler

A receive handler that builds a chain of receive handlers.

Each receive handler is called in turn when the corresponding method is called. Handlers are called in the order in which they are added.

add_handler(handler)

Add a new ReceiveHandler to the end of the current chain of handlers. This method returns the MultiReceiveHandler, thus allowing for multiple handlers to be added through chaining of calls to this method.

Parameters:

handler (ReceiveHandler) – ReceiveHandler instance to add.

Returns:

This MultiReceiveHandler instance.

Return type:

MultiReceiveHandler

remove_handler(handler)

Remove the specified handler from the current chain of handlers. This method returns the MultiReceiveHandler, thus allowing for multiple handlers to be removed through chaining of calls to this method.

Parameters:

handler (ReceiveHandler) – ReceiveHandler instance to remove.

Returns:

This MultiReceiveHandler instance.

Return type:

MultiReceiveHandler

version_info(major, minor)

Called with the major and minor version as returned from the server.

Corresponding frame type: ‘R’

Parameters:
  • major (int) – Major version.

  • minor (int) – Minor version.

callsign_registered(callsign, success)

Called with the results of an attempt to register a callsign with the server.

Corresponding frame type: ‘X’

Parameters:
  • callsign (str) – Callsign being registered.

  • success (bool) – True if registration was successful; False otherwise.

port_info(info)

Called with the results of a request for information on available ports.

Each returned port is a string of the form “<number>;<desc>”, being the port number and its description, separated by a semicolon.

Corresponding frame type: ‘G’

Parameters:

info (list[str]) – List of available ports.

port_caps(port, caps)

Called with the results of a request for the capabilities of a specific port.

Corresponding frame type: ‘g’

Parameters:
  • port (int) – Port for which capabilities are provided.

  • caps (PortCaps) – A PortCaps instance for this port.

callsign_heard_on_port(port, heard_call)

Called with the results of a request for a list of callsigns heard on a specified port. This method may be called multiple times for a single request, once for each callsign heard on the port.

Corresponding frame type: ‘H’

Parameters:
  • port (int) – Port for which records were requested.

  • heard_call (HeardCall) – Record of one callsign heard as returned from the server.

frames_waiting_on_port(port, frames)

Called with the results of a request for the number of frames outstanding on a specified port.

Corresponding frame type: ‘y’

Parameters:
  • port (int) – Port for which count is provided.

  • frames (int) – The number of outstanding frames for this port.

connection_received(port, call_from, call_to, incoming, message)

Called with information about a new connection, whether outgoing (i.e. initiated by the client) or incoming (i.e. initiated by a remote node).

Corresponding frame type: ‘C’

Parameters:
  • port (int) – Port on which connection has been received.

  • call_from (str) – Callsign of station initiating the connection.

  • call_to (str) – Callsign of station receiving the connection.

  • incoming (bool) – True if the connection was initiated by a remote node; False if it was initiated by the client.

  • message (str) – Connection message. This will start with “*** CONNECTED To” for an incoming message, or “*** CONNECTED With” for an outgoing connection.

connected_data(port, call_from, call_to, pid, data)

Called with incoming data from on ongoing connection.

Corresponding frame type: ‘D’

Parameters:
  • port (int) – Port for ongoing connection.

  • call_from (str) – Callsign of station sending the data.

  • call_to (str) – Callsign of station receiving the data.

  • pid (int) – The PID corresponding to the incoming data.

  • data (bytearray) – The incoming data.

disconnected(port, call_from, call_to, message)

Called when an ongoing connection is disconnected, whether by the client, the remote node, or a timeout.

Corresponding frame type: ‘d’

Parameters:
  • port (int) – Port for ended connection.

  • call_from (str) – Callsign of station that initiated the connection.

  • call_to (str) – Callsign of station receiving the connection.

  • message (str) – Disconnection message. In the case of a timeout, this may include the string “RETRYOUT”.

frames_waiting_on_connection(port, call_from, call_to, frames)

Called with the results of a request for the number of frames outstanding on a specified connection.

Corresponding frame type: ‘Y’

Parameters:
  • port (int) – Port for ongoing connection.

  • call_from (str) – Callsign of station initiating the connection.

  • call_to (str) – Callsign of station receiving the connection.

  • frames (int) – The number of outstanding frames for this connection.

monitored_connected(port, call_from, call_to, text, data)

Called when an AX.25 Information (I) frame is received, if monitoring is enabled.

Corresponding frame type: ‘I’

Parameters:
  • port (int) – Port on which frame was received.

  • call_from (str) – Callsign of sending station.

  • call_to (str) – Callsign of destination station.

  • text (str) – Textual representation of frame, in AGWPE format.

  • data (bytearray) – Data associated with the frame.

monitored_supervisory(port, call_from, call_to, text)

Called when an AX.25 Supervisory (S) frame is received, if monitoring is enabled.

Corresponding frame type: ‘S’

Parameters:
  • port (int) – Port on which frame was received.

  • call_from (str) – Callsign of sending station.

  • call_to (str) – Callsign of destination station.

  • text (str) – Textual representation of frame, in AGWPE format.

monitored_unproto(port, call_from, call_to, text, data)

Called when an AX.25 Unproto (U) frame is received, if monitoring is enabled.

Corresponding frame type: ‘U’

Parameters:
  • port (int) – Port on which frame was received.

  • call_from (str) – Callsign of sending station.

  • call_to (str) – Callsign of destination station.

  • text (str) – Textual representation of frame, in AGWPE format.

  • data (bytearray) – Data associated with the frame.

monitored_own(port, call_from, call_to, text, data)

Called when an AX.25 Unproto (U) frame has been sent by the client, if monitoring is enabled, allowing for confirmation of sent frames.

Corresponding frame type: ‘T’

Parameters:
  • port (int) – Port on which frame was sent.

  • call_from (str) – Callsign of sending station.

  • call_to (str) – Callsign of destination station.

  • text (str) – Textual representation of frame, in AGWPE format.

  • data (bytearray) – Data associated with the frame.

monitored_raw(port, data)

Called for all monitored frames when monitoring in raw format has been enabled.

Corresponding frame type: ‘K’

Parameters:
  • port (int) – Port on which frame was received.

  • data (bytearray) – Raw AX.25 frame data.

class pe.handler.DebugReceiveHandler

Bases: pe.ReceiveHandler

A receive handler that logs each method call along with its arguments.

Logging is at the DEBUG level, and may be enabled and disabled by means of the enable_output property.

property enable_output
Query or set the current state of debug logging output.
Type:

bool

version_info(major, minor)

Called with the major and minor version as returned from the server.

Corresponding frame type: ‘R’

Parameters:
  • major (int) – Major version.

  • minor (int) – Minor version.

callsign_registered(callsign, success)

Called with the results of an attempt to register a callsign with the server.

Corresponding frame type: ‘X’

Parameters:
  • callsign (str) – Callsign being registered.

  • success (bool) – True if registration was successful; False otherwise.

port_info(info)

Called with the results of a request for information on available ports.

Each returned port is a string of the form “<number>;<desc>”, being the port number and its description, separated by a semicolon.

Corresponding frame type: ‘G’

Parameters:

info (list[str]) – List of available ports.

port_caps(port, caps)

Called with the results of a request for the capabilities of a specific port.

Corresponding frame type: ‘g’

Parameters:
  • port (int) – Port for which capabilities are provided.

  • caps (PortCaps) – A PortCaps instance for this port.

callsign_heard_on_port(port, heard_call)

Called with the results of a request for a list of callsigns heard on a specified port. This method may be called multiple times for a single request, once for each callsign heard on the port.

Corresponding frame type: ‘H’

Parameters:
  • port (int) – Port for which records were requested.

  • heard_call (HeardCall) – Record of one callsign heard as returned from the server.

frames_waiting_on_port(port, frames)

Called with the results of a request for the number of frames outstanding on a specified port.

Corresponding frame type: ‘y’

Parameters:
  • port (int) – Port for which count is provided.

  • frames (int) – The number of outstanding frames for this port.

connection_received(port, call_from, call_to, incoming, message)

Called with information about a new connection, whether outgoing (i.e. initiated by the client) or incoming (i.e. initiated by a remote node).

Corresponding frame type: ‘C’

Parameters:
  • port (int) – Port on which connection has been received.

  • call_from (str) – Callsign of station initiating the connection.

  • call_to (str) – Callsign of station receiving the connection.

  • incoming (bool) – True if the connection was initiated by a remote node; False if it was initiated by the client.

  • message (str) – Connection message. This will start with “*** CONNECTED To” for an incoming message, or “*** CONNECTED With” for an outgoing connection.

connected_data(port, call_from, call_to, pid, data)

Called with incoming data from on ongoing connection.

Corresponding frame type: ‘D’

Parameters:
  • port (int) – Port for ongoing connection.

  • call_from (str) – Callsign of station sending the data.

  • call_to (str) – Callsign of station receiving the data.

  • pid (int) – The PID corresponding to the incoming data.

  • data (bytearray) – The incoming data.

disconnected(port, call_from, call_to, message)

Called when an ongoing connection is disconnected, whether by the client, the remote node, or a timeout.

Corresponding frame type: ‘d’

Parameters:
  • port (int) – Port for ended connection.

  • call_from (str) – Callsign of station that initiated the connection.

  • call_to (str) – Callsign of station receiving the connection.

  • message (str) – Disconnection message. In the case of a timeout, this may include the string “RETRYOUT”.

frames_waiting_on_connection(port, call_from, call_to, frames)

Called with the results of a request for the number of frames outstanding on a specified connection.

Corresponding frame type: ‘Y’

Parameters:
  • port (int) – Port for ongoing connection.

  • call_from (str) – Callsign of station initiating the connection.

  • call_to (str) – Callsign of station receiving the connection.

  • frames (int) – The number of outstanding frames for this connection.

monitored_connected(port, call_from, call_to, text, data)

Called when an AX.25 Information (I) frame is received, if monitoring is enabled.

Corresponding frame type: ‘I’

Parameters:
  • port (int) – Port on which frame was received.

  • call_from (str) – Callsign of sending station.

  • call_to (str) – Callsign of destination station.

  • text (str) – Textual representation of frame, in AGWPE format.

  • data (bytearray) – Data associated with the frame.

monitored_supervisory(port, call_from, call_to, text)

Called when an AX.25 Supervisory (S) frame is received, if monitoring is enabled.

Corresponding frame type: ‘S’

Parameters:
  • port (int) – Port on which frame was received.

  • call_from (str) – Callsign of sending station.

  • call_to (str) – Callsign of destination station.

  • text (str) – Textual representation of frame, in AGWPE format.

monitored_unproto(port, call_from, call_to, text, data)

Called when an AX.25 Unproto (U) frame is received, if monitoring is enabled.

Corresponding frame type: ‘U’

Parameters:
  • port (int) – Port on which frame was received.

  • call_from (str) – Callsign of sending station.

  • call_to (str) – Callsign of destination station.

  • text (str) – Textual representation of frame, in AGWPE format.

  • data (bytearray) – Data associated with the frame.

monitored_own(port, call_from, call_to, text, data)

Called when an AX.25 Unproto (U) frame has been sent by the client, if monitoring is enabled, allowing for confirmation of sent frames.

Corresponding frame type: ‘T’

Parameters:
  • port (int) – Port on which frame was sent.

  • call_from (str) – Callsign of sending station.

  • call_to (str) – Callsign of destination station.

  • text (str) – Textual representation of frame, in AGWPE format.

  • data (bytearray) – Data associated with the frame.

monitored_raw(port, data)

Called for all monitored frames when monitoring in raw format has been enabled.

Corresponding frame type: ‘K’

Parameters:
  • port (int) – Port on which frame was received.

  • data (bytearray) – Raw AX.25 frame data.