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.

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.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: termchar_demo-0.3.0.tar.gz
  • Upload date:
  • Size: 8.7 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.tar.gz
Algorithm Hash digest
SHA256 829e12d852b111b6a8fa4a5594d7c7a539ec6bf45979a6112a2681ee0997ae61
MD5 bd341384e2bde608812693d945f5c9c1
BLAKE2b-256 e9d1ebfb016a40401a96368be4ec2322fbec9fe50d47c3608d304a29f74985d1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: termchar_demo-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • 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-py3-none-any.whl
Algorithm Hash digest
SHA256 93840dabfcd2a9936ba636ff660b67dab3e75c0233e7209881cd27ea68f0ed5e
MD5 4e0cdaa8c01998db0513ea5ec3cd8e64
BLAKE2b-256 8bb60f4e703df333762ea8a6e465de1394b8562daecf46154e4ec16b8d003422

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