diff --git a/README.md b/README.md index d813dc1cd98365931e614f9e9e95948d128627ab..03541587f6f1cbbace781036b2c250da019573ba 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@  -Skyward Boardcore -[](https://git.skywarder.eu/r2a/skyward-boardcore/commits/master) +Skyward Boardcore +[](https://git.skywarder.eu/scs/skyward-boardcore/commits/master) ------------- Boardcore is a framework for developing and building missile software for custom boards with Miosix . [Miosix](https://miosix.org/) is a lightweigth OS for embedded developing which provides support for basic things such as Threads, GPIO, Time and many other. You can find our fork of the kernel here: [skyward/miosix-kernel](https://git.skywarder.eu/elc/miosix-kernel) -Building is made with [SBS](https://git.skywarder.eu/r2a/skyward-boardcore/wikis/Skyward-Build-Systems-(SBS)), which was created to easily compile and reuse code for different boards. +Building is made with [SBS](https://git.skywarder.eu/scs/skyward-boardcore/wikis/Skyward-Build-Systems-(SBS)), which was created to easily compile and reuse code for different boards. ### Content @@ -28,13 +28,22 @@ In the main folder you will find **sbs.conf** which is used to configure the bui ### Getting Started -Install Python, Git and Miosix toolchain. Also, openocd and clang-format are recommended for a better experience. +#### Dependencies + +* Python3 +* Git +* Miosix toolchain + +Also, openocd, cppcheck and clang-format are recommended for a better experience. + +#### Cloning the repo + Clone this repo with the `--recursive` option and build everything. ``` -git clone --recursive https://git.skywarder.eu/r2a/skyward-boardcore.git +git clone --recursive https://git.skywarder.eu/scs/skyward-boardcore.git cd skyward-boardcore -python sbs -v +python3 sbs -v ``` SBS will start building all the entrypoints. Depending on how many entrypoints there are, this operation can take several minutes. @@ -43,16 +52,8 @@ Once SBS finished, check the resulting message: if every build displays an *OK* ### What's next? -In the [Wiki](https://git.skywarder.eu/r2a/skyward-boardcore/wikis/home) you will find some first-steps **guides** (configuring the IDE, building a firmware etc) as well as the **coding guidelines** and some **best practices** we adopt. - -If you want to contribute to this repository, please read [Git Workflow](https://git.skywarder.eu/r2a/skyward-boardcore/wikis/Git-Workflow). - -If you just want to start messing around, try [this](https://git.skywarder.eu/r2a/skyward-boardcore/wikis/Boardcore-Quick-Start). - +In the [Wiki](https://git.skywarder.eu/scs/skyward-boardcore/wikis/home) you will find some first-steps **guides** (configuring the IDE, building a firmware etc) as well as the **coding guidelines** and some **best practices** we adopt. -Useful links ------------ +If you want to contribute to this repository, please read [Git Workflow](https://git.skywarder.eu/scs/skyward-boardcore/wikis/Git-Workflow). -* [Miosix Wiki](https://miosix.org/wiki/index.php?title=Main_Page) for the installation. -* [Miosix Doxygen](https://miosix.org/doxygen/doxygen_k2.01/index.html) for the full documentation (classes, constants ecc). -* [ELC Handbooks](https://git.skywarder.eu/docs/elc-internal-reports/tree/master) +If you just want to start messing around, try [this](https://git.skywarder.eu/scs/skyward-boardcore/wikis/Boardcore-Quick-Start). \ No newline at end of file diff --git a/sbs b/sbs index 8a4449230b92485761f59ee3d469187fa9c4fda8..d159ba3a51bb38c2280f2f0853a1aa75da16d187 100755 --- a/sbs +++ b/sbs @@ -4,17 +4,17 @@ # # Copyright (c) 2015-2019 Skyward Experimental Rocketry # Authors: Alain Carlucci, Alvise de'Faveri Tron -# +# # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: -# +# # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. -# +# # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -82,7 +82,7 @@ def printBanner(): print("+----------------------------------|___/-------------------v2.0-+") # -# Colorized output helper functions +# Colorized output helper functions # NOTE: I don't know why but an extra \n is added at the end of each line, # so we have to use replace # @@ -110,23 +110,25 @@ def print_make_output(text): # def configCmdParser(): parser = OptionParser() - parser.add_option("-c", "--clean", help="Run a 'make clean'", dest="clean", + parser.add_option("-c", "--clean", help="Run a 'make clean'", dest="clean", action="store_true") parser.add_option("-b", "--build", help="Build a specific entrypoint or test", dest="board") parser.add_option("-l", "--list", help="List all possible configurations", dest="list", default=False, action='store_true') - parser.add_option("-t", "--all-test", help="Build all tests", dest="all_tests", + parser.add_option("-t", "--all-test", help="Build all tests", dest="all_tests", default=False, action='store_true') - parser.add_option("-e", "--all-entrypoint", help="Build all entrypoints", dest="all_entry", + parser.add_option("-e", "--all-entrypoint", help="Build all entrypoints", dest="all_entry", default=False, action='store_true') - parser.add_option("-g", "--gen-faults", help="Generate fault list header files and exit", - dest="genhdr", default=False, action='store_true') - parser.add_option("-v", "--verbose", help="Print a verbose output", dest="log", +# parser.add_option("-g", "--gen-faults", help="Generate fault list header files and exit", +# dest="genhdr", default=False, action='store_true') + parser.add_option("-v", "--verbose", help="Print a verbose output", dest="log", action="store_true") - parser.add_option("-j", "--jobs", - help="Specifies the number of jobs (commands) to run simultaneously.", + parser.add_option("", "--lint", help="Run the linter", dest="lint", + action="store_true") + parser.add_option("-j", "--jobs", + help="Specifies the number of jobs (commands) to run simultaneously.", type="int", dest="JOBS", default=8) - parser.add_option("-n", "--no-colors", help="Don't print colors in the output", dest="colors", + parser.add_option("-n", "--no-colors", help="Don't print colors in the output", dest="colors", default=True, action="store_false") return parser @@ -153,14 +155,14 @@ def parseConf(path): elif stype == 'srcfiles': srcfiles[i] = [x.strip() for x in conf.get(i, 'Files').split("\n")] elif stype == 'board': - entrypoints[i] = { 'id': conf.get(i, 'BoardId'), + entrypoints[i] = { 'id': conf.get(i, 'BoardId'), 'bin': conf.get(i, 'BinName'), 'defines': conf.get(i, 'Defines'), 'files': [entrypoint_mask % conf.get(i, 'Main').strip()] + [x.strip() for x in conf.get(i, 'Include').split(' ')] - } + } elif stype == 'test': - tests[i] = { 'id': conf.get(i, 'BoardId'), + tests[i] = { 'id': conf.get(i, 'BoardId'), 'bin': conf.get(i, 'BinName'), 'defines': conf.get(i, 'Defines') + " -I" + projconf['TESTS_PATH'], 'files': [test_mask % conf.get(i, 'Main').strip()] + @@ -215,10 +217,10 @@ def build_makefile(template, board, bname): for incl in incllist: rmap["PROJECT_INCLUDES"] += incl.strip() + " " - + for lib in liblist: rmap["PROJECT_LIBS"] += lib.strip() + " " - + for sd in subdirs: rmap["PROJECT_SUBDIRS"] += sd.strip() + " " @@ -232,10 +234,10 @@ def build_makefile(template, board, bname): # # Generate fault counter headers # -def genFaultCounters(): - d1 = "data/fault_list.csv" - d2 = SBS_BASE + "/src/shared/diagnostic/FaultCounterData.h" - os.system("python %s/scripts/gen_fault_headers.py %s %s" %(SBS_BASE,d1,d2)) +#def genFaultCounters(): +# d1 = "data/fault_list.csv" +# d2 = SBS_BASE + "/src/shared/diagnostic/FaultCounterData.h" +# os.system("python %s/scripts/gen_fault_headers.py %s %s" %(SBS_BASE,d1,d2)) # # Import srcfiles groups from another .conf file. @@ -282,9 +284,15 @@ if len(make_template) == 0: # # Fault headers generation -if options.genhdr == True: - genFaultCounters() - exit(0) +# if options.genhdr == True: +# genFaultCounters() +# exit(0) + +# Linter +if options.lint == True: + print("[SBS] Executing linter.sh", flush=True) + os.system("%s/scripts/linter.sh %s" % (projconf['SBS_BASE'], projconf['SRC_PATH']) ) + sys.exit(0) # List if options.list == True: @@ -326,16 +334,16 @@ os.mkdir('build') for i in mainfiles: printout('[SBS] %s %s' % (action[1],i), WHITE, BOLD) - + with open('build/%s' % i, 'w') as f: f.write(build_makefile(make_template, mainfiles[i], i)) # stdout printed only in verbose if options.log == True: - p = subprocess.Popen(['make', '-j', str(options.JOBS), '-f', 'build/%s' % i] + p = subprocess.Popen(['make','-j', str(options.JOBS), '-f', 'build/%s' % i] + cleanparam, universal_newlines=True, - #stdout=subprocess.PIPE, + #stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=1) else: @@ -362,4 +370,4 @@ for i in mainfiles: # Clean if options.clean == True: - shutil.rmtree('build',ignore_errors=True, onerror=None) + shutil.rmtree('build',ignore_errors=True, onerror=None) \ No newline at end of file diff --git a/scripts/cppcheck_suppressions_list.txt b/scripts/cppcheck_suppressions_list.txt deleted file mode 100644 index 84fbc0df253990712eeec40ac270a53a17228317..0000000000000000000000000000000000000000 --- a/scripts/cppcheck_suppressions_list.txt +++ /dev/null @@ -1,2 +0,0 @@ -*:src/tests/* - diff --git a/scripts/linter.sh b/scripts/linter.sh index 79792ccfa247a75ddccfc2bb96a2db7dccbe98ce..70dd0adb8d12a393cc67d72cc2051353b27c2b22 100755 --- a/scripts/linter.sh +++ b/scripts/linter.sh @@ -1,38 +1,18 @@ #!/bin/bash -declare -i RESULT=0 +echo '[Linter] Executing cppcheck' +cppcheck --template=gcc -q --std=c++11 --enable=all \ + --suppress=unusedFunction --suppress=missingInclude --suppress=noExplicitConstructor \ + "$@" 2>&1 | awk ' + function color(c,s) { + printf("\033[%dm%s\033[0m\n",30+c,s) + } + /warning/ {color(1,$0);next} + /style/ {color(2,$0);next} + /performance/ {color(3,$0);next} + /information/ {color(4,$0);next} + /portability/ {color(5,$0);next} + {print} + ' -function check { - B=$(eval "$3") - A=$? - echo -n "[LINTER] $2... " - - if [ "$1" == "OUT" ]; then - if [ ${#B} -gt 0 ]; then - A=$1 - fi; - fi; - if [ "$A" == "$1" ]; then - echo -e "FAIL\n------------ OUTPUT ------------" - echo "$B" - echo "--------------------------------" - return 1 - else - echo "OK" - return 0 - fi; -} - -#check 0 "Checking for files with lines longer than 80 characters" 'egrep --include="*.cpp" --include="*.h" -nr ".{81}" src/' -check 0 "Checking for files with lines longer than 120 characters" 'egrep --include="*.cpp" --include="*.h" -nr ".{121}" src/' -RESULT+=$? -check OUT "Checking for files having \n\n\n" "grep -HPcrz '(\\r?\\n){4,}' src | egrep -v ':0$' | cut -d ':' -f 1" -check OUT "Checking for files not having the copyright" "grep -rL '* Permission is hereby granted, free of charge' src/" -check OUT "Checking for tabulations instead of spaces" "grep -Pr '\t' src" -check OUT "MMP wants his full name" "grep -rl 'Matteo Piazzolla' src/" -check OUT "Launching cppcheck" "cppcheck --suppressions-list=./scripts/cppcheck_suppressions_list.txt --template=gcc -q --suppress=unusedFunction --suppress=missingInclude --std=c++11 --enable=all src/ 2>&1" -RESULT+=$? -check OUT "Checking for using namespace in header files" "grep -rl 'using namespace' src | egrep '.h(pp)?$'" -RESULT+=$? - -exit 0 +#exit 0 diff --git a/src/tests/catch/test-packetqueue.cpp b/src/tests/catch/test-packetqueue.cpp index 3e8c2f71b60f6d53c95d680de839347c952990c3..58e6bc12145070d0c6cfc177276686592d99de87 100644 --- a/src/tests/catch/test-packetqueue.cpp +++ b/src/tests/catch/test-packetqueue.cpp @@ -42,7 +42,7 @@ uint8_t buf[BUF_LEN]; inline bool COMPARE(uint8_t* buf, size_t len, const char* expected) { - int i = 0; + size_t i = 0; while (expected[i] != '\0' && i < len) { CAPTURE(i); @@ -240,7 +240,7 @@ TEST_CASE("PacketQueue tests") COMPARE(pq.buffer.get(1), "abcd"); COMPARE(pq.buffer.get(2), "abcdefg"); - + INFO("Popping first element"); p = pq.pop(); // Should still return first packet REQUIRE(p.msgCount() == 3); @@ -263,7 +263,7 @@ TEST_CASE("PacketQueue tests") REQUIRE(pq.countNotEmpty() == 3); REQUIRE_FALSE(pq.isEmpty()); REQUIRE(pq.isFull()); - + COMPARE(pq.buffer.get(0), "abcd"); COMPARE(pq.buffer.get(1), "abcdefg"); COMPARE(pq.buffer.get(2), "0123456789"); @@ -298,7 +298,7 @@ TEST_CASE("PacketQueue tests") REQUIRE(pq.isEmpty()); REQUIRE(pq.countNotEmpty() == 0); REQUIRE(pq.countReady() == 0); - + INFO("Adding empty message") REQUIRE(pq.put(message_base, 0) == -1); diff --git a/src/tests/drivers/test-piksi.cpp b/src/tests/drivers/test-piksi.cpp index c4a604f5190858001bcd8184c12f33112071ecaf..b4e01bc9e9c3983c7bcb311b4bbf29b12195000e 100644 --- a/src/tests/drivers/test-piksi.cpp +++ b/src/tests/drivers/test-piksi.cpp @@ -57,7 +57,7 @@ int main() << " lon: " << gps.longitude << " h: " << gps.height << " vn: " << gps.velocityNorth << " ve: " << gps.velocityEast << " vd: " << gps.velocityDown << " ns: " << gps.numSatellites - << endl; + << " now: " << now; } catch (...) { diff --git a/src/tests/misc/xbee-bitrate.cpp b/src/tests/misc/xbee-bitrate.cpp index 7fbe56c59121279e97df6df67b1a083158339c41..229fa358f1f54b48fc16f47d6aeee8b5aaf8b239 100644 --- a/src/tests/misc/xbee-bitrate.cpp +++ b/src/tests/misc/xbee-bitrate.cpp @@ -95,7 +95,7 @@ bool sendPacket(uint8_t size) snd_buf[0] = '{'; snd_buf[size-1] = '}'; - + for(int i = 0; i < size - 2; i++) { snd_buf[i+1] = ((snd_cntr + i) % 75 ) + 48; //ASCII char from 0 to z @@ -145,7 +145,7 @@ int main() } results[i] = getTick() - start; } - printf("Results for %d byte packet size:\n"); + printf("Results for %d byte packet size:\n", pkt_size); for(int i = 0; i < PKT_NUM; i++) { printf("%d\n", (int)results[i]);