Part 3: How to display the encoder output
Now is the time to encode your own words to communicate in Morse code!
The final part of this tutorial is the integration of a service that will send an input words in order to be encoded into Morse code, by the encoder application. We can use various types of services that provide the text input like, for example, a string input, microphones, our computer, or even an application that generates words. After this addition, we will have a complete Morse project.
For this tutorial, we decided to use a serial communication driver so that we can send words from the keyboard of our computer, which will be translated into Morse code and displayed to a LED light on the electronic boards. This serial driver is a commonly used component at Luos and is called a pipe.
2. Explore the pipe driver utilty
The pipe is a Luos pre-specified driver which is responsible for serially receiving and sending data, from and to a computer, an RPI, etc. Its only responsability is to pass the data received from the embedded system to the higher level, and to pass the data received from the high level to the embedded system.
The pipe service is a part of the embedded network like any other Luos service.
For this reason it has the same basic functions that any other service:
Pipe_Loop(). Each time it receives a frame of data, it stores it to a buffer and waits for another service to ask for it. When a service asks for the data (
GET_CMD message), the pipe sends the stored data to the requiring service (
In our project (if your remember well from the previous steps), the encoder application demanded to the pipe to be updated every 10ms. So the moment that we will integrate the pipe to the project, it will send the data (if they exist) to the encoder, every 10ms.
If you want more information about the pipe, you can check the corresponding documentation page.
You can explore all the Luos services examples that we have created for you here.
3. Integrate the pipe service into our Morse encoder:
The pipe is integrated into your Luos project.
Compile your project and check that you have no errors.
You are ready: because the encoder app is looking for a
Pipe services as an input, this will directly work!
7. Encode your words to Morse Code
You are now ready to send some characters in your MCU, and see the encoded Morse result in the LED of your board.
Specify port configuration parameters
In order to send characters, we will use the monitoring console provided by PlatformIO.
First we need to define the baudrate of our serial USB port and to configure the monitoring parameters in the file platformio.ini.
You cn see an example of the file
platformio.ini, after adding the monitoring part.
; PlatformIO Project Configuration File
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
; Please visit documentation for the other options and examples
platform = ststm32
board = ; your board
framework = stm32cube
build_unflags = -Os
-DLUOSHAL= ; your board LuosHAL
lib_extra_dirs = lib/
debug_tool = stlink
upload_protocol = stlink
; Monitoring port config
monitor_speed = 1000000
It is now time to compile your project and flash your MCU with your code. Click on the upload button of PlatformIO. You should finally see that your code is uploaded successfully.
Then click to the Serial Monitor button in platformIO:
You should see a miniterm console open, which shows the configuration of your serial port.
You can now send the sequence of the characters that you want to encode.
Do not forget to press the “Enter” button after the end of each of your words.
Below you can see an example of sending the word “hello”.
Congratulations! You have arrived at the end of this project. You can now communicate in Morse code with everybody existing on this earth (or not 👽).