Skip to main content

Termination character demo, a playground to learn about serial communication.

Project description

Termination character demo

Welcome to this termination character demonstration, a playground to learn about serial communication and ways to mark the end of messages exchanged between computers and serial devices like an Arduino, or instruments like an oscilloscope. In these demos, the Client is your computer and the Server is the external device. Note: it is recommended that you make your terminal wide enough to give all widgets some breathing room. This app is written in Python with the ✨awesome✨ Textual framework.

screenshot of basic demo

Play around for a bit! Some suggestions:

  1. Start with the Basic demo: the server will autoreply if a complete message is received.
  2. Try to send a message, with or without manually adding termination characters. Which characters are expected by the Server?
  3. Set the termination characters in the Write Termination Characters field of the client. Send some more messages. What happens?
  4. Try to read messages. Are you required to specify read termination characters?
  5. What happens if you do? Collect at least two replies and try to read them one by one.
  6. Finally, you can try the Advanced demo. Here, you operate both client and server. Play around with various settings for the termination characters and read timeouts. What happens when you try to read, but there is no message yet received?
  7. In the advanced demo, buffers have a finite size. If you try to overflow them, what happens?

Details

The basic and advanced tabs are quite similar, but while the latter tab lets the user change everything, the former lets the user only change the client settings. The server settings mimic an Arduino running bespoke VISA-compliant firmware. Commands sent to the Arduino should be terminated using a line feed, \n, while commands received from the device will be terminated by a carriage return followed by a line feed, \r\n. The basic demo will send a response back to the client each time a message is correctly received.

The interface

The Input Buffer is where commands you send end up before they are explicitly read by a device. They usually have a finite amount of space. The colour of the horizontal bar will indicate the amount of space that is left while the colour of the buffer contents will indicate the presence of the correct termination characters. If the end of a message cannot be determined, the message is shown in red. If the end of the message is missing, the contents are tinted orange. On the other hand, if the message is correctly terminated, it will be displayed in a green colour while the termination characters themselves will be a blueish colour. You can type the termination characters explicitly at the end of each message, or you can set them once in the Write Termination Characters widget. If you do that, each time you send a message the termination characters are added to the end automatically. Click the Read button to read messages from the input buffer. If the Read Termination Characters are not set correctly the application may keep waiting or display some gibberish at the end of each message. The Application Log records all messages that are sent and received. The Timeout on the advanced tab lets the user set read timeouts. If they are set to 0 the device will not stop reading before a complete message is received. If the timeout is set to n, the read will abort if there is no complete message received after n seconds.

Background

Computers and digital devices often need to communicate with each other. Over the course of many years, a plethora of communication standards and protocols have been developed. They usually involve exchanging some sort of messages. While reading and writing it is important to mark the end of a message so that the device will know when to stop reading and start processing. In many protocols this is usually done with one or two special characters, the so-called termination characters.

In simple protocols where short messages are exchanged the termination characters are usually one form of end-of-line-characters. Such characters were introduced in the early days of (electronic) typewriters, where a carriage return would mean return to the beginning of the line and a line feed would mean move to the next line. A typewriter has a handle which you can use to move the carriage back to the start of the line and, simultaneously, feed the paper to move to the next line. Such control characters survive to this day to mark the end of lines in text files on computers. A carriage return is usually denoted \r in languages like C and Python, and a line feed is similarly denoted as \n. DOS-derived operating systems like Windows use a carriage return + line feed \r\n as a line ending, while Unix-derived operating systems like macOS and Linux only use line feed \n for line endings. To this day, this can confuse users when they exchange text files between different OSes.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

termchar_demo-0.3.0.post2.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

termchar_demo-0.3.0.post2-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file termchar_demo-0.3.0.post2.tar.gz.

File metadata

  • Download URL: termchar_demo-0.3.0.post2.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.13 Darwin/24.0.0

File hashes

Hashes for termchar_demo-0.3.0.post2.tar.gz
Algorithm Hash digest
SHA256 81d4fe8e8a19dc5718c8db7320568bee3b09713b9678efd01e6cea36c0c620e0
MD5 d1d9bc4405c61bac84a3c5c916d35a92
BLAKE2b-256 ac687c8d86641b14142ce7b9073f28dbd4b575d052823c19312b947b52b36074

See more details on using hashes here.

File details

Details for the file termchar_demo-0.3.0.post2-py3-none-any.whl.

File metadata

File hashes

Hashes for termchar_demo-0.3.0.post2-py3-none-any.whl
Algorithm Hash digest
SHA256 9e3dce5e17dfc9201d64b15b0251eda929042431c118fc594751f0c304ad38ab
MD5 957762776400f2a2f4dde5707d01408b
BLAKE2b-256 f64a2a9ee00ca85edff5458ceb6f1e2b061e1dd5de3050c502622494fb1b6d42

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page