Assignment One: Encoder / Decoder

For this assignment, you will write a function with the following prototype:

char* code(char*);

Provided for you is a main.c file that will do the work of obtaining user input. Do not modify this file. You will write your implementation of this function in the code.c file.

How It Works

> hello
104 101 108 108 111
> 104 101 108 108 111
> secret message
115 101 99 114 101 116 32 109 101 115 115 97 103 101
> 115 101 99 114 101 116 32 109 101 115 115 97 103 101
secret message

The function should first test to see whether the input given is text (characters a-z and A-Z) or a list of numbers (characters 0-9). Then, if it is text, it should output the decimal value of each character separated by spaces. If it is a list of numbers, it should output the ascii characters represented by the values.


  1. You may not use any libc functions such as atoi()
  2. You may not declare any more global variables beyond the provided char buf[128]

Using Screen or Minicom

To actually interact with the program running on the MSP430, you must use a tool on your machine that can listen directly to the USB port. There are two such tools: screen and minicom. I would recommend using screen initially, but minicom is a little more powerful. To listen to the USB port that you've connected the board to, execute

screen /dev/ttyACM0 9600

on Linux or

screen /dev/tty.uart-<tab> 9600

under macOS. You must actually press the tab key, not type <tab> out as the remaining name of the device is a serial number that will be different for every board.

Rotating Jumpers

For the communication between your machine and the launchpad to work correct you need to rotate two jumpers 90 degrees. Please see the picture below. This is the HW UART configuration etched into the circuit board to the left. Ensure this is how they are arranged on your board.