Devuan fork of gpsd
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

118 lines
2.8 KiB

  1. #!/bin/sh
  2. #
  3. # The regression-test driver script for the nmea2000 driver.
  4. # CAN is a bit different from normal serial interfaces.
  5. #
  6. GPSD_PORT=2948
  7. CAN_PLAYER=canplayer
  8. CAN_UNIT="vcan0"
  9. BUILD=0
  10. # Requires GNU date extensions
  11. # Should return an empty blank string if those are not present.
  12. STARTTIME=`date +"%s" 2>/dev/null`
  13. # We need to have the build directory in $GPSD_HOME to find the new gpsd
  14. if [ "`dirname $0`" = "." ]; then
  15. GPSD_HOME=`pwd`
  16. else
  17. GPSD_HOME=`dirname $0`
  18. fi
  19. version()
  20. {
  21. echo
  22. echo `basename $0`" : Version v0.20";
  23. echo
  24. }
  25. usage()
  26. {
  27. version;
  28. echo "usage :" `basename $0` " [-S <portnumber>] [-u <can_device>] [-p <canplayer>] [-b] <testfile>";
  29. echo " :" `basename $0` " -v";
  30. echo " :" `basename $0` " -h";
  31. echo " Options include:";
  32. echo " -S <portnumber> = Port for gpsd communication. Default is 2948.";
  33. echo " -u <can_device> = Used CAN device. Default is \"vcan0\"";
  34. echo " -p <canplayer> = Programm to replay logfile. Default is \"canplayer\"";
  35. echo " -b = Create testfile.chk instead of checking it.";
  36. echo " -v = Print version and exit.";
  37. echo " -h = Print this helptext and exit.";
  38. echo " <testfile> = A file created by \"candump -l <can_device> ><testfile>\".";
  39. echo
  40. }
  41. device()
  42. {
  43. echo
  44. echo "CAN device \"${CAN_UNIT}\" do not exit."
  45. echo "Try: sudo ./gpsinit vcan "
  46. echo
  47. }
  48. can_utils()
  49. (
  50. echo
  51. echo "Command to play CAN logfile \"${CAN_PLAYER}\" do not exist."
  52. echo "Try to install \"can-utils\" from your distribution."
  53. echo "I your distibution do not provide \"can-utils\", then"
  54. echo "git clone https://gitorious.org/linux-can/can-utils.git"
  55. echo "in a directory outside of gpsd, build and install it."
  56. echo "On most linux systems, \"make\", and then \"sudo make install\" works."
  57. echo
  58. )
  59. while getopts :S:u:p:vhb opt
  60. do
  61. case ${opt} in
  62. S) GPSD_PORT=${OPTARG};;
  63. u) CAN_UNIT=${OPTARG};;
  64. p) CAN_PLAYER=${OPTARG};;
  65. b) BUILD=1;;
  66. v) version; exit 0;;
  67. h) usage; exit 0;;
  68. \?) usage; exit 1;;
  69. esac
  70. done
  71. shift $((${OPTIND} - 1))
  72. if [ -z $1 ]; then usage; exit 1; fi
  73. TEST_FILE=$1
  74. if [ `ifconfig -a | grep ${CAN_UNIT} | wc -c` -eq 0 ]; then device; exit 1; fi
  75. if [ `command -v ${CAN_PLAYER} | wc -c` -eq 0 ]; then can_utils; exit 1; fi
  76. TMP_PID_FILE=`mktemp`
  77. TMP_OUT_FILE=`mktemp`
  78. ${GPSD_HOME}/gpsd -n -G -D0 -S ${GPSD_PORT} -P ${TMP_PID_FILE} nmea2000://${CAN_UNIT}
  79. sleep 1
  80. ${GPSD_HOME}/gpspipe -d -r -w -S -o ${TMP_OUT_FILE} :${GPSD_PORT}
  81. sleep 1
  82. ${CAN_PLAYER} -I${TEST_FILE} ${CAN_UNIT}=can0
  83. sleep 1
  84. kill `cat ${TMP_PID_FILE}`
  85. sleep 1
  86. if [ ${BUILD} -ne 0 ]
  87. then
  88. cp ${TMP_OUT_FILE} ${TEST_FILE}.chk
  89. else
  90. diff ${TEST_FILE}.chk ${TMP_OUT_FILE}
  91. fi
  92. rm -f ${TMP_PID_FILE}
  93. rm -f ${TMP_OUT_FILE}