Skip to content
This repository was archived by the owner on Apr 23, 2025. It is now read-only.

Latest commit

 

History

History
 
 

README.rst

Examples

This folder contains several code examples of the use of python4yahdlc.

The code examples work in pairs: send_data_frame.py works with receive_data_frame.py and fsm_endpoint_1.py works with fsm_endpoint_2.py.

Setting up a virtual serial bus

To make the two code examples of each pair work together, you need a serial bus of communication. The easiest way to set up a serial bus is to use a virtual one. socat is a great tool for carrying out this task:

socat -d -d socat -d -d pty,raw,echo=0 pty,raw,echo=0

This command will create two virtual devices such as /dev/pts/5 and /dev/pts/6. Everything you write in /dev/pts/5 will be echoed in /dev/pts/6 and vice versa.

send_data_frame.py and receive_data_frame.py

These two code examples need pyserial as dependency:

pip3 install --upgrade pyserial

fsm_endpoint_1.py and fsm_endpoint_2.py

These two code examples need pyserial and fysom as dependencies:

pip3 install --upgrade pyserial fysom

fysom is used to define the Finite-State Machines (FSM) of the two endpoints.

The sending FSM endpoint:

FSM Endpoint 1

The receiving FSM endpoint:

FSM Endpoint 2