Solutions to the exercises

This is the page to which the solutions will be uploaded. These will mainly consist of gzipped tar files which you can download and unpack.

For the exercise on Linux the are no solutions as these are simple Linux commands to be executed into the bash command interpreter.

  • Solutions to exercise 1: Linux Commands
    There are no solutions to this exercise. We simply try out a series of bash commands
  • Solutions to exercise 2: C programming:
https://iotworkshop.africa/pub/Embedded_Systems/SolutionsToTheExercises/solEx2.tar.gz

  • Solutions to exercise 3: Programming Tools
    Even though there are no solutions to exercise3: Compilations Tools, here are a few Makefile examples nevertheless:
https://iotworkshop.africa/pub/Embedded_Systems/SolutionsToTheExercises/makeExamples.tar.gz

  • Solutions to exercise 4: Raspberry Pi
    There are no solutions to this exercise session because we only use programs that have already been written before.

  • Solutions to exercise 4: LED

    For the mygpio program, these are the tests you must perform in order to make the program safe against wrong input from the user
    • test if the user has given at least 2 arguments namely a string, which should be "read" or "write" and the pin number
      (argv may not be smaller than 3)
    • check if argv[1] is either "read" or "write". Use strcmp to accomplish this
    • if argv[1] is "read", make sure argc is exactly 3
    • if argv[1] is "write", make sure argc is exactly 4
    • convert the pin number from string to integer. You may be tempted to use atoi() but you must not, because atoi() does not check for conversion errors. Use strtol() instead.
    • Make sure the converted pin number is in the range 0..7
      For the "read" case we are done with our checks here
    • for the "write" case convert the logic level and make sure you get either 0 or 1

  • Solutions to the exercises on files, pipes and sockets

    These exercises have been skipped but I attach the solution codes nevertheless such that you can have a look at them and/or use them in a future course
https://iotworkshop.africa/pub/Embedded_Systems/SolutionsToTheExercises/communication.tar.gz

  • Solutions to exercise 5: The DHT11 temperature and humidity sensor

    The code contains an example of how to write a shared library. You can collect all libraries for your course in a common directory (.g. /opt/ucc/lib) as you do for all corresponding include files (/opt/ucc/include). Then you make the directory of libraries globally known to the system by putting a file ucc.conf into /etc/ld.so.conf. ucc.conf simply contains the text /opt/ucc/lib. Finally you run the command sudo ldconf and /opt/ucc/lib will be added to the search path of shared libraries on the system

-- Uli Raich - 2017-10-14

Comments

Topic attachments
I Attachment History Action Size Date Who Comment
Unknown file formatgz communication.tar.gz r1 manage 0.1 K 2017-10-26 - 08:24 UnknownUser  
Unknown file formatgz makeExamples.tar.gz r1 manage 1.7 K 2017-10-14 - 12:59 UnknownUser  
Unknown file formatgz rotaryEncoder.tar.gz r1 manage 6.1 K 2017-10-26 - 09:36 UnknownUser  
Unknown file formatgz solEx2.tar.gz r1 manage 798.9 K 2017-10-14 - 12:53 UnknownUser  
Edit | Attach | Watch | Print version | History: r18 | r6 < r5 < r4 < r3 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r4 - 2017-10-26 - uli
 
  • Edit
  • Attach
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback