Warning
This page is located in archive. Go to the latest version of this course pages. Go the latest version of this page.

Lab09 - Terminal thread command interface

This excersise provides description of the PC based application and requirements related to this application. The app is expected to join all the previously explained components together. Mainly it will use these parts:

  • lab01 - compilation principles
  • lab04 - serial port access
  • lab06 - threads for serial line communication
  • hw01 - skeleton of the console application

The final application will be named: NucTer.

Requirements

The application will allow for:

  • Communication with Nucleo RE401 over serial line with text commands
  • Issuing single commands - the commands are described at lab10.
  • Providing possibility to open an imput file and read the commands from the input file - the example of a data set is here: lab12.
  • Allow for input file flow control as it is described here in this description.
  • Command line parameters interface to be able to automate the data set operation.
  • Standard and Error outputs which can be redirected to separate files. The standard output is used for user communication and the error output is used for bad command and other error logging (e.g. bad open result).

Hints

This section provides some advices related to single tasks.

Thread

  • The application will use the main thread to communicate with user to alow him to select the available options. The execution of the application can be paused by p key.
  • The communication with the device and packet composition with asynchronous data from joystick will be processed by second thread.
  • Third thread can be used to work on data set and flow control file readings (usage of the thread for this task is optional).

Command line interface

The application will allow to pass these paramters on the command line:

  • The communication port designation, e.g.: /dev/ttyACM0.
  • A data set description, e.g. list of commands: lab12.
  • A control flow file - see below.

Standard and error outputs

The standard output will be used for user interaction. The error output will be used to report problems with serial port access (open, read, write, close) and commands problems, e.g. wrong command reporting: lab10.

Input file and its flow control

The input data set is just a list of commands in a text file which will be read one by one and send to the device. The responses will be available through standard and error output.

The flow control file will alow for usign the predefined data sets and sending specific commands to the device in relation with the user actions - mainly the joystick movements.

The flow control file is divided into sections:

// comment line 
#label:PartA: //start of a block

#label:PartB:

#label:PartC:

#label:PartD:

Every section will use a set of commands

// comment line 
#label:PartA: //start of a block
*IDN?
LED OFF
#goto:PartB:

#label:PartB:

or the commands can be read from external file

// comment line 
#label:PartA: //start of a block
#include:InitDataSet.txt: // the TXT file contains just a list of commands, e.g.: "*IDN?\nLED OFF\n"

#label:PartB:

The flow control is controlled mainly by the joystic unit

// comment line 
#label:PartA: //start of a block
#include:InitDataSet.txt: // the TXT file contains just a list of commands, e.g.: "*IDN?\nLED OFF\n" 

#label:PartB:
#include:IntroDataSet2.txt: // e.g.: "DRAW:SETFONT 12\nDRAW:TEXT 64,120,Press: Up or Down,1\n" 
// wait for joystick for 5 seconds - if no action then use JOY_NONE = it will go to else section
#wait_for_joystick:5000:JOY_NONE:
#if:JOY_UP:goto:PartD:
#if:JOY_DOWN:goto:PartC:
#else:goto:PartB:

#label:PartD:
// nothing, file is finished and the app closes itself
#exit:

#label:PartC
DRAW:CLEAR 2
DRAW:SETTEXTCOLOR BLACK 
DRAW:CIRCLE 49,20,10
DRAW:CIRCLE 79,20,10
DRAW:SETTEXTCOLOR 2 
DRAW:LINE 55,40,60,45 
DRAW:LINE 68,45,73,40 
DRAW:LINE 60,45,68,45 
DRAW:SETFONT 12
DRAW:TEXT 64,120,Nucleo RULEZ!,1
DRAW:TEXT 64,120,Press Left or Right!,1
// no parameter for #wait_for_joystick = wait forewer
#wait_for_joystick:
#if:JOY_LEFT:goto:PartA:
#if:JOY_RIGHT:goto:PartB:
#else:goto:PartC:

courses/be5b99cpl/labs/lab09.txt · Last modified: 2019/11/27 13:10 by pacesp