Files
2023-Webservices_And_Applic…/docs/tcp_cmd_interface.md
2026-01-11 14:53:50 +01:00

4.2 KiB

TCP CMD Interface

Introduction

The tcp cmd interface is a way to control the device over TCP. It is a simple protocol that allows the user to send commands to the device and receive responses. The protocol looks like bash commands. The commands are separated by a new line character (\n). The response is sent after the command is executed. The response is also terminated by a new line character (\n).

Table of contents

Usage of TCP CMD Interface

Connecting to the device

The device can be connected to using a TCP client. The device will listen on port 23. The device will send a welcome message when a client connects.

On Linux, the device can be connected to using the nc command:

nc <ip-address> 23

Sending commands

Commands can be sent to the device by typing them in the terminal and pressing enter. The device will execute the command and send a response.

Available commands

help

The help command will print a list of available commands.

$> help
help                    : shows a list of commands
text "<text>"           : puts text on the lcd
color (<a>) <r> <g> <b>       : set the background color of the lcd
textColor (<a>) <r> <g> <b>   : set the color of the text
listImages              : shows a list with images in the filesystem
setImage  <image_name>  : put an image on the screen
setGif    <image_name>  : put a gif on the screen
exit                    : closes the connection

text

The text command will print the given text on the screen. The text can be one or multiple words. one word does'n need quotes, multiple words do. The text will rapp around when it reaches the end of the screen.

$> text "Hello World!"

bgcolor

The bgcolor command will set the background color of the screen. The color can be provided in 2 ways: as three numbers between 0 and 255 and one hex value. The first number is the red value, the second is the green value and the third is the blue value. It also has the possible to set the alpha value as the first parameter, this is optional.

bgcolor 255 0 0

or

bgcolor 0xFF0000

color

The color command will set the color of the text. The color can be provided in 2 ways: as three numbers between 0 and 255 and one hex value. The first number is the red value, the second is the green value and the third is the blue value. It also has the possible to set the alpha value as the first parameter, this is optional.

color 255 0 0

or

color 0xFF0000

listImages

The listImages command will print a list of images that are present in the filesystem.

$> listImages
  image1.bmp
  image2.bmp
  image3.bmp
  gif1.gif
  ...

setImage

The setImage command will put an image on the screen. The image must be present in the filesystem. If the image is not present in the filesystem, the device will send an error message. This function only works for BMP images, if you give any other file type, the device will send an error message. You can also provide the starting x and y coordinates as optional parameters. If no coordinates are provided, the image will be placed at the top left corner of the screen (0,0).

$> setImage image1.bmp

or

$> setImage image1.bmp 128 64

setGif

The setGif command will put a gif on the screen. The gif must be present in the filesystem. If the gif is not present in the filesystem, the device will send an error message. This function only works for GIF images, if you give any other file type, the device will send an error message. You can also provide the starting x and y coordinates as optional parameters. If no coordinates are provided, the gif will be placed at the top left corner of the screen (0,0).

$> setGif gif1.gif

or

$> setGif gif1.gif 128 64