kiss
KISS TNC Protocol Client
A client implementation for the KISS TNC protocol, providing send and receive capability via a TCP/IP connection. All commands are supported in sending to the TNC; per the spec, only data frames are supported when receiving from the TNC. Multi-port TNCs are supported.
- Protocol reference:
Classes
KISS command values as defined in the spec. |
|
A connection to a KISS TNC. |
Package Contents
- class kiss.Command(*args, **kwds)
Bases:
enum.EnumKISS command values as defined in the spec.
These commands are valid only when sending.
- DATA_FRAME = 0
Data frame
- TX_DELAY = 1
Transmitter keyup delay
- PERSISTENCE = 2
Persistence
- SLOT_TIME = 3
Slot interval
- TX_TAIL = 4
Transmitter hold up time
- FULL_DUPLEX = 5
Set for full duplex, clear for half duplex
- SET_HARDWARE = 6
TNC-specific command
- RETURN = 255
Exit KISS mode
- class kiss.Connection(callback)
A connection to a KISS TNC.
Create an instance of this to communicate with the TNC. The callback function will be invoked with each complete KISS frame received from the TNC.
- Parameters:
callback (function or None) – Callback function to invoke with each received frame. The function takes the form
receive_callback(kiss_port, data)wherekiss_portis the port number on which the frame was received, anddatais a bytearray. Optional. Can be omitted if the client has no interest in received frames (e.g. for a one-shot beaconing application).
- connect_to_server(host=DEF_HOST, port=DEF_PORT)
Connect to the KISS TNC.
Call this before any other methods on this class. It is an error to call this again once connected. However, an instance may be reused by connecting again after disconnection.
- Parameters:
host (str) – The host to which to connect.
port (int) – The port on which to connect.
- disconnect_from_server()
Disconnect from the KISS TNC. Do not call other methods on this class after this call, except to (re)connect to a server. Calling this method when not connected is a no-op.
- send_data(data, port=0)
Send the provided data in a data frame.
- Parameters:
data (bytes or bytearray) – Data to be sent.
port (int) – KISS port number.
- set_tx_delay(tx_delay, port=0)
Set the transmitter keyup delay, in 10 ms units.
- Parameters:
tx_delay (int) – Transmitter keyup delay.
port (int) – KISS port number.
- set_persistence(persistence, port=0)
Set the ‘p’ persistence value.
- Parameters:
persistence (int) – The ‘p’ value, in the range 0 - 255.
port (int) – KISS port number.
- set_slot_time(slot_time, port=0)
Set the slot interval, in 10 ms units.
- Parameters:
slot_time (int) – Slot interval.
port (int) – KISS port number.
- set_tx_tail(tx_tail, port=0)
Set the post-TX hold up time, in 10 ms units.
- Parameters:
tx_tail (int) – Transmit hold up time.
port (int) – KISS port number.
- set_full_duplex(full_duplex, port=0)
Set full duplex on or off.
- Parameters:
full_duplex (bool) – True for full duplex; False for half duplex.
port (int) – KISS port number.
- set_hardware(hardware, port=0)
Set a TNC-specific hardware value.
- Parameters:
hardware (bytes or bytearray) – TNC-specific data.
port (int) – KISS port number.
- send_return()
Send the special return command to exit KISS.