5252# config-pin P8.42 qep
5353# cat /sys/devices/platform/ocp/48304000.epwmss/48304180.eqep/position
5454
55+ from subprocess import call
5556import os
5657
5758class QEP :
@@ -99,7 +100,25 @@ class RotaryEncoder(object):
99100 EQEP1 = 1
100101 EQEP2 = 2
101102 EQEP2b = 3
102-
103+
104+ def config_pin (self , pin ):
105+ '''
106+ config_pin()
107+ Config pin for QEP
108+ '''
109+ result = call (["config-pin" , pin , "qep" ])
110+ print "config_pin> pin={0} result={1}" .format (pin , result )
111+ return result
112+
113+ def cat_file (self , path ):
114+ '''
115+ cat_file()
116+ Print contents of file
117+ '''
118+ result = call (["cat" , path ])
119+ print "cat_file> path={0} result={1}" .format (path , result )
120+ return result
121+
103122 def __init__ (self , eqep_num ):
104123 '''
105124 RotaryEncoder(eqep_num)
@@ -108,6 +127,58 @@ def __init__(self, eqep_num):
108127 eqep_num can be: EQEP0, EQEP1, EQEP2 or EQEP2b based on which pins \
109128 the rotary encoder is connected to.
110129 '''
130+ print ">>>>>>>> TEST CALL BEGIN"
131+
132+ ###################################
133+ print ">>>>>> eqep0: P9_27, P9_92"
134+ pin = "P9_27"
135+ self .config_pin (pin )
136+
137+ pin = "P9_92"
138+ self .config_pin (pin )
139+
140+ path = "/sys/devices/platform/ocp/48300000.epwmss/48300180.eqep/position"
141+ self .cat_file (path );
142+
143+ ###################################
144+ print ">>>>>>> eqep1: P8.33, P8.35"
145+
146+ pin = "P8.33"
147+ self .config_pin (pin )
148+
149+ pin = "P8.35"
150+ self .config_pin (pin )
151+
152+ path = "/sys/devices/platform/ocp/48302000.epwmss/48302180.eqep/position"
153+ self .cat_file (path );
154+
155+ ###################################
156+ print ">>>>>>> eqep2: P8.11, P8.12"
157+
158+ pin = "P8.11"
159+ self .config_pin (pin )
160+
161+ pin = "P8.12"
162+ self .config_pin (pin )
163+
164+ path = "/sys/devices/platform/ocp/48304000.epwmss/48304180.eqep/position"
165+ self .cat_file (path );
166+
167+ ###################################
168+ print ">>>>>>> eqep2b: P8.41, P8.42"
169+
170+ pin = "P8.41"
171+ self .config_pin (pin )
172+
173+ pin = "P8.42"
174+ self .config_pin (pin )
175+
176+ path = "/sys/devices/platform/ocp/48304000.epwmss/48304180.eqep/position"
177+ self .cat_file (path );
178+
179+ ###################################
180+ print ">>>>>>>> TEST CALL END"
181+
111182 print ("RotaryEncoder(): eqep_num: {0}" .format (eqep_num ))
112183 print ("RotaryEncoder(): self._eqep_dirs[0]: {0}" .format (self ._eqep_dirs [0 ]))
113184 print ("RotaryEncoder(): self._eqep_dirs[1]: {0}" .format (self ._eqep_dirs [1 ]))
@@ -117,7 +188,7 @@ def __init__(self, eqep_num):
117188 self .base_dir = self ._eqep_dirs [eqep_num ]
118189 print ("RotaryEncoder(): self.base_dir: {0}" .format (self .base_dir ))
119190 self .enable ()
120-
191+
121192 def enable (self ):
122193 '''
123194 enable()
0 commit comments