From b218f4c799eadb836bd89a498f10a5ebe97f3b63 Mon Sep 17 00:00:00 2001
From: Rousseau Vincent <vincent.rousseau@irstea.fr>
Date: Fri, 27 Jul 2018 12:01:05 +0200
Subject: [PATCH] Close device

---
 CMakeLists.txt         | 54 +-----------------------------------------
 README.md              |  2 ++
 scripts/stream_node.py | 13 +++++-----
 3 files changed, 9 insertions(+), 60 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 13d32ad..a8a9a16 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,7 +1,7 @@
 cmake_minimum_required(VERSION 2.8.3)
 project(labjack_driver)
 
-set(${PROJECT_NAME}_CATKIN_DEPS rospy std_msgs)
+set(${PROJECT_NAME}_CATKIN_DEPS std_msgs)
 
 ## Find catkin macros and libraries
 ## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
@@ -12,63 +12,11 @@ find_package(catkin REQUIRED COMPONENTS ${${PROJECT_NAME}_CATKIN_DEPS})
 ## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html
 # catkin_python_setup()
 
-################################################
-## Declare ROS dynamic reconfigure parameters ##
-################################################
 
-## To declare and build dynamic reconfigure parameters within this
-## package, follow these steps:
-## * In the file package.xml:
-##   * add a build_depend and a run_depend tag for "dynamic_reconfigure"
-## * In this file (CMakeLists.txt):
-##   * add "dynamic_reconfigure" to
-##     find_package(catkin REQUIRED COMPONENTS ...)
-##   * uncomment the "generate_dynamic_reconfigure_options" section below
-##     and list every .cfg file to be processed
-
-## Generate dynamic reconfigure parameters in the 'cfg' folder
-# generate_dynamic_reconfigure_options(
-#   cfg/DynReconf1.cfg
-#   cfg/DynReconf2.cfg
-# )
-
-###################################
-## catkin specific configuration ##
-###################################
-## The catkin_package macro generates cmake config files for your package
-## Declare things to be passed to dependent projects
-## INCLUDE_DIRS: uncomment this if you package contains header files
-## LIBRARIES: libraries you create in this project that dependent projects also need
-## CATKIN_DEPENDS: catkin_packages dependent projects also need
-## DEPENDS: system dependencies of this project that dependent projects also need
 catkin_package(
-#  INCLUDE_DIRS include
-#  LIBRARIES labjack_driver
   CATKIN_DEPENDS ${${PROJECT_NAME}_CATKIN_DEPS}
-#  DEPENDS system_lib
-)
-
-###########
-## Build ##
-###########
-
-include_directories(
-  include ${catkin_INCLUDE_DIRS}
 )
 
-## Declare a C++ library
-# add_library(labjack_driver
-#   src/${PROJECT_NAME}/labjack_driver.cpp
-# )
-
-## Declare a C++ executable
-# add_executable(labjack_driver_node src/labjack_driver_node.cpp)
-
-## Specify libraries to link a library or executable target against
-# target_link_libraries(labjack_driver_node
-#   ${catkin_LIBRARIES}
-# )
-
 #############
 ## Install ##
 #############
diff --git a/README.md b/README.md
index 8e26683..e16833f 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,9 @@
 ## exodriver
 
 `git clone git://github.com/labjack/exodriver.git`
+
 `cd exodriver/`
+
 `sudo ./install.sh`
 
 ## LabJackPython
diff --git a/scripts/stream_node.py b/scripts/stream_node.py
index e13482e..9a86eb3 100755
--- a/scripts/stream_node.py
+++ b/scripts/stream_node.py
@@ -21,7 +21,7 @@ import ue9
 
 class Labjack(object):
     def __init__(self, channel, resolution=16, scan_freq=150):
-        self.channel_name = "AIN"+channel
+        self.channel_name = "AIN"+str(channel)
         self.d = ue9.UE9()
         self.d.getCalibrationData()
         self.d.streamConfig(
@@ -42,6 +42,9 @@ class Labjack(object):
         self.timer = rospy.Timer(rospy.Duration(timer_period), self.timer_callback)
         rospy.spin()
 
+        self.d.streamStop()
+        self.d.close()
+
     def timer_callback(self, event):
         msg = Float32()
         # Conversion in milli volt for gain 1
@@ -52,11 +55,7 @@ class Labjack(object):
                 self.pub.publish(msg)
 
 
-def main(args=None):
+if __name__ == '__main__':
     rospy.init_node('labjack', anonymous=True)
 
-    node = Labjack(1)
-
-
-if __name__ == '__main__':
-    main()
+    node = Labjack(1)
\ No newline at end of file
-- 
GitLab