My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

mftest 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. #!/usr/bin/env bash
  2. #
  3. # mftest [name] [index]
  4. #
  5. # Set configuration options based on a test
  6. # By default it will do megaatmega2560
  7. # Use 'mftest -' to pick from the list.
  8. #
  9. MFINFO=$(mfinfo) || exit 1
  10. [[ -d Marlin/src ]] || { echo "Please 'cd' up to repo root." ; exit 1 ; }
  11. TESTPATH=buildroot/share/tests
  12. STATE_FILE=$( echo ./.pio/.mftestrc )
  13. shopt -s extglob nocasematch
  14. # Get the environment and test number from the command
  15. TESTENV=${1:-'-'}
  16. CHOICE=${2:-0}
  17. # Allow shorthand for test name
  18. case $TESTENV in
  19. tree) platformio run --project-dir . -e include_tree ; exit 1 ;;
  20. due) TESTENV='DUE' ;;
  21. esp) TESTENV='esp32' ;;
  22. lin*) TESTENV='linux_native' ;;
  23. lpc?(8)) TESTENV='LPC1768' ;;
  24. lpc9) TESTENV='LPC1769' ;;
  25. m128) TESTENV='megaatmega1280' ;;
  26. m256) TESTENV='megaatmega2560' ;;
  27. mega) TESTENV='megaatmega2560' ;;
  28. stm) TESTENV='STM32F103RE' ;;
  29. f1) TESTENV='STM32F103RE' ;;
  30. f4) TESTENV='STM32F4' ;;
  31. f7) TESTENV='STM32F7' ;;
  32. teensy) TESTENV='teensy31' ;;
  33. t31) TESTENV='teensy31' ;;
  34. t32) TESTENV='teensy31' ;;
  35. t35) TESTENV='teensy35' ;;
  36. t36) TESTENV='teensy35' ;;
  37. # Build with the last-built env
  38. -r) [[ -f "$STATE_FILE" ]] || { echo "No previous (-r) build state found." ; exit 1 ; }
  39. read TESTENV <"$STATE_FILE"
  40. platformio run --project-dir . -e $TESTENV
  41. exit
  42. ;;
  43. # A -y may come first
  44. -y) TESTENV=${2:-'-'} ; CHOICE=${3:-0} ;;
  45. -[a-z]) echo "Unknown flag $TESTENV" ; exit 1 ;;
  46. -) ;;
  47. esac
  48. # Matching patterns
  49. ISNUM='^[0-9]+$'
  50. ISCMD='^(restore|opt|exec|use|pins|env)_'
  51. ISEXEC='^exec_'
  52. ISCONT='\\ *$'
  53. # List available tests and ask for selection
  54. if [[ $TESTENV == '-' ]]; then
  55. IND=0
  56. NAMES=()
  57. for FILE in $( ls -1 $TESTPATH/*-tests )
  58. do
  59. let IND++
  60. TNAME=${FILE/-tests/}
  61. TNAME=${TNAME/$TESTPATH\//}
  62. NAMES+=($TNAME)
  63. (( IND < 10 )) && echo -n " "
  64. echo " $IND) $TNAME"
  65. done
  66. echo
  67. for (( ; ; ))
  68. do
  69. read -p "Select a test to apply (1-$IND) : " NAMEIND
  70. [[ -z "$NAMEIND" ]] && { echo '(canceled)' ; exit 1 ; }
  71. [[ $NAMEIND =~ $ISNUM ]] && ((NAMEIND >= 1 && NAMEIND <= IND)) && { TESTENV=${NAMES[$NAMEIND-1]} ; echo ; break ; }
  72. echo "Invalid selection."
  73. done
  74. fi
  75. # Get the contents of the test file
  76. OUT=$( cat $TESTPATH/$TESTENV-tests 2>/dev/null ) || { echo "Can't find test '$TESTENV'." ; exit 1 ; }
  77. # Count up the number of tests
  78. # TODO: List test descriptions with numbers
  79. TESTCOUNT=$( awk "/$ISEXEC/{a++}END{print a}" <<<"$OUT" )
  80. # User entered a number?
  81. (( CHOICE && CHOICE > TESTCOUNT )) && { echo "Invalid test index '$CHOICE' (1-$TESTCOUNT)." ; exit 1 ; }
  82. if [[ $CHOICE == 0 ]]; then
  83. # List test descriptions with numbers
  84. echo "Available '$TESTENV' tests:" ; echo "$OUT" | {
  85. IND=0
  86. SED=$(which gsed || which sed)
  87. while IFS= read -r LINE
  88. do
  89. if [[ $LINE =~ $ISEXEC ]]; then
  90. DESC=$( "$SED" -E 's/^.+"(.*)".*$/\1/g' <<<"$LINE" )
  91. (( ++IND < 10 )) && echo -n " "
  92. echo " $IND) $DESC"
  93. fi
  94. done
  95. }
  96. CHOICE=1
  97. if [[ $TESTCOUNT > 1 ]]; then
  98. for (( ; ; ))
  99. do
  100. read -p "Select a '$TESTENV' test (1-$TESTCOUNT) : " CHOICE
  101. [[ -z "$CHOICE" ]] && { echo '(canceled)' ; exit 1 ; }
  102. [[ $CHOICE =~ $ISNUM ]] && ((CHOICE >= 1 && CHOICE <= TESTCOUNT)) && break
  103. echo ">>> Invalid test index '$CHOICE'."
  104. done
  105. fi
  106. fi
  107. # Finally, run the specified test lines
  108. echo "$OUT" | {
  109. IND=0
  110. GOTX=0
  111. CMD=""
  112. while IFS= read -r LINE
  113. do
  114. if [[ $LINE =~ $ISCMD || $GOTX == 1 ]]; then
  115. ((!IND)) && let IND++
  116. if [[ $LINE =~ $ISEXEC ]]; then
  117. ((IND++ > CHOICE)) && break
  118. else
  119. ((!HEADER)) && {
  120. HEADER=1
  121. echo -e "\n#\n# Test $TESTENV ($CHOICE) $DESC\n#"
  122. }
  123. ((IND == CHOICE)) && {
  124. GOTX=1
  125. [[ $CMD == "" ]] && CMD="$LINE" || CMD=$( echo -e "$CMD$LINE" | sed -e 's/\\//g' )
  126. [[ $LINE =~ $ISCONT ]] || { echo $CMD ; eval "$CMD" ; CMD="" ; }
  127. }
  128. fi
  129. fi
  130. done
  131. }
  132. # Get a -y parameter the lazy way
  133. [[ "$2" == "-y" || "$3" == "-y" ]] && BUILD_YES='Y'
  134. # Build the test too?
  135. if [[ $BUILD_YES != 'Y' ]]; then
  136. echo
  137. read -p "Build $TESTENV test #$CHOICE (y/N) ? " BUILD_YES
  138. fi
  139. [[ $BUILD_YES == 'Y' || $BUILD_YES == 'Yes' ]] && {
  140. platformio run --project-dir . -e $TESTENV
  141. echo "$TESTENV" >"$STATE_FILE"
  142. }