hein package¶
Submodules¶
hein.socreceiver module¶
-
class
hein.socreceiver.
SocReceiver
(port, name, buffer_size=1024, connect=True, connectWait=0.5, portname='')¶ Bases:
object
-
__init__
(port, name, buffer_size=1024, connect=True, connectWait=0.5, portname='')¶ Connects to a transmitting port in order to listen for any communication from it. In case the communication drops it will try to reconnect periodically.
- Args:
- port (int): the communication port
- name (str[15]): the name of the receiver, for identification purposes
- buffer_size (int): the size in octet of each listening
- connect (bool): whether to start the connection loop
at initialization. If
False
, useconnect
method. - connectWait (float >0.1): the duration in second between two successive connection attempts
- portname (str[15]): the name of the communicating port, for identification purposes
-
close
()¶ Shuts down the receiver, but not the autoconnect
-
connect
(oneshot=False)¶ If not already connected, starts the connection loop
-
connected
¶ Whether the receiver is connected to the transmitter
-
loopConnect
¶
-
process
(typ, data)¶ Replace this function with proper data processing
-
running
¶ Whether the listening is undergoing
-
stop_connectLoop
()¶ Stops the connection loop, but does not stop the current connection nor communication
-
hein.soctransmitter module¶
-
class
hein.soctransmitter.
SocTransmitter
(port, nreceivermax, start=True, portname='', timeoutACK=1.0)¶ Bases:
object
-
__init__
(port, nreceivermax, start=True, portname='', timeoutACK=1.0)¶ Creates a transmitting socket to which receiving socket can listen.
- Args:
- port (int): the communication socket-port
- nreceivermax (int): the maximum amount of receivers that can listen. From 1 to 5.
- start (bool): whether to start the broadcasting at
initialization or not. If not, use
start
method - portname (str[15]): the name of the communicating port, for identification purposes
- timeoutACK (float): the timeout duration in seconds to wait for
the acknowledgement receipt, or
None
to disable it
-
close
()¶ Shuts the broadcasting down, and forces all receivers to drop listening. The broadcasting can be restarted using
start
.
-
close_receivers
()¶ Forces all receivers to drop listening
-
nreceivers
¶ The number of receivers currently listening to the port. Note that the active receivers are updated at each communication and some receivers may have dropped since then
-
ping
()¶ Pings all receivers to check their health, updates the receivers list and returns the result
-
running
¶ Whether the broadcasting is active or not
-
start
()¶ Initializes and starts the broadcasting on the communication port, if not already started.
-
tell_dict
(**kwargs)¶ Broadcasts a dictionary-type message
- Kwargs:
- the keys-values to merge into a socket-compatible string
-
tell_raw
(txt)¶ Broadcasts a raw-type message
- Args:
- txt (Byt or str): the message
-
tell_report
(**kwargs)¶ Broadcasts a dictionary-type message
- Kwargs:
- the keys-values to merge into a socket-compatible string
-
Module contents¶
Name: | hein |
---|---|
Website: | https://github.com/ceyzeriat/hein |
Author: | Guillaume Schworer |
Version: | 0.1 |
Hein: Advanced Subscriber-Publisher Socket Communication.
Note that Hein is based on Tkinter to display frames of text or graph, and that it is released under the GNU General Public License v3 or later (GPLv3+).
Documentation¶
Refer to this page, http://pythonhosted.org/hein/hein.html
Requirements¶
Hein requires the following Python packages:
- socket: Obviously
- threading, select: for threading and port-reading
- time, os: for basic stuff
- byt: to handle chains of bytes identically no matter the python version
Installation¶
The easiest and fastest way for you to get the package and run is to install Hein through pip:
$ pip install hein
You can also download Hein source from GitHub and type:
$ python setup.py install
Dependency on byt will be installed automatically. Refer to the requirements section. If you have a standard install of python (or any fancier distribution like anaconda), you should be good to go.
Contributing¶
Code writing¶
Code contributions are welcome! Just send a pull request on GitHub and we will discuss it. In the issue tracker you may find pending tasks.
Bug reporting¶
If you think you’ve found one please refer to the issue tracker on GitHub.
Additional options¶
You can either send me an e-mail or add it to the issues/wishes list on GitHub.
Citing¶
If you use Hein on your project, please drop me a line <mailto:{my first name}.{my family name}@gmail.com>, you will get fixes and additional options earlier.
License¶
Hein is released under the GNU General Public License v3 or later (GPLv3+). Please refer to the LICENSE file.