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

Covid HW 05 - Interaction with the PC

This HW is extension of the previous HW. The expected deliverables are two files (to be uploaded into BRUTE):

  • main.c for the Nucleo board (please, do not upload the whole Eclipse project)
  • chw05.c as the control program on PC

The concept of this exercise is to comunicate from your program (chw05.c) with the Nucleo code (main.c) with string commands while simultaneously the button is still capable to control the LED light

These parameters will be evaluated:

  • the communication protocol is non trivial:
    • the command has more then one character and
    • ends with \r\n characters
    • describe the communication commands in the comment section of your source code
  • Both sides are saving the incomming data into a buffer and detect the end of the message by checking \r\n end characters
  • Both sides properly initialize the communication interface - serial line
  • The PC program works in the loop and do not wait for the Enter to be pressed - please see the example of the code in the lecture slides which allows to switch the terminal input mode for direct reading of the keyboard buffer.
    • When 'o' is pressed on the computer the “LED ON\r\n” command is send to the Nucleo and Nucleo will switch the LED ON
    • When 'f' is pressed on the computer the “LED OFF\r\n” command is send to the Nucleo and Nucleo will switch the LED OFF
    • When 'b' is pressed on the computer the “BUTT:STATUS?\r\n” command is send to the Nucleo and Nucleo will reply with
      • “BUTTON:PRESSED” and the program shows the user message claiming “Nucleo claims the button is down!”
      • “BUTTON:RELEASED” and the program shows the user message claiming “Nucleo claims the button is up!”
    • When 'c' is pressed the PC program will wait for a string which is send to Nucleo as a custom command. There is no handler for custom command at the Nucleo side so the Nucleo will reply “Wrong command” with “\r\n” characters and the user will see message claiming “Nucleo claims it does not know the command.”
  • Both sides are capable to add “\r\n” characters to the strings which are send over the serial line
  • Both sides are capable to remove “\r\n” characters form incomming data from the serial line
  • the PC program is capable to get one command line parameter which is the path to the USB/serial interface: such as “/dev/ttyACMx”
  • The hardwired button on the Nucleo is still capable to control the LED light - when pressed the LED is ON when released the LED behaves according to the last command received from the computer.
courses/be5b99cpl/hw/hw05c.txt · Last modified: 2020/11/06 14:42 by pacesp